From 61bc5005fab5adabb4f345bcadb0d4b0b0a99a2b Mon Sep 17 00:00:00 2001 From: bobbysteel Date: Sun, 18 Jun 2017 04:05:27 +0100 Subject: [PATCH 1/2] add cover to FT --- recipes/financial_times_uk.recipe | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/recipes/financial_times_uk.recipe b/recipes/financial_times_uk.recipe index 7d0087aedb..4804dc50a5 100644 --- a/recipes/financial_times_uk.recipe +++ b/recipes/financial_times_uk.recipe @@ -61,7 +61,23 @@ class FinancialTimes(BasicNewsRecipe): br['password'] = self.password br.submit() return br - + + def get_cover_url(self): + from datetime import timedelta, date + cover = 'http://img.kiosko.net/' + str(date.today().year) + '/' + date.today().strftime('%m') + '/' + date.today().strftime('%d') + '/uk/ft_uk.750.jpg' + br = BasicNewsRecipe.get_browser(self) + try: + br.open(cover) + except: + index = 'http://en.kiosko.net/uk/np/ft_uk.html' + soup = self.index_to_soup(index) + for image in soup.findAll('img', src=True): + if image['src'].endswith('750.jpg'): + return image['src'] + self.log("\nCover unavailable") + cover = None + return cover + def parse_index(self): feeds = OrderedDict() soup = self.index_to_soup(self.INDEX) From fd1b52d1637b987a599575db0b9cbcdfce4106b8 Mon Sep 17 00:00:00 2001 From: bobbysteel Date: Sun, 18 Jun 2017 04:10:07 +0100 Subject: [PATCH 2/2] fix spacing --- recipes/financial_times_uk.recipe | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/recipes/financial_times_uk.recipe b/recipes/financial_times_uk.recipe index 4804dc50a5..5b25a2f24e 100644 --- a/recipes/financial_times_uk.recipe +++ b/recipes/financial_times_uk.recipe @@ -70,11 +70,11 @@ class FinancialTimes(BasicNewsRecipe): br.open(cover) except: index = 'http://en.kiosko.net/uk/np/ft_uk.html' - soup = self.index_to_soup(index) - for image in soup.findAll('img', src=True): - if image['src'].endswith('750.jpg'): - return image['src'] - self.log("\nCover unavailable") + soup = self.index_to_soup(index) + for image in soup.findAll('img', src=True): + if image['src'].endswith('750.jpg'): + return image['src'] + self.log("\nCover unavailable") cover = None return cover