Compare commits

...

4 Commits

Author SHA1 Message Date
yosh a6a6080df4 twitch-vodarchive slash filename workaround 2024-02-04 20:16:40 -05:00
yosh c2219d703e avalifetch: better 2024-02-04 20:16:30 -05:00
yosh 6cfe35d978 aria2sel: add 2024-02-04 20:14:44 -05:00
yosh 746c73323e resonite-photoexif: fix for non-resdb urls 2024-02-04 20:14:44 -05:00
4 changed files with 51 additions and 25 deletions

37
aria2sel Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
set -euf
# wrapper script over --select-file for downloading from aria2c torrents
# escape stuff for evaluating
escape() {
sed -e "s/^$/''/" -e "s/'/'\\\\''/g" <<-EOF
$1
EOF
}
errecho() { printf '%s\n' "$*" >&2; }
FILTER_CMD="" FILTER_STR="" DOWNLOAD=""
while getopts ":dFin:" OPT; do
case "$OPT" in
d) DOWNLOAD=1 ;;
F|i) FILTER_STR="${FILTER_STR} -$OPTARG" ;;
n)
FILTER_CMD="$FILTER_CMD | grep -E ${FILTER_STR} -e '$(escape "$OPTARG")'"
;;
*)
esac
done
shift $((OPTIND - 1))
[ -z "${1:-}" ] && errecho "error: torrent file needed" && exit 1
[ -z "$FILTER_CMD" ] && errecho "error: no filters! use -n" && exit 1
inds=$(eval "aria2c -S '$(escape "$1")' $FILTER_CMD | cut -d '|' -f 1 | tr -d ' ' | paste -s -d ','")
echo "$inds"
if [ -n "$DOWNLOAD" ]; then
aria2c --select-file="$inds" "$1"
fi

View File

@ -31,20 +31,12 @@ system_info() {
colres='\033[m'
process_colors() {
# colindex=1
# while IFS=" " read -r curcol; do
# colesc="$(tput setaf "$curcol")"
# c$colindex="$colesc"
# colindex="$(($colindex + 1))"
# done <<-EOF
# "$COLORS"
# EOF
c1="$(printf '%b\033[38;5;%sm' "$colres" "$1")"
c2="$(printf '%b\033[38;5;%sm' "$colres" "$2")"
c3="$(printf '%b\033[38;5;%sm' "$colres" "$3")"
c4="$(printf '%b\033[38;5;%sm' "$colres" "$4")"
c5="$(printf '%b\033[38;5;%sm' "$colres" "$5")"
c6="$(printf '%b\033[38;5;%sm' "$colres" "$6")"
colindex=1
for c; do
colesc="$(printf '%b\033[38;5;%sm' "$colres" "$c")"
eval "c$colindex="'$colesc'
colindex=$((colindex + 1))
done
}
process_ascii() {
@ -72,16 +64,15 @@ res() { printf '\033[0m'; }
iprint() { printf "%b%s\n" "\033[0m\033[${info_padding}C" "$1"; }
print_all() {
tput rmam # disable line wrapping
printf '%s' '[?7l' # disable line wrapping
printf '%s\n' "$final_ascii"
printf '\0337 \033[?25l' # save cursor pos & hide it
printf "\033[%sF" "$linecount" #
system_info
tput smam # enable line wrapping
printf '%s' '[?7h' # enable line wrapping
printf '\0338\n\033[?25h' # restore cursor pos & unhide it
}
set -f -- $COLORS && set +f
process_colors "$@"
process_colors $COLORS
process_ascii
print_all

View File

@ -26,14 +26,12 @@ for resrec; do
# asset uri stuff
asseturi="$(jq -r '.assetUri | sub("resdb:///(?<x>[^.]+).*";"https://assets.resonite.com/\(.x)")' < "$tmp_recuri")"
tmp_json="$(mktemp)"
# TODO: suck it up and make my own fucking bson->json thing so I can make this actually good
# for now this works. ew.
curl -s "$asseturi" | tail -c +10 | brotli -d | bson2 print | tr -d '\n' > "$tmp_json"
curl -s "$asseturi" | tail -c +10 | brotli -d | bson2json > "$tmp_json"
# save the image itself
imguri="$(jq -r '.Object.Children[0].Components.Data.[] |
select(.Type=="FrooxEngine.StaticTexture2D").Data.URL.Data |
sub("@resdb:///(?<x>[^.]+).*";"https://assets.resonite.com/\(.x)")' \
sub("@(resdb:///(?<x>[^.]+))?.*";"https://assets.resonite.com/\(.x)")' \
< "$tmp_json"
)"
timestamp="$(date -u -d "$(jq -r '.tags[] | select(contains("timestamp:")) |
@ -52,7 +50,7 @@ for resrec; do
continue
else
echo "WARNING: filename exists in 1st pass, making unique name as safeguard"
outfile="${outfile%.webp}_$(uuidgen).webp"
outfile="${outfile%.webp}_$(uuidgen).webp"
fi
fi
@ -64,7 +62,7 @@ for resrec; do
tmp_json2="$(mktemp)"
jq '.Object.Children[0].Components.Data.[] | select(.Type=="FrooxEngine.PhotoMetadata")' "$tmp_json" > "$tmp_json2"
meta_time="$(date -u -d "@$(jq -r '.Data.TimeTaken.Data | sub("{\\$date: (?<x>[0-9]+)[0-9][0-9][0-9]}"; "\(.x)")' < "$tmp_json2")" +'%Y:%m:%d %H:%M:%S')"
meta_time="$(date -u -d "@$(jq -r '.Data.TimeTaken.Data/1000' < "$tmp_json2")" +'%Y:%m:%d %H:%M:%S')"
meta_host="$(jq -r '.Data.LocationHost._userId.Data' < "$tmp_json2")"
meta_place="$(jq -r '.Data.LocationName.Data | gsub("<[^<]+>";"")' < "$tmp_json2")"
meta_photographer="$(jq -r '.Data.TakenBy._userId.Data' < "$tmp_json2")"

View File

@ -12,7 +12,7 @@ done
shift $((OPTIND - 1))
for url; do
filename="$(yt-dlp -O '%(upload_date>%Y-%m-%d)s %(title)s.%(ext)s' "$url")"
filename="$(yt-dlp -O '%(upload_date>%Y-%m-%d)s %(title)s.%(ext)s' "$url" | sed 's/\//_/g')"
if [ -z "${novod:-}" ]; then
yt-dlp ${quality:+-f "$quality"} -o "$filename" "$url"
fi