Update TLS

missing book details
This commit is contained in:
unkn0w7n 2024-09-08 21:26:05 +05:30
parent cf5c4a7d15
commit 57a9682a71
2 changed files with 15 additions and 14 deletions

View File

@ -163,7 +163,7 @@ class SCMP(BasicNewsRecipe):
load_article_from_json(script[0].text, b_root) load_article_from_json(script[0].text, b_root)
except Exception: except Exception:
return raw_html return raw_html
head = root.xpath('//h2') + root.xpath('//h3') head = b_root.xpath('//h2') + b_root.xpath('//h3')
for h2 in head: for h2 in head:
h2.tag = 'h4' h2.tag = 'h4'
raw = etree.tostring(b_root, encoding='unicode') raw = etree.tostring(b_root, encoding='unicode')

View File

@ -118,18 +118,6 @@ class tls(BasicNewsRecipe):
else: else:
prim = title = desc = label = auth = lede = '' prim = title = desc = label = auth = lede = ''
bks = ''
if 'bookdetails' in data and data['bookdetails']:
bks += '<br>'
for a in data['bookdetails']:
for x, y in a.items():
if isinstance(y, str):
if x == 'imageurl':
bks += '<img src="{}">'.format(y)
elif y:
bks += '<div class="det">' + y + '</div>\n'
bks += '<br>'
if 'article_data_leadimage' in data: if 'article_data_leadimage' in data:
i = data['article_data_leadimage'] i = data['article_data_leadimage']
if 'full_image' in i and i['full_image']: if 'full_image' in i and i['full_image']:
@ -138,7 +126,20 @@ class tls(BasicNewsRecipe):
+ i['imagecredit'] + '</i>' + i['imagecredit'] + '</i>'
) )
cont = self.index_to_soup('https://www.the-tls.co.uk/wp-json/tls/v2/single-article/' + data['ID'], raw=True) cont = self.index_to_soup('https://www.the-tls.co.uk/wp-json/tls/v2/single-article/' + data['ID'], raw=True)
body = json.loads(cont)['content'] c_data = json.loads(cont)
body = c_data['content']
bks = ''
if 'bookdetails' in c_data and c_data['bookdetails']:
bks += '<br>'
for a in c_data['bookdetails']:
for x, y in a.items():
if isinstance(y, str):
if x == 'imageurl':
bks += '<img src="{}">'.format(y)
elif y:
bks += '<div class="det">' + y + '</div>\n'
bks += '<br>'
html = '<html><body><div>' \ html = '<html><body><div>' \
+ label + title + desc + auth + lede + bks + body + \ + label + title + desc + auth + lede + bks + body + \