星期一, 4月 01, 2019

[node.js] 偷youtube影音首選 youtube-dl

需要去同步 youtube的資料到server存一份,

有在幹資料的人都會推的開源:youtube-dl
優點是去爬網頁的資料,不需使用 api key也可以使用,
也有支援oauth的功魴。

測試指令


-F 列出所有影片格式


youtube-dl https://www.youtube.com/watch?v=QKm-SOOMC4c -F


-f <格式字串|itag id > -g 列出指定的影片格式 (同事測試六小時會過期)

youtube-dl https://www.youtube.com/watch?v=QKm-SOOMC4c -f best,bestvideo ,
bestaudio -g


可以取得指定的播放網址 

影音混合的格式
22 mp4 1280x720 hd720 1853k , avc1.64001F, mp4a.40.2@192k (44100Hz) (best)




缺音源
266 mp4 3840x2000 2160s 21499k , avc1.640033, 30fps, video only, 416.39MiB

https://r2---sn-n58xjvh-u2xe.googlevideo.com/videoplayback?signature=8AA8CBDA0024A8C5E5FB022CFA76F182E81BF354.4C9DC2F6E368633AD5685980F31E5B29B35A44E4&key=yt6&ipbits=0&itag=266&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C264%2C266%2C271%2C278%2C313&c=WEB&pl=21&expire=1554132041&dur=260.059&gir=yes&sparams=aitags%2Cclen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cxtags%2Cexpire&ip=61.63.156.155&lmt=1552432202113912&fvip=3&initcwndbps=578750&id=o-ABBy62Qm8_j7kRurZ60b_pKKJn3y4EZO01mGfaWtCOFA&ei=6dehXLGdEcreqAG68JTQAw&mn=sn-n58xjvh-u2xe%2Csn-u4o-u2xy&txp=5530232&mm=31%2C29&mime=video%2Fmp4&requiressl=yes&clen=436613137&source=youtube&keepalive=yes&xtags=vproj%3Dmesh&mv=m&mt=1554110377&ms=au%2Crdu&ratebypass=yes



音訊

https://r2---sn-n58xjvh-u2xe.googlevideo.com/videoplayback?key=yt6&txp=5511222&mime=audio%2Fwebm&c=WEB&mn=sn-n58xjvh-u2xe%2Csn-u4o-u2xy&mm=31%2C29&ip=61.63.156.155&pl=21&itag=251&gir=yes&signature=9A50E784043546435F3B3625985157B6475F3E7E.CC62E740825F34B40CC00ABA1B778D372A2D43F2&id=o-APaLtk67hTCCfREk5CFTQJGEGRXRjMtLadjctgdjpFqr&mv=m&keepalive=yes&ms=au%2Crdu&lmt=1547892083268195&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cpl%2Crequiressl%2Csource%2Cexpire&ipbits=0&requiressl=yes&initcwndbps=600000&source=youtube&ei=UtqhXPCNFNXU4QL4tIbQCg&expire=1554132658&clen=3956896&mt=1554110979&dur=260.081&fvip=3&ratebypass=yes



參考

http://truelogic.org/wordpress/2017/06/20/7-youtube-data-api-paging-maxresults/

沒有留言:

張貼留言

留個話吧:)