From aa8d44e1f84ea4765567434c26f934c27731c58a Mon Sep 17 00:00:00 2001 From: bobbysteel Date: Fri, 30 Jun 2017 16:32:16 +0100 Subject: [PATCH] Found a cover source --- recipes/sunday_times_magazine.recipe | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/recipes/sunday_times_magazine.recipe b/recipes/sunday_times_magazine.recipe index d65fa36644..47627e33cb 100644 --- a/recipes/sunday_times_magazine.recipe +++ b/recipes/sunday_times_magazine.recipe @@ -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',