From 68aaed8872258b8a10764b90b8f73fb6f98479a3 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Tue, 2 Jan 2024 19:21:11 +0530 Subject: [PATCH] natgeo cover --- recipes/natgeo.recipe | 8 ++++++-- recipes/natgeomag.recipe | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/recipes/natgeo.recipe b/recipes/natgeo.recipe index adeca894b2..3b1b0b112c 100644 --- a/recipes/natgeo.recipe +++ b/recipes/natgeo.recipe @@ -137,8 +137,12 @@ class NatGeo(BasicNewsRecipe): ''' def get_cover_url(self): - soup = self.index_to_soup('https://www.nationalgeographic.com/magazine/') - png = re.findall('https://i\.natgeofe\.com\S+?national-geographic-\S+?\.jpg', soup.decode('utf-8')) + # soup = self.index_to_soup('https://www.nationalgeographic.com/magazine/') + # png = re.findall('https://i\.natgeofe\.com\S+?national-geographic-\S+?\.jpg', soup.decode('utf-8')) + from datetime import date + url = 'https://www.nationalgeographic.com/magazine/issue/' + (date.today().strftime('%B-%Y')).lower() + soup = self.index_to_soup(url) + png = soup.find('meta', attrs={'property':'og:image'})['content'].split('?') return png[0] + '?w=1000&h=1000' def parse_index(self): diff --git a/recipes/natgeomag.recipe b/recipes/natgeomag.recipe index 5b21fd54fd..a4869e4052 100644 --- a/recipes/natgeomag.recipe +++ b/recipes/natgeomag.recipe @@ -143,8 +143,9 @@ class NatGeo(BasicNewsRecipe): self.log('Downloading ', url) self.timefmt = ' [' + edition + ']' soup = self.index_to_soup(url) - png = re.findall('https://i\.natgeofe\.com\S+?national-geographic-\S+?\.jpg', soup.decode('utf-8')) - self.cover_url = png[0] + '?w=1000&h=1000' + # png = re.findall('https://i\.natgeofe\.com\S+?national-geographic-\S+?\.jpg', soup.decode('utf-8')) + # self.cover_url = png[0] + '?w=1000&h=1000' + self.cover_url = soup.find('meta', attrs={'property':'og:image'})['content'].split('?')[0] + '?w=1000' name = soup.find(attrs={'class':lambda x: x and 'Header__Description' in x.split()}) self.title = 'National Geographic ' + self.tag_to_string(name)