diff --git a/config/dev.cfg b/config/dev.cfg index 67c691c..2e6735a 100644 --- a/config/dev.cfg +++ b/config/dev.cfg @@ -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 diff --git a/config/prod_example.cfg b/config/prod_example.cfg index e2d4f47..25c8eed 100644 --- a/config/prod_example.cfg +++ b/config/prod_example.cfg @@ -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 +path.separate.space=_ [drive] drive.oauth2_scope=https://www.googleapis.com/auth/drive diff --git a/script/packtpub.py b/script/packtpub.py index 9963a3c..74e8098 100644 --- a/script/packtpub.py +++ b/script/packtpub.py @@ -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)) @@ -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]

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