mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
601d13e98d
@ -5,9 +5,6 @@ from datetime import datetime
|
|||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
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):
|
def get_contents(x):
|
||||||
if x == '':
|
if x == '':
|
||||||
@ -60,6 +57,13 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
)
|
)
|
||||||
remove_empty_feeds = True
|
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 = [
|
remove_tags = [
|
||||||
dict(name=['button', 'svg', 'meta']),
|
dict(name=['button', 'svg', 'meta']),
|
||||||
dict(name='div', attrs={'id':['bb-that', 'bb-nav']}),
|
dict(name='div', attrs={'id':['bb-that', 'bb-nav']}),
|
||||||
@ -82,6 +86,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
inx = 'https://cdn-mobapi.bloomberg.com'
|
inx = 'https://cdn-mobapi.bloomberg.com'
|
||||||
sec = self.index_to_soup(inx + '/wssmobile/v1/bw/news/list?limit=1', raw=True)
|
sec = self.index_to_soup(inx + '/wssmobile/v1/bw/news/list?limit=1', raw=True)
|
||||||
id = json.loads(sec)['magazines'][0]['id']
|
id = json.loads(sec)['magazines'][0]['id']
|
||||||
|
past_edition = self.recipe_specific_options.get('date')
|
||||||
if past_edition:
|
if past_edition:
|
||||||
id = past_edition
|
id = past_edition
|
||||||
edit = self.index_to_soup(inx + '/wssmobile/v1/bw/news/week/' + id, raw=True)
|
edit = self.index_to_soup(inx + '/wssmobile/v1/bw/news/week/' + id, raw=True)
|
||||||
|
@ -55,7 +55,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
'Bloomberg delivers business and markets news, data, analysis, and video'
|
'Bloomberg delivers business and markets news, data, analysis, and video'
|
||||||
' to the world, featuring stories from Businessweek and Bloomberg News.'
|
' to the world, featuring stories from Businessweek and Bloomberg News.'
|
||||||
)
|
)
|
||||||
oldest_article = 1 # days
|
oldest_article = 1.2 # days
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
cover_url = 'https://assets.bwbx.io/images/users/iqjWHBFdfxIU/ivUxvlPidC3M/v0/600x-1.jpg'
|
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;}
|
.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):
|
def parse_index(self):
|
||||||
|
d = self.recipe_specific_options.get('days')
|
||||||
|
if d:
|
||||||
|
self.oldest_article = d
|
||||||
inx = 'https://cdn-mobapi.bloomberg.com'
|
inx = 'https://cdn-mobapi.bloomberg.com'
|
||||||
sec = self.index_to_soup(inx + '/wssmobile/v1/navigation/bloomberg_app/search-v2', raw=True)
|
sec = self.index_to_soup(inx + '/wssmobile/v1/navigation/bloomberg_app/search-v2', raw=True)
|
||||||
sec_data = json.loads(sec)['searchNav']
|
sec_data = json.loads(sec)['searchNav']
|
||||||
|
@ -60,10 +60,13 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
return soup
|
return soup
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
mag_url = None
|
|
||||||
local_edition = self.recipe_specific_options.get('location')
|
local_edition = self.recipe_specific_options.get('location')
|
||||||
if local_edition:
|
if local_edition:
|
||||||
local_edition = 'th_' + local_edition
|
local_edition = 'th_' + local_edition
|
||||||
|
else:
|
||||||
|
local_edition = 'th_international'
|
||||||
|
|
||||||
past_edition = self.recipe_specific_options.get('date')
|
past_edition = self.recipe_specific_options.get('date')
|
||||||
|
|
||||||
dt = date.today()
|
dt = date.today()
|
||||||
@ -71,36 +74,20 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
year, month, day = (int(x) for x in past_edition.split('-'))
|
year, month, day = (int(x) for x in past_edition.split('-'))
|
||||||
dt = date(year, month, day)
|
dt = date(year, month, day)
|
||||||
|
|
||||||
is_monday = dt.weekday() == 0
|
today = dt.strftime('%Y-%m-%d')
|
||||||
is_friday = dt.weekday() == 4
|
|
||||||
is_saturday = dt.weekday() == 5
|
|
||||||
is_sunday = dt.weekday() == 6
|
|
||||||
|
|
||||||
|
self.log('Downloading The Hindu, ' + local_edition[3:] + ' edition, ' + today)
|
||||||
|
url = absurl('/todays-paper/' + today + '/' + local_edition + '/')
|
||||||
|
|
||||||
if local_edition or past_edition:
|
mag_url = None
|
||||||
if local_edition is None:
|
if dt.weekday() == 0:
|
||||||
local_edition = 'th_chennai'
|
mag_url = url + '?supplement=' + local_edition + '-epbs'
|
||||||
today = date.today().strftime('%Y-%m-%d')
|
if dt.weekday() == 4:
|
||||||
if past_edition:
|
mag_url = url + '?supplement=' + local_edition + '-fr'
|
||||||
today = past_edition
|
if dt.weekday() == 5:
|
||||||
self.log('Downloading past edition of', local_edition + ' from ' + today)
|
mag_url = url + '?supplement=' + local_edition + '-mp'
|
||||||
url = absurl('/todays-paper/' + today + '/' + local_edition + '/')
|
if dt.weekday() == 6:
|
||||||
if is_monday:
|
mag_url = url + '?supplement=' + local_edition + '-sm'
|
||||||
mag_url = url + '?supplement=' + local_edition + '-epbs'
|
|
||||||
if is_saturday:
|
|
||||||
mag_url = url + '?supplement=' + local_edition + '-mp'
|
|
||||||
if is_sunday:
|
|
||||||
mag_url = url + '?supplement=' + local_edition + '-sm'
|
|
||||||
else:
|
|
||||||
url = 'https://www.thehindu.com/todays-paper/'
|
|
||||||
if is_monday:
|
|
||||||
mag_url = url + '?supplement=th_chennai-epbs'
|
|
||||||
if is_friday:
|
|
||||||
mag_url = url + '?supplement=th_chennai-fr'
|
|
||||||
if is_saturday:
|
|
||||||
mag_url = url + '?supplement=th_chennai-mp'
|
|
||||||
if is_sunday:
|
|
||||||
mag_url = url + '?supplement=th_chennai-sm'
|
|
||||||
|
|
||||||
raw = self.index_to_soup(url, raw=True)
|
raw = self.index_to_soup(url, raw=True)
|
||||||
soup = self.index_to_soup(raw)
|
soup = self.index_to_soup(raw)
|
||||||
@ -139,7 +126,7 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
title = item['articleheadline']
|
title = item['articleheadline']
|
||||||
url = absurl(item['href'])
|
url = absurl(item['href'])
|
||||||
desc = 'Page no.' + item['pageno'] + ' | ' + item['teaser_text'] or ''
|
desc = 'Page no.' + item['pageno'] + ' | ' + item['teaser_text'] or ''
|
||||||
self.log('\t', title, '\n\t\t', url)
|
self.log(' ', title, '\n\t', url)
|
||||||
feeds_dict[section].append({"title": title, "url": url, "description": desc})
|
feeds_dict[section].append({"title": title, "url": url, "description": desc})
|
||||||
return [(section, articles) for section, articles in feeds_dict.items()]
|
return [(section, articles) for section, articles in feeds_dict.items()]
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user