Search code examples
youtubecronyoutube-apiyoutube-data-apiyoutube-dl

How to download youtube videos from a channel as soon as the video is uploaded using youtube-dl?


Here is my script to download a video if its video-id is known:

 youtube-dl -f 134 -ciw -o video.mp4 https://www.youtube.com/watch?v=xxxxxxxxxxx

Is there any way by which I can download the latest video from now on from a particular channel as soon as the video is uploaded using cronjob or some other method?


Solution

  • As far as I know there is no method that is implemented into youtube-dl directly to download the latest video.

    You can use the Youtube Data API to get the Channel's Upload Playlist-ID.

    https://developers.google.com/youtube/v3/docs/channels/list
    

    After that you can periodically poll the Videos that are on the Upload Playlist of that Channel.

    https://developers.google.com/youtube/v3/docs/playlistItems/list
    

    There is an SDK for Java for example, so you could write a Java Application to retrieve the latest Upload, and then launch the youtube-dl Process like this.

    Here is an example to retrieve your own Uploads using the Youtube API (just to get you started).