Found a cover source

This commit is contained in:
bobbysteel 2017-06-30 16:32:16 +01:00 committed by GitHub
parent e30ee64f59
commit aa8d44e1f8

View File

@ -47,6 +47,26 @@ class TimesOnline(BasicNewsRecipe):
br.open('https://login.thetimes.co.uk/', data)
return br
def get_cover_url(self):
from datetime import date
from datetime import timedelta
today = date.today()
today_index = today.weekday()
if (today_index == 5): # new edition drops on Saturday AM
today += timedelta(1)
elif (today_index < 5): # Mon-Thurs
today_index = (today_index + 1) % 7 # Recalibrate to days back MON = 0, SUN = 6 -> SUN = 0 .. SAT = 6
today = today - timedelta(today_index) # Rewind to most recent Sunday
cover = 'https://cdn2-img.pressreader.com/pressdisplay/docserver/getimage.aspx?file=1174' + today.strftime('%Y') + today.strftime('%m') + today.strftime('%d') + '00000000001001&page=1&scale=100'
self.log(cover)
br = BasicNewsRecipe.get_browser(self)
try:
br.open(cover)
except:
self.log("\nCover unavailable")
cover = None
return cover
remove_tags = [
{'name': ['object', 'link', 'iframe', 'base', 'meta', 'script']},
{'attrs': {'class': ['tools comments-parent','u-hide','Tooltip','Toolbar Toolbar--bottom',