mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Merge branch 'master' of https://github.com/Monkfishare/calibre
This commit is contained in:
commit
920b87ac2b
@ -11,6 +11,7 @@ from mechanize import Request
|
||||
|
||||
from calibre import browser
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.date import parse_only_date
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
|
||||
@ -246,6 +247,17 @@ class Economist(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
|
||||
return br
|
||||
|
||||
def publication_date(self):
|
||||
edition_date = self.recipe_specific_options.get('date')
|
||||
if edition_date and isinstance(edition_date, str):
|
||||
return parse_only_date(edition_date, as_utc=False)
|
||||
try:
|
||||
url = self.browser.open('https://www.economist.com/printedition').geturl()
|
||||
except Exception as e:
|
||||
self.log('Failed to fetch publication date with error: ' + str(e))
|
||||
return super().publication_date()
|
||||
return parse_only_date(url.split('/')[-1], as_utc=False)
|
||||
|
||||
def economist_return_index(self, ans):
|
||||
if not ans:
|
||||
raise NoArticles(
|
||||
|
@ -11,6 +11,7 @@ from mechanize import Request
|
||||
|
||||
from calibre import browser
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.date import parse_only_date
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
|
||||
|
||||
@ -246,6 +247,17 @@ class Economist(BasicNewsRecipe):
|
||||
br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
|
||||
return br
|
||||
|
||||
def publication_date(self):
|
||||
edition_date = self.recipe_specific_options.get('date')
|
||||
if edition_date and isinstance(edition_date, str):
|
||||
return parse_only_date(edition_date, as_utc=False)
|
||||
try:
|
||||
url = self.browser.open('https://www.economist.com/printedition').geturl()
|
||||
except Exception as e:
|
||||
self.log('Failed to fetch publication date with error: ' + str(e))
|
||||
return super().publication_date()
|
||||
return parse_only_date(url.split('/')[-1], as_utc=False)
|
||||
|
||||
def economist_return_index(self, ans):
|
||||
if not ans:
|
||||
raise NoArticles(
|
||||
|
Loading…
x
Reference in New Issue
Block a user