From 5b406885a5846b3e78ad9b93355d895fe90afd02 Mon Sep 17 00:00:00 2001 From: jbara Date: Sat, 27 Jul 2024 18:10:28 +0100 Subject: [PATCH] fix: chokerman's suggestions & fix sub var parsing --- README.md | 6 +++--- lobster.sh | 33 +++++++++++---------------------- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index d5b1777..ec74805 100644 --- a/README.md +++ b/README.md @@ -301,11 +301,11 @@ lobster -d "../rick_and_morty/" rick and morty ### `--discord` / `--discord-presence` / `--rpc` / `--presence` argument -By passing this argument you make use of discord rich presence so you can let your friends know what you are enjoying. +By passing this argument you make use of discord rich presence so you can let your friends know what you are watching. This argument requires BSD netcat to be installed. -On Arch Linux you can install it using ether pacman or your aur helper of choice with: +On Arch Linux you can install it using either pacman or your aur helper of choice with: ```sh paru -S openbsd-netcat @@ -330,7 +330,7 @@ Example using my custom rofi configuration (to customize how your rofi image pre -For `fzf` you will need to ether install [chafa](https://github.com/hpjansson/chafa/) or [ueberzugpp](https://github.com/jstkdng/ueberzugpp/). +For `fzf` you will need to either install [chafa](https://github.com/hpjansson/chafa/) or [ueberzugpp](https://github.com/jstkdng/ueberzugpp/).
Showcase diff --git a/lobster.sh b/lobster.sh index 6735b52..7f8d4f5 100755 --- a/lobster.sh +++ b/lobster.sh @@ -575,32 +575,21 @@ EOF fi exit 0 } - make_sub_ops() { - num_subs="$(echo "$subs_links" | sed 's/\([^\]\):/\1\n/g' | wc -l)" - sub_input="$( - printf "%s" "$subs_links" | - sed 's/^/-i /g; s/\([^\]\):/\1 -i /g; s/\\:/:/g' - )" - sub_ops="$sub_input -map 0:v -map 0:a" - i=0 - while [ "$i" -lt "$num_subs" ]; do - sub_ops="$sub_ops -map $((i + 1))" - i=$((i + 1)) - done - sub_ops="$sub_ops -c:v copy -c:a copy -c:s srt" - i=0 - while [ "$i" -lt "$num_subs" ]; do - # FIXME - sub_ops="$sub_ops -metadata:s:s:$i language=unknown" - i=$((i + 1)) - done - echo "$sub_ops" - } # download_video [url] [title] [download_dir] [thumbnail_file] download_video() { title="$(printf "%s" "$2" | tr -d ':/')" dir="${3}/${title}" - sub_ops="$(make_sub_ops)" + num_subs="$(echo "$subs_links" | sed 's/:\([^\/]\)/\n\\1/g' | wc -l)" + ffmpeg_subs_links=$(printf "%s" "$subs_links" | sed -E 's/https(\\)?:/-i https:/g; s/:\([^\/]\)/ \\1/g') + sub_ops="$ffmpeg_subs_links -map 0:v -map 0:a" + i=0 + while [ "$i" -lt "$num_subs" ]; do + ffmpeg_maps="$ffmpeg_maps -map $((i + 1))" + # FIXME: use filename for language + ffmpeg_meta="$ffmpeg_meta -metadata:s:s:$i language=unknown" + i=$((i + 1)) + done + sub_ops="$sub_ops $ffmpeg_maps -c:v copy -c:a copy -c:s srt $ffmpeg_meta" eval "ffmpeg -loglevel error -stats -i '$1' $sub_ops -c copy '$dir.mkv'" } choose_from_trending_or_recent() {