-
Notifications
You must be signed in to change notification settings - Fork 176
Download books and extras into separate directories #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
If path.separate is set to true in the configuration file, downloads books and extras into separate directory. Examples: ebooks/TITLE - AUTHOR/TITLE.pdf ... ebooks/TITLE - AUTHOR/extras/TITLE.png Note that if you use separate directories path.extras behaves differently. The code is only a suggestion (preview) of new functionality, but works properly with local download. Other features to check (possible complications with Google Drive upload). Instead of setting this in the configuration file, separate or not directory can be changed by additional option from the command line.
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,8 @@ credential.password=testPwd | |
|
|
||
| [path] | ||
| path.ebooks=ebooks | ||
| path.extras=ebooks/extras | ||
| path.extras=extras | ||
| path.separate=true | ||
|
||
|
|
||
| [drive] | ||
| drive.oauth2_scope=https://www.googleapis.com/auth/drive | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,6 +124,10 @@ def download_ebooks(self, types): | |
| for type in types] | ||
|
|
||
| directory = self.__config.get('path', 'path.ebooks') | ||
|
|
||
| if self.__config.get('path', 'path.separate') == "true": | ||
| directory = directory + '/' + self.info['title'] + ' - ' + self.info['author'] | ||
|
||
|
|
||
| for download in downloads_info: | ||
| self.info['paths'].append( | ||
| download_file(self.__session, download['url'], directory, download['filename'], self.__headers)) | ||
|
|
@@ -134,6 +138,9 @@ def download_extras(self): | |
|
|
||
| directory = self.__config.get('path', 'path.extras') | ||
|
|
||
| if self.__config.get('path', 'path.separate') == "true": | ||
| directory = self.__config.get('path', 'path.ebooks') + '/' + self.info['title'] + ' - ' + self.info['author'] + '/' + directory | ||
|
|
||
| url_image = self.info['url_image'] | ||
| filename = self.info['filename'] + '_' + split(url_image)[1] | ||
| self.info['paths'].append(download_file(self.__session, url_image, directory, filename, self.__headers)) | ||
|
|
||