From d536c567853c51083205b9bcf808c6efa5153dba Mon Sep 17 00:00:00 2001 From: cdhigh Date: Tue, 30 Apr 2024 21:37:01 -0300 Subject: [PATCH] allow_redirect --- .../lib/calibre/ebooks/conversion/plugins/recipe_input.py | 6 +++++- application/lib/calibre/ebooks/conversion/plumber.py | 5 +++-- application/lib/urlopener.py | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/application/lib/calibre/ebooks/conversion/plugins/recipe_input.py b/application/lib/calibre/ebooks/conversion/plugins/recipe_input.py index 05795cf5..e5b34537 100644 --- a/application/lib/calibre/ebooks/conversion/plugins/recipe_input.py +++ b/application/lib/calibre/ebooks/conversion/plugins/recipe_input.py @@ -292,7 +292,11 @@ def add_article_toc(self, parent, entries, feedIdx): #onlyRecipe: 如果一本书仅包含一个BasicNewRecipe,则为True def build_meta(self, recipe1, onlyRecipe): title = recipe1.short_title() if onlyRecipe else 'KindleEar' - pdate = recipe1.publication_date() + try: + pdate = recipe1.publication_date() + except Exception as e: + default_log.warning('recipe1.publication_date error: {e}') + pdate = self.user.local_time() timefmt = recipe1.timefmt.strip() if timefmt and self.user.book_cfg('title_fmt'): title = f'{title} {strftime(timefmt, pdate)}' diff --git a/application/lib/calibre/ebooks/conversion/plumber.py b/application/lib/calibre/ebooks/conversion/plumber.py index 2f9327f0..37221c57 100644 --- a/application/lib/calibre/ebooks/conversion/plumber.py +++ b/application/lib/calibre/ebooks/conversion/plumber.py @@ -4,7 +4,7 @@ __copyright__ = '2009, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import os, re, sys, shutil, pprint, json, io, css_parser, logging +import os, re, sys, shutil, pprint, json, io, css_parser, logging, traceback from itertools import chain from functools import partial from calibre.utils.logging import Log @@ -396,7 +396,8 @@ def run(self): try: self.oeb = self.input_plugin(self.input_, self.opts, self.input_fmt, self.log, tdir, fs) except Exception as e: - self.log.warning('Failed to execute input plugin: {}'.format(str(e))) + #self.log.warning('Failed to execute input plugin: {}'.format(str(e))) + self.log.warning('Failed to execute input plugin: {}'.format(traceback.format_exc())) fs.clear() return diff --git a/application/lib/urlopener.py b/application/lib/urlopener.py index 553db69c..976e7ad5 100644 --- a/application/lib/urlopener.py +++ b/application/lib/urlopener.py @@ -73,7 +73,7 @@ def open_remote_url(self, url, data, headers, timeout, method, **kwargs): req_func = self.session.post try: - resp = req_func(url, data=data, headers=headers, timeout=timeout, **kwargs) + resp = req_func(url, data=data, headers=headers, timeout=timeout, allow_redirects=True, **kwargs) except Exception as e: resp = requests.models.Response() resp.status_code = 555