aboutsummaryrefslogtreecommitdiff
path: root/src/stream_command.sh
blob: 32b1e6522473beb3abc8b66326bfb034a3208037 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
user_agent="Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0"

if [[ -n "${args['--download']}" ]]; then
	START=$(date +%s)

	yt-dlp \
		--all-subs \
		--cookies-from-browser firefox \
		--embed-subs \
		--external-downloader=aria2c \
		--external-downloader-args \
		'--min-split-size=1M --max-connection-per-server=16 --max-concurrent-downloads=16 --split=16' \
		-f 'best[height=1080]' \
		--remux mkv \
		--merge mkv \
		--verbose \
		--user-agent "${user_agent}" \
		"${args[uri]}"

	printf "\ntook %s seconds\n" $(($(date +%s || true) - START))

	return
fi

# mpv "$(yt-dlp \
# 	--cookies-from-browser firefox \
# 	--extractor-args crunchyrollbeta:hardsub=en-US \
# 	-f 'best[height=1080]' \
# 	-g \
# 	--verbose \
# 	"${1}")"

subtitles_command=(
	'yt-dlp'
	'--cookies-from-browser' 'firefox'
	'--no-download'
	'-o' '/tmp/skyla_subtitles'
	'--sub-lang' 'en-US'
	'--write-subs'
	'--user-agent' "${user_agent}"
	"${args[uri]}"
)

if [ -n "${args['--username']}" ]; then
	subtitles_command+=(-u "${args['--username']}")
	subtitles_command+=(-p "${args['--password']}")
fi

"${subtitles_command[@]}"

if [[ -n "${args['--fix']}" ]]; then
	sed -i 's/{an\d*}//g' /tmp/skyla_subtitles.*.ass
fi

media_command=(
	'yt-dlp'
	'--cookies-from-browser' 'firefox'
	'-f' 'best[height=1080]'
	'-g'
	'--user-agent' "${user_agent}"
	"${args[uri]}"
)

if [ -n "${args['--username']}" ]; then
	media_command+=(-u "${args['--username']}")
	media_command+=(-p "${args['--password']}")
fi

memento \
	--sub-file="/tmp/skyla_subtitles.en-US.ass" \
	"$("${media_command[@]}")"

rm /tmp/skyla_subtitles.*.ass