Compare commits

...

2 Commits

Author SHA1 Message Date
cquest
887474a1f3 do not download very large video files ! 2023-02-09 16:51:53 +01:00
cquest
fba2318929 avoid redirect inifinite loops 2023-02-09 16:51:31 +01:00

View File

@ -17,7 +17,11 @@ import requests
def unredir(redir):
r = requests.get(redir, allow_redirects=False)
redir_count = 0
while r.status_code in {301, 302}:
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')
@ -286,7 +290,7 @@ else:
c = c.replace(l, '')
video = redir
print('video:', video)
subprocess.run('rm -f out.mp4; yt-dlp -N 8 -o out.mp4 --recode-video mp4 --no-playlist %s' %
subprocess.run('rm -f out.mp4; yt-dlp -N 8 -o out.mp4 --recode-video mp4 --no-playlist %s --max-filesize 100M' %
(video,), shell=True, capture_output=False)
print("received")
try: