mirror of
https://github.com/cquest/tootbot.git
synced 2025-02-24 19:18:38 +00:00
Compare commits
3 Commits
dfde209171
...
d022f43aa3
Author | SHA1 | Date | |
---|---|---|---|
|
d022f43aa3 | ||
|
21ef9375f3 | ||
|
5b562ff379 |
@ -1,5 +1,5 @@
|
||||
feedparser>=6.0.10
|
||||
Mastodon.py==1.8.0
|
||||
requests==2.28.1
|
||||
Mastodon.py==1.8.1
|
||||
requests==2.31.0
|
||||
twint @ git+https://github.com/woluxwolu/twint.git
|
||||
yt-dlp>=2023.3.4
|
||||
|
13
tootbot.py
13
tootbot.py
@ -22,16 +22,17 @@ def unredir(redir):
|
||||
redir_count = redir_count + 1
|
||||
if redir_count > 10:
|
||||
break
|
||||
if 'http' not in r.headers.get('Location'):
|
||||
redir = re.sub(r'(https?://.*)/.*', r'\1', redir) + \
|
||||
r.headers.get('Location')
|
||||
location = r.headers.get('Location')
|
||||
if 'go.france24.com' in redir:
|
||||
# decoding hack in case "location" header is UTF-8 encoded (should not !)
|
||||
location = location.encode("latin1").decode("utf-8")
|
||||
if 'http' not in location:
|
||||
redir = re.sub(r'(https?://[^/]*).*$', r'\1', redir) + location
|
||||
else:
|
||||
redir = r.headers.get('Location')
|
||||
# print('redir', redir)
|
||||
redir = location
|
||||
if '//ow.ly/' in redir or '//bit.ly/' in redir:
|
||||
redir = redir.replace('https://ow.ly/', 'http://ow.ly/') # only http
|
||||
redir = requests.get(redir, allow_redirects=False).headers.get('Location')
|
||||
# print('redir+', redir)
|
||||
try:
|
||||
r = requests.get(redir, allow_redirects=False, timeout=5)
|
||||
except:
|
||||
|
Loading…
x
Reference in New Issue
Block a user