using curl now
This commit is contained in:
parent
e51a12a965
commit
2edaba449d
10
dl
10
dl
@ -2,6 +2,16 @@
|
||||
|
||||
set DIR (cd (dirname (status -f)); and pwd)
|
||||
|
||||
if ! type -q curl
|
||||
echo "curl is required to run this script"
|
||||
exit
|
||||
end
|
||||
|
||||
if ! type -q ffmpeg
|
||||
echo "ffmpeg is required to run this script"
|
||||
exit
|
||||
end
|
||||
|
||||
if ! test -d "$DIR/venv"
|
||||
/bin/env python3 -m venv "$DIR/venv"
|
||||
. "$DIR/venv/bin/activate.fish"
|
||||
|
6
dl.py
6
dl.py
@ -28,6 +28,7 @@ def parse_args():
|
||||
def main():
|
||||
args = parse_args()
|
||||
|
||||
try:
|
||||
if not args.no_auth and args.auth_token and args.session_id and args.session_ci:
|
||||
set_token(args.auth_token, args.session_id, args.session_ci)
|
||||
elif not args.no_auth:
|
||||
@ -39,7 +40,10 @@ def main():
|
||||
if index < args.start_at - 1:
|
||||
continue
|
||||
|
||||
download_clip(clip_id, f'{args.out_dir}/{index+1: 04d}_{clip_id}.mp4')
|
||||
download_clip(
|
||||
clip_id, f'{args.out_dir}/{index+1: 04d}_{clip_id}.mp4')
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
14
lib.py
14
lib.py
@ -147,14 +147,14 @@ def download_media(media_id: str, outfile_path: str):
|
||||
url = f'https://itunes.video.uni-erlangen.de/get/file/' + \
|
||||
str(media_id) + '?download=1'
|
||||
|
||||
with requests.get(url, stream=True, cookies=_cookies()) as r:
|
||||
if (r.status_code != 200):
|
||||
return False
|
||||
cookie_args = []
|
||||
if len(_cookies()) > 0:
|
||||
for key, value in _cookies().items():
|
||||
cookie_args.append('--cookie')
|
||||
cookie_args.append(f'{key}={value}')
|
||||
|
||||
with open(outfile_path, 'wb') as f:
|
||||
shutil.copyfileobj(r.raw, f)
|
||||
|
||||
return True
|
||||
status = subprocess.call(['curl', '-o', outfile_path, url] + cookie_args)
|
||||
return status == 0
|
||||
|
||||
|
||||
def download_playlist(playlist_url: str, outfile_path: str):
|
||||
|
Loading…
x
Reference in New Issue
Block a user