From 006c372278d0686f99f95a282e1f440924ad2079 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:06:59 +0530 Subject: [PATCH] Update foreign_policy.recipe --- recipes/foreign_policy.recipe | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/recipes/foreign_policy.recipe b/recipes/foreign_policy.recipe index a702fa81e0..914bfdb22a 100644 --- a/recipes/foreign_policy.recipe +++ b/recipes/foreign_policy.recipe @@ -47,8 +47,20 @@ class ForeignPolicy(BasicNewsRecipe): ] remove_tags_after = [classes('post-content-main')] + recipe_specific_options = { + 'issue': { + 'short': 'Enter the Issue Number you want to download ', + 'long': 'For example, 411131563' + } + } + def parse_index(self): - soup = self.index_to_soup('https://foreignpolicy.com/the-magazine') + issue_url = 'https://foreignpolicy.com/the-magazine' + d = self.recipe_specific_options.get('issue') + if d and isinstance(d, str): + issue_url = issue_url + '/?issue_id=' + d + + soup = self.index_to_soup(issue_url) img = soup.find('img', attrs={'src': lambda x: x and '-cover' in x}) if img: self.cover_url = img['src'].split('?')[0] + '?w=800?quality=90'