This commit is contained in:
Jaidyn Ann 2021-01-14 20:08:28 -06:00
commit 56528f9655
2 changed files with 112 additions and 0 deletions

36
README.txt Normal file
View File

@ -0,0 +1,36 @@
===============================================================================
YUJA-DL
===============================================================================
Download videos and subtitles from *.yuja.com with this script.
Useful if your web-browser doesn't support streaming, or your PC is too weak
to run one in the first place. Also useful for archival.
I have a blog post on this over at https://xwx.moe/lib/ripping_hls_from_yuja.md
----------------------------------------
PRE-REQUISITES
----------------------------------------
You'll need:
* curl
* jq
* ffmpeg
* a shell
----------------------------------------
USAGE
----------------------------------------
$ yuja-dl $VIDEO_URL $OUTPUT_NAME
$VIDEO_URL should be in the format of "https://*.yuja.com/V/Video=?v=*".
$OUTPUT_NAME will be the basename of the mp4 and srt files.
----------------------------------------
BORING STUFF
----------------------------------------
License is CC-0
Author is Jaidyn Ann <jadedctrl@teknik.io>
https://git.feneas.org/detruota/yuja-dl.git
https://github.com/JadedCtrl/yuja-dl.git

76
yuja-dl Executable file
View File

@ -0,0 +1,76 @@
#!/bin/sh
# --------------------------------------
# name: yuja-dl
# main: Jaidyn Ann <jadedctrl@teknik.io>
# lisc: CC0
# date: 2021
# --------------------------------------
function download_url {
local url="$1"; local output="$2"
local id="$(echo "$url" | video_id)"
local sub="$(echo "$url" | subdomain)"
local hls_key="$(get_metadata "$sub" "$id" | hls_file_key)"
local captions_key="$(get_metadata "$sub" "$id" | caption_file_key)"
ffmpeg -i "$(m3u8_url "$hls_key")" "${output}.mp4"
curl -o "${output}.srt" "$(caption_url "$sub" "$captions_key")"
}
function m3u8_url {
local hls_key="$1"
local fragment="${hls_key}/720p/${hls_key}.m3u8"
echo \
"https://my.yuja.com/P/Data/VideoUrl/level${fragment}.m3u8?dist=yuja-edits&key=${fragment}"
}
function caption_url {
local subdomain="$1"
local caption_key="$2"
echo \
"https://${subdomain}.yuja.com/P/DataPage/CaptionFile/${caption_key}"
}
function get_metadata {
local sub="$1"; local id="$2"
curl -s \
"https://${sub}.yuja.com/P/Data/GetVideoListNodeInfo?videoPID=${id}"
}
function hls_file_key {
jq -r .video \
| jq -r .videoHLSFileKey.value
}
function caption_file_key {
jq -r .video \
| jq -r .captionFileKey.value
}
function video_id {
sed 's%.*v=%%' \
| sed 's%&.*%%'
}
function subdomain {
awk -F '.' '{print $1}' \
| sed 's%.*//%%'
}
# INVOCATION
# --------------------------------------
function usage {
echo "usage: yuja-dl URL OUTPUT"
echo
echo " URL is a *.yuja.com URL with a video ID argument"
echo " OUTPUT is the basename for the mp4 and srt files"
exit 2
}
URL="$1"
OUTPUT="$2"
if test -z "$URL" -o -z "$OUTPUT"; then usage; fi
download_url "$URL" "$OUTPUT"