import subprocess
import tempfile
import os
import youtube_dl
import time
class MyLogger(object):
def debug(self, msg):
pass
def warning(self, msg):
pass
def error(self, msg):
print(msg)
def my_hook(d):
if d['status'] == 'finished':
print('Done downloading, now converting ...')
ydl_opts = {
'outtmpl': './temp/ZCL5.mp4',
'logger': MyLogger(),
'progress_hooks': [my_hook],
'format': 'worst'
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
starttime = time.time()
ydl.download(['https://www.youtube.com/watch?v=sHAkDTlv8fA'])
completeTime = time.time()
print(completeTime - starttime)
print("printing file in temp dir")
basepath = tempfile.gettempdir()
for entry in os.listdir(basepath):
if os.path.isfile(os.path.join(basepath, entry)):
print("printing file in temp dir")
print(entry)
print("out of loop")
For more options check https://github.com/ytdl-org/youtube-dl/blob/3e4cedf9e8cd3157df2457df7274d0c842421945/youtube_dl/options.py
field to check is "dest"
for example, the output field was
'-o', '--output',
dest='outtmpl', metavar='TEMPLATE',
Comments
Post a Comment