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
c976875ee6
@ -11,10 +11,10 @@ def get_contents(x):
|
|||||||
if otype == 'text':
|
if otype == 'text':
|
||||||
if 'attributes' in x:
|
if 'attributes' in x:
|
||||||
if 'strong' in x['attributes']:
|
if 'strong' in x['attributes']:
|
||||||
return '<b>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</b>'
|
return '<strong>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</strong>'
|
||||||
if 'emphasis' in x['attributes']:
|
if 'emphasis' in x['attributes']:
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<em>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</em>'
|
||||||
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
||||||
elif otype == 'br':
|
elif otype == 'br':
|
||||||
return '<br>'
|
return '<br>'
|
||||||
@ -30,8 +30,8 @@ def get_contents(x):
|
|||||||
return '<blockquote class="col">' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</blockquote>'
|
return '<blockquote class="col">' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</blockquote>'
|
||||||
elif otype == 'media':
|
elif otype == 'media':
|
||||||
if x['subType'] == 'photo':
|
if x['subType'] == 'photo':
|
||||||
return '<div><div class="img"><img src="{}"></div><div class="cap">{}</div></div>'.format(
|
return '<div><div class="img"><img src="{}"></div><div class="cap">{}<div>{}</div></div></div>'.format(
|
||||||
x['data']['photo']['src'], x['data']['photo']['caption'])
|
x['data']['photo']['src'], x['data']['photo']['caption'], x['data']['photo']['credit'])
|
||||||
elif x['subType'] == 'chart':
|
elif x['subType'] == 'chart':
|
||||||
if x['data'] and x['data']['chart']:
|
if x['data'] and x['data']['chart']:
|
||||||
return '<div class="img"><img src="{}"></div>'.format(x['data']['chart']['fallback'])
|
return '<div class="img"><img src="{}"></div>'.format(x['data']['chart']['fallback'])
|
||||||
@ -50,6 +50,8 @@ def get_contents(x):
|
|||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
|
elif otype in {'div', 'callout'}:
|
||||||
|
return '<div>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</div>'
|
||||||
elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']):
|
elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']):
|
||||||
if any(b in x for b in ['value', 'content']):
|
if any(b in x for b in ['value', 'content']):
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
@ -77,7 +79,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
.auth {font-size:small; font-weight:bold;}
|
.auth {font-size:small; font-weight:bold;}
|
||||||
.time, .chart, .css--lede-byline, .css--lede-timestamp {font-size:small;}
|
.time, .chart, .css--lede-byline, .css--lede-timestamp {font-size:small;}
|
||||||
.subhead {font-style:italic; color:#404040;}
|
.subhead {font-style:italic; color:#404040;}
|
||||||
i, .col {color:#202020;}
|
em, .col {color:#202020;}
|
||||||
.cat {font-size:small; color:gray;}
|
.cat {font-size:small; color:gray;}
|
||||||
.news-figure-caption-text, .cap, .img, .css--caption-outer-wrapper {font-size:small; text-align:center;}
|
.news-figure-caption-text, .cap, .img, .css--caption-outer-wrapper {font-size:small; text-align:center;}
|
||||||
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
||||||
@ -179,7 +181,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
body_data = data['body']['content']
|
body_data = data['body']['content']
|
||||||
for x in body_data:
|
for x in body_data:
|
||||||
body += get_contents(x)
|
body += get_contents(x)
|
||||||
pause = random.choice((3, 4, 5, 6))
|
pause = random.choice((5, 6, 7, 8, 9))
|
||||||
self.log('Delay: ', pause, ' seconds')
|
self.log('Delay: ', pause, ' seconds')
|
||||||
time.sleep(pause)
|
time.sleep(pause)
|
||||||
return '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body + '</div></body></html>'
|
return '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body + '</div></body></html>'
|
||||||
|
@ -12,10 +12,10 @@ def get_contents(x):
|
|||||||
if otype == 'text':
|
if otype == 'text':
|
||||||
if 'attributes' in x:
|
if 'attributes' in x:
|
||||||
if 'strong' in x['attributes']:
|
if 'strong' in x['attributes']:
|
||||||
return '<b>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</b>'
|
return '<strong>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</strong>'
|
||||||
if 'emphasis' in x['attributes']:
|
if 'emphasis' in x['attributes']:
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<em>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</em>'
|
||||||
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
return x.get('value', '') + ''.join(map(get_contents, x.get('content', '')))
|
||||||
elif otype == 'br':
|
elif otype == 'br':
|
||||||
return '<br>'
|
return '<br>'
|
||||||
@ -31,8 +31,8 @@ def get_contents(x):
|
|||||||
return '<blockquote class="col">' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</blockquote>'
|
return '<blockquote class="col">' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</blockquote>'
|
||||||
elif otype == 'media':
|
elif otype == 'media':
|
||||||
if x['subType'] == 'photo':
|
if x['subType'] == 'photo':
|
||||||
return '<div><div class="img"><img src="{}"></div><div class="cap">{}</div></div>'.format(
|
return '<div><div class="img"><img src="{}"></div><div class="cap">{}<div>{}</div></div></div>'.format(
|
||||||
x['data']['photo']['src'], x['data']['photo']['caption'])
|
x['data']['photo']['src'], x['data']['photo']['caption'], x['data']['photo']['credit'])
|
||||||
elif x['subType'] == 'chart':
|
elif x['subType'] == 'chart':
|
||||||
if x['data'] and x['data']['chart']:
|
if x['data'] and x['data']['chart']:
|
||||||
return '<div class="img"><img src="{}"></div>'.format(x['data']['chart']['fallback'])
|
return '<div class="img"><img src="{}"></div>'.format(x['data']['chart']['fallback'])
|
||||||
@ -51,6 +51,8 @@ def get_contents(x):
|
|||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
|
elif otype in {'div', 'callout'}:
|
||||||
|
return '<div>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</div>'
|
||||||
elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']):
|
elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']):
|
||||||
if any(b in x for b in ['value', 'content']):
|
if any(b in x for b in ['value', 'content']):
|
||||||
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
return '<i>' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '</i>'
|
||||||
@ -76,7 +78,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
.auth {font-size:small; font-weight:bold;}
|
.auth {font-size:small; font-weight:bold;}
|
||||||
.time, .chart {font-size:small;}
|
.time, .chart {font-size:small;}
|
||||||
.subhead {font-style:italic; color:#404040;}
|
.subhead {font-style:italic; color:#404040;}
|
||||||
i, .col {color:#202020;}
|
em, .col {color:#202020;}
|
||||||
.cat {font-size:small; color:gray;}
|
.cat {font-size:small; color:gray;}
|
||||||
.news-figure-caption-text, .cap, .img {font-size:small; text-align:center;}
|
.news-figure-caption-text, .cap, .img {font-size:small; text-align:center;}
|
||||||
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
||||||
@ -177,7 +179,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
body_data = data['body']['content']
|
body_data = data['body']['content']
|
||||||
for x in body_data:
|
for x in body_data:
|
||||||
body += get_contents(x)
|
body += get_contents(x)
|
||||||
pause = random.choice((3, 4, 5, 6))
|
pause = random.choice((5, 6, 7, 8, 9))
|
||||||
self.log('Delay: ', pause, ' seconds')
|
self.log('Delay: ', pause, ' seconds')
|
||||||
time.sleep(pause)
|
time.sleep(pause)
|
||||||
return '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body + '</div></body></html>'
|
return '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body + '</div></body></html>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user