Merge pull request #480 from ilmich/fix-altadefinzione-redirection

altadefizione: fix url redirection
This commit is contained in:
Timmy89
2024-02-29 00:24:31 +01:00
committed by GitHub
+5 -2
View File
@@ -9,8 +9,11 @@ from platformcode import config, logger
def findhost(url): def findhost(url):
host = support.match(url, patron=r'<h2[^>]+><a href="([^"]+)').match.rstrip('/') host = support.match(url, patron=r'<h2[^>]+><a href="([^"]+)').match.rstrip('/')
permUrl = httptools.downloadpage(host, follow_redirects=False).headers permUrl = httptools.downloadpage(host, follow_redirects=False, only_headers=True).headers
return permUrl['location']
if 'location' in permUrl.keys(): # handle redirection
return permUrl['location']
return host
host = config.get_channel_url(findhost) host = config.get_channel_url(findhost)
headers = [['Referer', host]] headers = [['Referer', host]]