aboutsummaryrefslogtreecommitdiffhomepage
path: root/TOOLS/youtube-dl_mpv.sh
blob: 6b15bd7a3881ba84c0051a44b0722366002ead80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
# Example of script for using mpv with youtube-dl
set -e

cookies_dir="$(mktemp -d /tmp/youtube-dl_mpv.XXXX)"
cookies_file="${cookies_dir}/cookies"
user_agent="$(youtube-dl --dump-user-agent)" # or set whatever you want

video_url="$(youtube-dl \
    --user-agent="$user_agent" \
    --cookies="$cookies_file" \
    --get-url \
    "$@")"

set -f
${MPV:-mpv} \
    --cookies \
    --cookies-file="$cookies_file" \
    --user-agent="$user_agent" \
    -- $video_url

rm -rf "$cookies_dir"