Last active
November 28, 2022 12:33
-
-
Save dardo82/c2660f2db16e2fc8f5d6159c735e98e0 to your computer and use it in GitHub Desktop.
Play last YouTube history video in MPV.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Play the last video watched on YouTube in MPV with subtitles. | |
L="${2-${${LANG%.*}%_*}}"; SIZE="${3-48}"; EXT="${4-vtt}"; FMT="${5-135+140}" # Set variables. | |
ID=$(yt-dlp -v --get-id --playlist-items ${1-1} \ | |
--cookies-from-browser chrome+gnomekeyring :ythistory) # Set the video's ID. | |
SUB=$(yt-dlp youtu.be/$ID --write-subs --sub-format vtt --sub-langs $L \ | |
--print '%(requested_subtitles)j' | jq -M -r '.[]|.url') # Set the subtitles' URL. | |
mpv --ytdl-format="$FMT" --sub-file="$SUB" --sub-font-size="$SIZE" "ytdl://$ID" # Play the video. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment