summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiao Pan <gky44px1999@gmail.com>2023-09-26 17:46:03 -0700
committerXiao Pan <gky44px1999@gmail.com>2023-09-26 17:46:03 -0700
commit5fad27c4da63f8f8599710c18d84861c2d21c98c (patch)
tree2638248cfdc2cd86c6399ea6b08731d4fa75c3e8
parentb411b4aba7caeaa78033a8309e461ce39fe87346 (diff)
make yt-dlp --trim-filenames global instead again, because I see more value of not worrying about this issue happen again in the future
-rw-r--r--home/xyz/.config/yt-dlp/config6
-rwxr-xr-xhome/xyz/.local/bin/mpvy5
2 files changed, 8 insertions, 3 deletions
diff --git a/home/xyz/.config/yt-dlp/config b/home/xyz/.config/yt-dlp/config
index 4ed6c4a7..76049422 100644
--- a/home/xyz/.config/yt-dlp/config
+++ b/home/xyz/.config/yt-dlp/config
@@ -9,3 +9,9 @@
# manpage says yt-dlp use --sub-langs, youtube-dl use --sub-lang, but experiment shows yt-dlp also use --sub-lang
--sub-lang zh-Hans,zh-CN,zh-Hant,zh-SG,zh-TW,zh-HK,en,en-US,en-GB
+
+# linux max filename length is 255 bytes, UTF-8 1 character max 4 byptes
+# aria2c will add about max 24 chars behind video name, for example: '.f616.mp4.part.frag.urls'
+# (255-24)/4=57
+# testing youtube videos: EXF4g-2jOJo
+--trim-filenames 57
diff --git a/home/xyz/.local/bin/mpvy b/home/xyz/.local/bin/mpvy
index e147a3c1..c4839af4 100755
--- a/home/xyz/.local/bin/mpvy
+++ b/home/xyz/.local/bin/mpvy
@@ -35,9 +35,8 @@ case $flag in
# --embed-subs is a little bit better, but still worse then direct streaming
# --sponsorblock-remove will make audio/video goes out of sync, need --force-keyframes-at-cuts which need re-encode which is slow, more see comments at the bottom of https://github.com/yt-dlp/yt-dlp/issues/871
# another way is using mpv-sponsorblock-minimal-git for streaming and sponsorblock-mpv-local for local videos
- # I use `--trim-filenames 54` because: linux max filename length is 255 bytes, UTF-8 1 character max 4 byptes, yt-dlp and aria2c will add about max 38 chars behind video name, for example: ' [EXF4g-2jOJo].f616.mp4.part.frag.urls', (255-38)/4==54. Not sure `mpvy -s` direct mpv method need this or not, I'll change if it meet issues in the future.
- A) yt-dlp --trim-filenames 54 -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url";;
- a) yt-dlp --trim-filenames 54 -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url" --exec 'mpv --fs --speed=2';;
+ A) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url";;
+ a) yt-dlp -f "$format" --embed-subs -P "${download_dir:-"$XDG_DOWNLOAD_DIR/mpvy/"}" --sponsorblock-remove default --sponsorblock-mark default "$url" --exec 'mpv --fs --speed=2';;
s) mpv --ytdl-format="$format" --ytdl-raw-options='write-sub=' --fs --speed=2 "$url";;
esac
# not sure if this is the best practice, but it seems working ;)