This commit is contained in:
Kovid Goyal 2023-07-17 06:58:13 +05:30
parent 43e6b36e15
commit e6d838ad45
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 23 additions and 17 deletions

View File

@ -2,7 +2,6 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
from calibre import browser
from html5_parser import parse
import json
import re
class Bloomberg(BasicNewsRecipe):
@ -86,7 +85,7 @@ class Bloomberg(BasicNewsRecipe):
else:
data = json.loads(m2[0].text)
data = data['props']['pageProps']['story']
title = '<h1>' + data['headline'] + '</h1>'
cat = subhead = lede = auth = caption = ''
@ -110,7 +109,7 @@ class Bloomberg(BasicNewsRecipe):
if 'ledeImageUrl' in data:
if data['ledeImageUrl'] is not None:
lede = '<p><img src="{}">'.format(data['ledeImageUrl'])
if 'ledeDescription' in data:
if data['ledeDescription'] is not None:
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
@ -121,7 +120,7 @@ class Bloomberg(BasicNewsRecipe):
if data['lede']['alt'] is not None:
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
if m:
if m:
body = data['body']
else:
body = ''
@ -133,7 +132,7 @@ class Bloomberg(BasicNewsRecipe):
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
if objects['type'] == 'paragraph' or 'heading':
body += '<p>'
if not 'content' in objects:
if 'content' not in objects:
continue
for content in objects['content']:
if 'value' in content:

View File

@ -3,7 +3,6 @@ from calibre import browser
from html5_parser import parse
from calibre.ptempfile import PersistentTemporaryFile
import json
import re
class Bloomberg(BasicNewsRecipe):
title = u'Bloomberg'
@ -14,7 +13,7 @@ class Bloomberg(BasicNewsRecipe):
remove_attributes = ['style', 'height', 'width']
ignore_duplicate_articles = {'url', 'title'}
resolve_internal_links = True
delay = 5 # seconds
extra_css = '''
@ -116,7 +115,7 @@ class Bloomberg(BasicNewsRecipe):
if data['lede']['alt'] is not None:
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
if m:
if m:
body = data['body']
else:
body = ''
@ -128,7 +127,7 @@ class Bloomberg(BasicNewsRecipe):
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
if objects['type'] == 'paragraph' or 'heading': # lists are missed :(
body += '<p>'
if not 'content' in objects:
if 'content' not in objects:
continue
for content in objects['content']:
if 'value' in content:

View File

@ -1251,11 +1251,15 @@ class TagsModel(QAbstractItemModel): # {{{
filter_by = self.filter_categories_by
if prefs['use_primary_find_in_search']:
final_equals = lambda x, y: primary_strcmp(x, y) == 0
final_contains = primary_contains
def final_equals(x, y):
return primary_strcmp(x, y) == 0
def final_contains(x, y):
return primary_contains(x, y)
else:
final_equals = lambda x, y: strcmp(x, y) == 0
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
def final_equals(x, y):
return strcmp(x, y) == 0
def final_contains(filt, txt):
return contains(filt, icu_lower(txt))
for category in data.keys():
if use_exact_match:
@ -1853,11 +1857,15 @@ class TagsModel(QAbstractItemModel): # {{{
start_path = []
if prefs['use_primary_find_in_search']:
final_equals = lambda x, y: primary_strcmp(x, y) == 0
final_contains = primary_contains
def final_equals(x, y):
return primary_strcmp(x, y) == 0
def final_contains(x, y):
return primary_contains(x, y)
else:
final_equals = lambda x, y: strcmp(x, y) == 0
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
def final_equals(x, y):
return strcmp(x, y) == 0
def final_contains(filt, txt):
return contains(filt, icu_lower(txt))
def process_tag(depth, tag_index, tag_item, start_path):
path = self.path_for_index(tag_index)