Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
niqdev merged 4 commits into niqdev:master from lszeremeta:master
Dec 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/dev.cfg
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ credential.password=testPwd
[path]
path.ebooks=ebooks
path.extras=ebooks/extras
#path.separate.ebooks=MY/EBOOKS/FOLDER
#path.separate.extras=MY/EXTRAS/FOLDER

[drive]
drive.oauth2_scope=https://www.googleapis.com/auth/drive
Expand Down
3 changes: 3 additions & 0 deletions config/prod_example.cfg
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ credential.password=PACKTPUB_PASSWORD
[path]
path.ebooks=ebooks
path.extras=ebooks/extras
#path.separate.ebooks=MY/EBOOKS/FOLDER
#path.separate.extras=MY/EXTRAS/FOLDER
Copy link
Owner

@niqdev niqdev Dec 6, 2016
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, I like it in this way with the has_option

lszeremeta reacted with thumbs up emoji
path.separate.space=_

[drive]
drive.oauth2_scope=https://www.googleapis.com/auth/drive
Expand Down
21 changes: 19 additions & 2 deletions script/packtpub.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,16 @@ def download_ebooks(self, types):
filename=self.info['filename'] + '.' + type)
for type in types]

directory = self.__config.get('path', 'path.ebooks')
if self.__config.has_option('path', 'path.separate.extras'):
space = self.__config.get('path', 'path.separate.space')

if space == '?':
space = ' '

directory = self.__config.get('path', 'path.separate.ebooks') + '/' + self.info['title'].encode('ascii', 'ignore').replace(' ', space) + space + '-' + space + self.info['author'].encode('ascii', 'ignore').replace(' ', space)
else:
directory = self.__config.get('path', 'path.ebooks')

for download in downloads_info:
self.info['paths'].append(
download_file(self.__session, download['url'], directory, download['filename'], self.__headers))
Expand All @@ -132,7 +141,15 @@ def download_extras(self):
"""
"""

directory = self.__config.get('path', 'path.extras')
if self.__config.has_option('path', 'path.separate.extras'):
space = self.__config.get('path', 'path.separate.space')

if space == '?':
space = ' '

directory = self.__config.get('path', 'path.separate.ebooks') + '/' + self.info['title'].encode('ascii', 'ignore').replace(' ', space) + space + '-' + space + self.info['author'].encode('ascii', 'ignore').replace(' ', space) + '/' + self.__config.get('path', 'path.separate.extras')
else:
directory = self.__config.get('path', 'path.extras')

url_image = self.info['url_image']
filename = self.info['filename'] + '_' + split(url_image)[1]
Expand Down

AltStyle によって変換されたページ (->オリジナル) /