update rss_proxy.py
* fixed broken guid rewrite
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import html
|
||||
import urllib.parse
|
||||
import os
|
||||
import requests
|
||||
@@ -22,8 +23,8 @@ def normalize_text(text):
|
||||
|
||||
|
||||
def extract_viewtopic_link(description):
|
||||
"""Ищет любую ссылку в description"""
|
||||
match = re.search(r'href="(https?://[^"]+)"', description)
|
||||
decoded_description = html.unescape(description)
|
||||
match = re.search(r'href="(https?://[^"]+)"', decoded_description)
|
||||
return match.group(1) if match else None
|
||||
|
||||
|
||||
@@ -50,13 +51,13 @@ def init_proxy(app):
|
||||
try:
|
||||
proxies = {"http": PROXY_URL, "https": PROXY_URL} if PROXY_URL else None
|
||||
r = requests.get(url, timeout=10, proxies=proxies)
|
||||
r.encoding = r.apparent_encoding
|
||||
|
||||
xml_data = r.text
|
||||
xml_data = xml_data.replace("&", "&")
|
||||
_encoding = xml_data.split('encoding="')[1].split('"')[0]
|
||||
if '<?xml version="1.0" encoding="' in xml_data:
|
||||
xml_data = xml_data.replace(
|
||||
'<?xml version="1.0" encoding="' + xml_data.split('encoding="')[1].split('"')[0] + '"?>',
|
||||
f'<?xml version="1.0" encoding="{_encoding}"?>',
|
||||
'<?xml version="1.0" encoding="UTF-8"?>'
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user