mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update toiprint.recipe
This commit is contained in:
parent
cae829301b
commit
c5b0f893ef
@ -29,6 +29,7 @@ class toiprint(BasicNewsRecipe):
|
|||||||
masthead_url = 'https://static.toiimg.com/photo/98333929.cms'
|
masthead_url = 'https://static.toiimg.com/photo/98333929.cms'
|
||||||
timefmt = ' [' + dt.strftime('%b %d, %Y') + ']'
|
timefmt = ' [' + dt.strftime('%b %d, %Y') + ']'
|
||||||
description = 'Articles from the Times of India epaper, digital edition'
|
description = 'Articles from the Times of India epaper, digital edition'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
BasicNewsRecipe.__init__(self, *args, **kwargs)
|
BasicNewsRecipe.__init__(self, *args, **kwargs)
|
||||||
@ -37,7 +38,7 @@ class toiprint(BasicNewsRecipe):
|
|||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
.sub { color:#5c5c5c; }
|
.sub { color:#5c5c5c; }
|
||||||
.auth { font-size:small; }
|
.auth { font-size:small; font-weight:bold; color:#202020; }
|
||||||
.cap { text-align:center; font-size:small; }
|
.cap { text-align:center; font-size:small; }
|
||||||
img { display:block; margin:0 auto; }
|
img { display:block; margin:0 auto; }
|
||||||
'''
|
'''
|
||||||
@ -72,7 +73,10 @@ class toiprint(BasicNewsRecipe):
|
|||||||
page = link.split('_')[-3]
|
page = link.split('_')[-3]
|
||||||
url = page + '-' + link
|
url = page + '-' + link
|
||||||
title = art.get('ArticleTitle', 'unknown')
|
title = art.get('ArticleTitle', 'unknown')
|
||||||
desc = 'Page No.' + page + ' | ' + art.get('ColumnTitle', '')
|
if art.get('ColumnTitle', '') == '':
|
||||||
|
desc = 'Page No.' + page + ' | ' + art.get('ArticleBody', '')
|
||||||
|
else:
|
||||||
|
desc = 'Page No.' + page + ' | ' + art.get('ColumnTitle', '')
|
||||||
self.log('\t', title, '\n\t', desc, '\n\t\t', url)
|
self.log('\t', title, '\n\t', desc, '\n\t\t', url)
|
||||||
articles.append({'title': title, 'description':desc, 'url': url})
|
articles.append({'title': title, 'description':desc, 'url': url})
|
||||||
if articles:
|
if articles:
|
||||||
@ -88,18 +92,18 @@ class toiprint(BasicNewsRecipe):
|
|||||||
if x['TagName'] == 'ColumnTitle':
|
if x['TagName'] == 'ColumnTitle':
|
||||||
body += '<p class="sub"><b>' + x['ZoneText'] + '</b></p>'
|
body += '<p class="sub"><b>' + x['ZoneText'] + '</b></p>'
|
||||||
if x['TagName'] == 'Author':
|
if x['TagName'] == 'Author':
|
||||||
body += '<p class="auth"><i>' + x['ZoneText'].replace('<br>', '') + '</i></p>'
|
body += '<p class="auth">' + x['ZoneText'].replace('<br>', '') + '</p>'
|
||||||
if x['TagName'] in {'ArticleBody', 'Information'}:
|
if x['TagName'] in {'ArticleBody', 'Information'}:
|
||||||
body += x['ZoneText']
|
body += x['ZoneText']
|
||||||
if x['TagName'] == 'LinkTo':
|
if x['TagName'] in {'LinkTo', 'LinkFrom'}:
|
||||||
body += '<p><i>' + x['ZoneText'] + '</i></p>'
|
body += '<p class="auth"><i>' + x['ZoneText'] + '</i></p>'
|
||||||
if x['TagName'] == 'Photographs':
|
if x['TagName'] == 'Photographs':
|
||||||
pag = x['ZoneID'].split('_')[-4]
|
pag = x['ZoneID'].split('_')[-4]
|
||||||
body += '<div><img src="{}"></div>'.format(img_index + '/Photographs/' + pag + '/' \
|
body += '<div><img src="{}"></div>'.format(img_index + '/Photographs/' + pag + '/' \
|
||||||
+ x['ZoneID'] + '.jpg&bucket=andre-toi-out&q=50')
|
+ x['ZoneID'] + '.jpg&bucket=andre-toi-out&q=50')
|
||||||
if x['TagName'] == 'ImageCaption':
|
if x['TagName'] == 'ImageCaption':
|
||||||
body += '<div class="cap">' + x['ZoneText'] + '</div><p>'
|
body += '<div class="cap">' + x['ZoneText'] + '</div><p>'
|
||||||
return '<html><body><div>' + body.replace('<br>', '<p>') + '</div></body></html>'
|
return '<html><body><div>' + body.replace('<br>', '<p>').replace('<br/>', '<p>') + '</div></body></html>'
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
return index + '/ArticleZoneJson/' + url.replace('-', '/') + '.json'
|
return index + '/ArticleZoneJson/' + url.replace('-', '/') + '.json'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user