Using get_video on YouTube to download a video

前端 未结 3 919
醉酒成梦
醉酒成梦 2021-02-09 15:26

I am trying to get the video URL of any YouTube video like this:

Open

http://youtube.com/get_video_info?video_id=VIDEOID

then take the

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-09 15:59

    Great! I needed a way to grab a whole playlist of videos.

    In Linux, this is what I used:

    y=http://www.youtube.com; f="http://gdata.youtube.com/feeds/api/playlists/PLeHqhPDNAZY_3377_DpzRSMh9MA9UbIEN?start-index=26"; for i in $(curl -s $f |grep -o "url='$y/watch?v=[^']'");do d=$(echo $i|sed "s|url\='$y/watch?v=(.)&.*'|\1|"); youtube-dl --restrict-filenames "$y/watch?v=$d"; done

    You have to find the playlist ID from a common Youtube URL like: https://www.youtube.com/playlist?list=PLeHqhPDNAZY_3377_DpzRSMh9MA9UbIEN

    Also, this technique uses gdata API, limiting 25 records per page.
    Hence the ?start-index=26 parameter (to get page 2 in my example)

    This could use some cleaning, and extra logic to iterate thru all sets of 25, too.

    Credits:

    https://stackoverflow.com/a/8761493/1069375

    http://www.commandlinefu.com/commands/view/3154/download-youtube-playlist (which itself didn't quite work)

提交回复
热议问题