From 9b1a8bb6fcab88ae684ccc746df45987b6e5a877 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:37:55 +0530 Subject: [PATCH] Bloomberg update --- recipes/bloomberg-business-week.recipe | 16 +++++++++------- recipes/bloomberg.recipe | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe index 7ea4adf460..3c8acdabed 100644 --- a/recipes/bloomberg-business-week.recipe +++ b/recipes/bloomberg-business-week.recipe @@ -11,10 +11,10 @@ def get_contents(x): if otype == 'text': if 'attributes' in x: if 'strong' in x['attributes']: - return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' if 'emphasis' in x['attributes']: - return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' - return x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + 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': return '
' @@ -30,8 +30,8 @@ def get_contents(x): return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '
' elif otype == 'media': if x['subType'] == 'photo': - return '
{}
'.format( - x['data']['photo']['src'], x['data']['photo']['caption']) + return '
{}
{}
'.format( + x['data']['photo']['src'], x['data']['photo']['caption'], x['data']['photo']['credit']) elif x['subType'] == 'chart': if x['data'] and x['data']['chart']: return '
'.format(x['data']['chart']['fallback']) @@ -50,6 +50,8 @@ def get_contents(x): return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + elif otype in {'div', 'callout'}: + return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '
' elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']): if any(b in x for b in ['value', 'content']): return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' @@ -77,7 +79,7 @@ class Bloomberg(BasicNewsRecipe): .auth {font-size:small; font-weight:bold;} .time, .chart, .css--lede-byline, .css--lede-timestamp {font-size:small;} .subhead {font-style:italic; color:#404040;} - i, .col {color:#202020;} + em, .col {color:#202020;} .cat {font-size:small; color:gray;} .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;} @@ -179,7 +181,7 @@ class Bloomberg(BasicNewsRecipe): body_data = data['body']['content'] for x in body_data: body += get_contents(x) - pause = random.choice((3, 4, 5, 6)) + pause = random.choice((5, 6, 7, 8, 9)) self.log('Delay: ', pause, ' seconds') time.sleep(pause) return '' + cat + title + subhead + auth + lede + caption + '
' + body + '
' diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe index 50fe1033c1..10bf380349 100644 --- a/recipes/bloomberg.recipe +++ b/recipes/bloomberg.recipe @@ -12,10 +12,10 @@ def get_contents(x): if otype == 'text': if 'attributes' in x: if 'strong' in x['attributes']: - return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' if 'emphasis' in x['attributes']: - return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' - return x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + 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': return '
' @@ -31,8 +31,8 @@ def get_contents(x): return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '
' elif otype == 'media': if x['subType'] == 'photo': - return '
{}
'.format( - x['data']['photo']['src'], x['data']['photo']['caption']) + return '
{}
{}
'.format( + x['data']['photo']['src'], x['data']['photo']['caption'], x['data']['photo']['credit']) elif x['subType'] == 'chart': if x['data'] and x['data']['chart']: return '
'.format(x['data']['chart']['fallback']) @@ -51,6 +51,8 @@ def get_contents(x): return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' + elif otype in {'div', 'callout'}: + return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '
' elif not any(x == otype for x in ['', 'ad', 'inline-newsletter', 'tabularData']): if any(b in x for b in ['value', 'content']): return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content', ''))) + '' @@ -76,7 +78,7 @@ class Bloomberg(BasicNewsRecipe): .auth {font-size:small; font-weight:bold;} .time, .chart {font-size:small;} .subhead {font-style:italic; color:#404040;} - i, .col {color:#202020;} + em, .col {color:#202020;} .cat {font-size:small; color:gray;} .news-figure-caption-text, .cap, .img {font-size:small; text-align:center;} .news-figure-credit {font-size:small; text-align:center; color:#202020;} @@ -177,7 +179,7 @@ class Bloomberg(BasicNewsRecipe): body_data = data['body']['content'] for x in body_data: body += get_contents(x) - pause = random.choice((3, 4, 5, 6)) + pause = random.choice((5, 6, 7, 8, 9)) self.log('Delay: ', pause, ' seconds') time.sleep(pause) return '' + cat + title + subhead + auth + lede + caption + '
' + body + '
'