diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe index 3d94f6868a..5cf8d4d5b0 100644 --- a/recipes/bloomberg-business-week.recipe +++ b/recipes/bloomberg-business-week.recipe @@ -5,9 +5,6 @@ from datetime import datetime from calibre.ebooks.BeautifulSoup import BeautifulSoup from calibre.web.feeds.news import BasicNewsRecipe, classes -# https://www.bloomberg.com/magazine/businessweek/24_12 -# Set past_edition to edition id, which is '24_12'. -past_edition = None def get_contents(x): if x == '': @@ -60,6 +57,13 @@ class Bloomberg(BasicNewsRecipe): ) remove_empty_feeds = True + recipe_specific_options = { + 'date': { + 'short': 'The ID of the edition to download (YY_XX format)', + 'long': 'For example, 24_17\nHint: Edition ID can be found at the end of its URL' + } + } + remove_tags = [ dict(name=['button', 'svg', 'meta']), dict(name='div', attrs={'id':['bb-that', 'bb-nav']}), @@ -82,6 +86,7 @@ class Bloomberg(BasicNewsRecipe): inx = 'https://cdn-mobapi.bloomberg.com' sec = self.index_to_soup(inx + '/wssmobile/v1/bw/news/list?limit=1', raw=True) id = json.loads(sec)['magazines'][0]['id'] + past_edition = self.recipe_specific_options.get('date') if past_edition: id = past_edition edit = self.index_to_soup(inx + '/wssmobile/v1/bw/news/week/' + id, raw=True) diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe index 3a9557570b..f34278ab9c 100644 --- a/recipes/bloomberg.recipe +++ b/recipes/bloomberg.recipe @@ -55,7 +55,7 @@ class Bloomberg(BasicNewsRecipe): 'Bloomberg delivers business and markets news, data, analysis, and video' ' to the world, featuring stories from Businessweek and Bloomberg News.' ) - oldest_article = 1 # days + oldest_article = 1.2 # days resolve_internal_links = True remove_empty_feeds = True cover_url = 'https://assets.bwbx.io/images/users/iqjWHBFdfxIU/ivUxvlPidC3M/v0/600x-1.jpg' @@ -78,7 +78,17 @@ class Bloomberg(BasicNewsRecipe): .news-figure-credit {font-size:small; text-align:center; color:#202020;} ''' + recipe_specific_options = { + 'days': { + 'short': 'Oldest article to download from this news source. In days ', + 'long': 'For example, 0.5, gives you articles for the past 12 hours' + } + } + def parse_index(self): + d = self.recipe_specific_options.get('days') + if d: + self.oldest_article = d inx = 'https://cdn-mobapi.bloomberg.com' sec = self.index_to_soup(inx + '/wssmobile/v1/navigation/bloomberg_app/search-v2', raw=True) sec_data = json.loads(sec)['searchNav']