mirror of
https://github.com/thewesker/Video-Archive-Discord-Bot.git
synced 2025-12-20 04:11:05 -05:00
Initial commit
This commit is contained in:
26
downloader.py
Normal file
26
downloader.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import youtube_dl
|
||||
|
||||
def download(videoUrl):
|
||||
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s.mp4'})
|
||||
|
||||
ydl_opts = {}
|
||||
|
||||
with ydl:
|
||||
result = ydl.extract_info(
|
||||
videoUrl,
|
||||
download=True
|
||||
)
|
||||
|
||||
if 'entries' in result:
|
||||
# Can be a playlist or a list of videos
|
||||
video = result['entries'][0]
|
||||
return "Error: More than 1 result found"
|
||||
else:
|
||||
# Just a video
|
||||
video = result
|
||||
|
||||
print(video)
|
||||
video_url = video['title']
|
||||
videoId = video['id']
|
||||
|
||||
return videoId + ".mp4"
|
||||
Reference in New Issue
Block a user