Allow more book types
This commit is contained in:
		| @@ -20,7 +20,7 @@ else: | |||||||
|     ebook_dir = os.path.expanduser(ebook_dir) |     ebook_dir = os.path.expanduser(ebook_dir) | ||||||
|     for root, dirs, files in os.walk(ebook_dir): |     for root, dirs, files in os.walk(ebook_dir): | ||||||
| 	for file in files: | 	for file in files: | ||||||
| 	    if re.search('.(rar|zip|epub|mobi|lit|html)(.\d+)?', file): | 	    if re.search('.(rar|zip|epub|mobi|lit|html|rtf|azw3)(.\d+)?', file): | ||||||
|                 try: |                 try: | ||||||
|                     if os.path.getmtime(file) >= age: |                     if os.path.getmtime(file) >= age: | ||||||
|         	        books.append(os.path.join(root, file)) |         	        books.append(os.path.join(root, file)) | ||||||
| @@ -42,13 +42,13 @@ for book in books: | |||||||
|         # unzip |         # unzip | ||||||
|         archive = zipfile.ZipFile(book) |         archive = zipfile.ZipFile(book) | ||||||
|         archive.extractall(tmp) |         archive.extractall(tmp) | ||||||
|     elif re.search('.(epub|mobi|lit|html)', book): |     elif re.search('.(epub|mobi|lit|html|rtf|awz3)', book): | ||||||
|         # copy book into tmp |         # copy book into tmp | ||||||
|         shutil.copy(book, tmp) |         shutil.copy(book, tmp) | ||||||
|     # find epub, mobi or lit and import into calibre |     # find epub, mobi or lit and import into calibre | ||||||
|     for root, dirs, files in os.walk(tmp): |     for root, dirs, files in os.walk(tmp): | ||||||
| 	for file in files: | 	for file in files: | ||||||
|             if re.search('.(epub|mobi|lit|html)$', file): |             if re.search('.(epub|mobi|lit|html|rtf|azw3)$', file): | ||||||
|                 try: |                 try: | ||||||
|                     subprocess.call(["calibredb", "add", os.path.join(root, file)]) |                     subprocess.call(["calibredb", "add", os.path.join(root, file)]) | ||||||
|                 except Exception, e: |                 except Exception, e: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user