mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
2f962ad21c
commit
911e15e63b
@ -103,7 +103,7 @@ class LiveMint(BasicNewsRecipe):
|
|||||||
dict(name=['meta', 'link', 'svg', 'button', 'iframe']),
|
dict(name=['meta', 'link', 'svg', 'button', 'iframe']),
|
||||||
classes(
|
classes(
|
||||||
'trendingSimilarHeight moreNews mobAppDownload label msgError msgOk taboolaHeight gadgetSlider'
|
'trendingSimilarHeight moreNews mobAppDownload label msgError msgOk taboolaHeight gadgetSlider'
|
||||||
' socialHolder imgbig disclamerText disqus-comment-count openinApp2 lastAdSlot bs_logo'
|
' socialHolder imgbig disclamerText disqus-comment-count openinApp2 lastAdSlot bs_logo manualbacklink'
|
||||||
' datePublish sepStory premiumSlider moreStory Joinus moreAbout milestone benefitText'
|
' datePublish sepStory premiumSlider moreStory Joinus moreAbout milestone benefitText'
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -132,7 +132,9 @@ class LiveMint(BasicNewsRecipe):
|
|||||||
# remove empty p tags
|
# remove empty p tags
|
||||||
raw = re.sub(
|
raw = re.sub(
|
||||||
r'(<p>\s*)(<[^(\/|a|i|b|em|strong)])', '\g<2>', re.sub(
|
r'(<p>\s*)(<[^(\/|a|i|b|em|strong)])', '\g<2>', re.sub(
|
||||||
r'(<p>\s* \s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+> \s*<\/p>)', '', raw
|
r'(<p>\s* \s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+> \s*<\/p>)', '', re.sub(
|
||||||
|
r'(?=<h2>\s*Also\s*Read).*?(?<=</h2>)', '', raw
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if '<script>var wsjFlag=true;</script>' in raw:
|
if '<script>var wsjFlag=true;</script>' in raw:
|
||||||
|
@ -35,7 +35,8 @@ def parse_lead_image(media):
|
|||||||
yield '<p>'
|
yield '<p>'
|
||||||
if 'dsc' in media['image']:
|
if 'dsc' in media['image']:
|
||||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||||
if 'caption' in media and 'credit' in media:
|
if 'caption' in media and 'credit' in media:
|
||||||
@ -120,8 +121,7 @@ def parse_article(edg):
|
|||||||
for item in main['props']['body']:
|
for item in main['props']['body']:
|
||||||
if isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
if item.get('type', '') == 'inline':
|
if item.get('type', '') == 'inline':
|
||||||
for inl in parse_inline(item):
|
yield ''.join(parse_inline(item))
|
||||||
yield inl
|
|
||||||
elif isinstance(item, list):
|
elif isinstance(item, list):
|
||||||
for line in item:
|
for line in item:
|
||||||
yield ''.join(parse_body(line))
|
yield ''.join(parse_body(line))
|
||||||
|
@ -34,7 +34,8 @@ def parse_lead_image(media):
|
|||||||
yield '<p>'
|
yield '<p>'
|
||||||
if 'dsc' in media['image']:
|
if 'dsc' in media['image']:
|
||||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||||
if 'caption' in media and 'credit' in media:
|
if 'caption' in media and 'credit' in media:
|
||||||
@ -119,8 +120,7 @@ def parse_article(edg):
|
|||||||
for item in main['props']['body']:
|
for item in main['props']['body']:
|
||||||
if isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
if item.get('type', '') == 'inline':
|
if item.get('type', '') == 'inline':
|
||||||
for inl in parse_inline(item):
|
yield ''.join(parse_inline(item))
|
||||||
yield inl
|
|
||||||
elif isinstance(item, list):
|
elif isinstance(item, list):
|
||||||
for line in item:
|
for line in item:
|
||||||
yield ''.join(parse_body(line))
|
yield ''.join(parse_body(line))
|
||||||
|
@ -39,7 +39,8 @@ def parse_lead_image(media):
|
|||||||
yield '<p>'
|
yield '<p>'
|
||||||
if 'dsc' in media['image']:
|
if 'dsc' in media['image']:
|
||||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||||
if 'caption' in media and 'credit' in media:
|
if 'caption' in media and 'credit' in media:
|
||||||
@ -124,8 +125,7 @@ def parse_article(edg):
|
|||||||
for item in main['props']['body']:
|
for item in main['props']['body']:
|
||||||
if isinstance(item, dict):
|
if isinstance(item, dict):
|
||||||
if item.get('type', '') == 'inline':
|
if item.get('type', '') == 'inline':
|
||||||
for inl in parse_inline(item):
|
yield ''.join(parse_inline(item))
|
||||||
yield inl
|
|
||||||
elif isinstance(item, list):
|
elif isinstance(item, list):
|
||||||
for line in item:
|
for line in item:
|
||||||
yield ''.join(parse_body(line))
|
yield ''.join(parse_body(line))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user