Youtube.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:leetcode 作者: WUJISHANXIA 项目源码 文件源码
def youtube_download(self,url,id):
        #download_command=['youtube-dl -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/bestvideo+bestaudio\
        #                  --merge-output-format mp4 -o /Users/wujishanxia/Downloads/test.mp4',url]
        command='youtube-dl'+' -f bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best'+' -o'+' '+str(id)+'.mp4'+' '+url
        #thread=threading.Thread(target=self.download,args=(command,id))
        #thread.setDaemon(True)
        #thread.start()
        download=subprocess.Popen(command,shell=True)
        #download = subprocess.Popen('echo "hello"',shell=True)
        download.wait()
        #with youtube_dl.YoutubeDL() as ydl:
        #    ydl.download(['http://www.bilibili.com/video/av2331280?from=search&seid=831467570734192523'])
        print 'download video successfully'
        gif_command='ffmpeg -ss 20 -t 20 -i'+' '+str(id)+'.mp4  -s 320x240 -f gif'+' '+str(id)+'.gif'
        gif=subprocess.Popen(gif_command,shell=True)
        gif.wait()
        print 'generate gif successfully'
        cp_command='cp'+' '+str(id)+'.gif'+' /home/www/public/media'
        cp = subprocess.Popen(cp_command, shell=True)
        cp.wait()
        print 'copy gif to media successfully'
        rm_command='rm'+' '+str(id)+'.mp4'
        rm = subprocess.Popen(rm_command,shell=True)
        rm.wait()
        print 'rm mp4 successfully'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号