-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyFetch.py
More file actions
27 lines (22 loc) · 722 Bytes
/
PyFetch.py
File metadata and controls
27 lines (22 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import yt_dlp
import os
def run():
url = input("URL: ")
print("1- Video\n2- Audio")
c = input("Choice: ")
path = '/storage/emulated/0/Download/%(title)s.%(ext)s'
opts = {
'outtmpl': path,
'format': 'best[ext=mp4]/best' if c == '1' else 'bestaudio/best',
}
try:
with yt_dlp.YoutubeDL(opts) as ydl:
ydl.download([url])
print("\nSaved to: /storage/emulated/0/Download/")
except:
opts['outtmpl'] = '%(title)s.%(ext)s'
with yt_dlp.YoutubeDL(opts) as ydl:
info = ydl.extract_info(url, download=True)
print(f"\nSaved in app folder: {ydl.prepare_filename(info)}")
if __name__ == "__main__":
run()