Download youtube video’s to watch with Plex with automatically translated subtitles

There is so much entertaining, funny and educative material available on Youtube, most of which is in english. Some of the video’s have Dutch subtitles.

This is my wishlist for these video’s:

  1. Preference for Dutch and English subtitles, if youtube has them available (automatically translated or not)
  2. Best quality available – this is the default setting for youtube-dl according to the documentation – but specifically for merging into mp4
  3. Converted to MP4, so I can watch it both in the web browser, as well as on the RasPlex, without transcoding (my NAS is not fast enough)

This is my method to watch these video’s with Plex:

  • Log in to my private google account and give the video a like
  • On the NAS make two directories youtube-likes-workdir and youtube-likes
  • In the youtube-likes-workdir directory, run:
    youtube-dl --username  \
     --cookies _youtube-dl-cookies.txt \
     --keep-video \
     --ignore-errors \
     --write-auto-sub \
     --sub-lang 'nl,en' \
     --prefer-ffmpeg \
     --format 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4' \
     --merge-output-format mp4 \
    cd ../youtube-likes
    IFS=$(echo -en "\n\b") ; for i in $(ls ../youtube-likes-workdir/*vtt) ; do ln -f "$i" . ; done
    IFS=$(echo -en "\n\b") ; for i in $(ls ../youtube-likes-workdir/*mp4 | egrep -v 'f[0-9]*.mp4') ; do ln -f "$i" . ; done

The separation between youtube-likes-workdir and youtube-likes is required to prevent Plex to list video’s twice, which it will do since both separate audio/video and merged video files exist in the workdir, and I want to keep the original files to prevent excessive downloads. As a workaround, Plex is directed to the youtube-likes folder, where only the merged videos and subtitles are linked from the working directory. The last two commands above create these links. Hardlinks in stead of symlinks are required in order for Plex to play the video.

This method works with the latest Plex versions that supports vtt subtitles, as well as youtube 2FA google account authentication.



Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s