Skip to content

Commit

Permalink
fix: chokerman's suggestions & fix sub var parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
medanisjbara committed Jul 27, 2024
1 parent 7c7ecd7 commit 5b40688
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -330,7 +330,7 @@ Example using my custom rofi configuration (to customize how your rofi image pre

</details>

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/).

<details>
<summary>Showcase</summary>
Expand Down
33 changes: 11 additions & 22 deletions lobster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 5b40688

Please sign in to comment.