Mark RSS Bridge feeds
This commit is contained in:
parent
1844b5b055
commit
524c9e5148
|
@ -41,6 +41,7 @@ with open(sys.argv[1]) as file, open(sys.argv[2], 'w+') as out:
|
||||||
print(text)
|
print(text)
|
||||||
out.write(text)
|
out.write(text)
|
||||||
continue
|
continue
|
||||||
|
rss_bridge = urlparse(feedurl).hostname.startswith('rss.')
|
||||||
try:
|
try:
|
||||||
with urlopen(Request(feedurl, headers={'User-Agent': "stop being so fucking obsessed that i'm using urllib ffs"}), timeout=60) as resp:
|
with urlopen(Request(feedurl, headers={'User-Agent': "stop being so fucking obsessed that i'm using urllib ffs"}), timeout=60) as resp:
|
||||||
if resp.status != 200:
|
if resp.status != 200:
|
||||||
|
@ -68,22 +69,26 @@ with open(sys.argv[1]) as file, open(sys.argv[2], 'w+') as out:
|
||||||
url = input().strip() or url
|
url = input().strip() or url
|
||||||
else:
|
else:
|
||||||
url = url.text or url.attrib['href']
|
url = url.text or url.attrib['href']
|
||||||
text = f'<li><b><a href="{html.escape(urljoin(feedurl, url))}">{html.escape(find_ignore_ns(channel, "title").text)}</a> (<a href="{html.escape(feedurl)}">feed</a>)'
|
text = f'<li><b><a href="{html.escape(urljoin(feedurl, url))}">{html.escape(find_ignore_ns(channel, "title").text)}</a> (<a href="{html.escape(feedurl)}">'
|
||||||
desc = find_ignore_ns(channel, 'description')
|
if rss_bridge:
|
||||||
if desc is not None and desc.text:
|
text += 'auto-generated '
|
||||||
if desc := desc.text.strip():
|
text += 'feed</a>)'
|
||||||
text += f':</b> {html.escape(desc)}'
|
if not rss_bridge:
|
||||||
else:
|
desc = find_ignore_ns(channel, 'description')
|
||||||
text += '</b>'
|
|
||||||
else:
|
|
||||||
desc = find_ignore_ns(channel, 'subtitle')
|
|
||||||
if desc is not None and desc.text:
|
if desc is not None and desc.text:
|
||||||
if desc := desc.text.strip():
|
if desc := desc.text.strip():
|
||||||
text += f':</b> {html.escape(desc)}'
|
text += f':</b> {html.escape(desc)}'
|
||||||
else:
|
else:
|
||||||
text += '</b>'
|
text += '</b>'
|
||||||
else:
|
else:
|
||||||
text += '</b>'
|
desc = find_ignore_ns(channel, 'subtitle')
|
||||||
|
if desc is not None and desc.text:
|
||||||
|
if desc := desc.text.strip():
|
||||||
|
text += f':</b> {html.escape(desc)}'
|
||||||
|
else:
|
||||||
|
text += '</b>'
|
||||||
|
else:
|
||||||
|
text += '</b>'
|
||||||
print(text, '</li>', sep='')
|
print(text, '</li>', sep='')
|
||||||
out.write(text)
|
out.write(text)
|
||||||
out.write('</li>\n')
|
out.write('</li>\n')
|
||||||
|
|
Loading…
Reference in New Issue