kl / sub-batch

Match and rename subtitle files to video files and perfom other batch operations on subtitle files
MIT License
24 stars 4 forks source link

Preserve secondary extension(lang) when renaming subtitles #5

Closed proItheus closed 10 months ago

proItheus commented 11 months ago

For a subtitle named something.jp.ass, sub-batch will erase the jp part when renaming. I think it should be preserved.

kl commented 11 months ago

It will always rename subtitles files to the name of the matched video file with the video file's extension replaced by the subtitle extension. So for example if you have a subtitle file something1.jp.ass and a video file 1something.mp4 it will rename the sub to 1something.ass so that the names are identical except for the file extensions (so that for example mpv will auto-detect the renamed subtitle)

What is your use case for preserving sub-extensions?

proItheus commented 11 months ago

I have several subtitles for one video, each with a different language. e.g. ep1.mkv ep1.jp.ass ep1.sc.ass ep1.en.ass ...

Dec 9, 2023 8:57:22 PM Kalle Lindström - notifications at github.com @.***>:

Forwarded by SimpleLogin to @.** from "Kalle Lindström " with Re: [kl/sub-batch] Preserve secondary extension(lang) when renaming subtitles (Issue #5)* as subject

It will always rename subtitles files to the name of the matched video file with the video file's extension replaced by the subtitle extension. So for example if you have a subtitle file something1.jp.ass and a video file 1something.mp4 it will rename the sub to 1something.ass so that the names are identical except for the file extensions (so that for example mpv will auto-detect the renamed subtitle)

What is your use case for preserving sub-extensions?

— Reply to this email directly, view it on GitHub[https://github.com/kl/sub-batch/issues/5#issuecomment-1848402394], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AMBSVDTO3KI46X3AGO2YKDDYIRN2LAVCNFSM6AAAAABAJWBT72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBYGQYDEMZZGQ]. You are receiving this because you authored the thread. [Tracking image][https://github.com/notifications/beacon/AMBSVDXEQQNZQY7HJN5XTU3YIRN2LA5CNFSM6AAAAABAJWBT72WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTOFRQ5U.gif]

kl commented 11 months ago

I see. However sub-batch currently doesn't support renaming multiple subtitle files for a single video file, e.g. in your example it would only rename one subtitle file and if you run it again it will say that all files are already renamed.

So you want it to also be able to rename multiple subs per video, right?

proItheus commented 11 months ago

Sure, that would be nice.

kl commented 10 months ago

I've tested with mpv and vlc and mpv will auto detect the subtitle if the secondary extension is no longer than 3 characters, while vlc auto detects no matter how long the secondary subtitle is. So if you have a long secondary extension e.g. subtitle1.something.srt and we keep the .something part it won't work in mpv.

Maybe we should only keep the secondary extension if it is less than 4 characters long? Then it would still work with all country codes which I assume is the main (only?) use case here. Any thoughts?

proItheus commented 10 months ago

This will cover the majority of use cases. However some edge cases still exists, like bilingual subtitles jp_sc.ass (we can specify sub-auto=fuzzy to mpv to recognize it).

So maybe keeping the default length limit as 3, while having an option like max_second_extension_len? So that we can make mpv happy at default configuration as well as cover edge cases.

Dec 13, 2023 6:06:56 PM Kalle Lindström - notifications at github.com @.***>:

Forwarded by SimpleLogin to @.** from "Kalle Lindström " with Re: [kl/sub-batch] Preserve secondary extension(lang) when renaming subtitles (Issue #5)* as subject

I've tested with mpv and vlc and mpv will auto detect the subtitle if the secondary extension is no longer than 3 characters, while vlc auto detects no matter how long the secondary subtitle is. So if you have a long secondary extension e.g. subtitle1.something.srt and we keep the .something part it won't work in mpv.

Maybe we should only keep the secondary extension if it is less than 4 characters long? Then it would still work with all country codes which I assume is the main (only?) use case here. Any thoughts?

— Reply to this email directly, view it on GitHub[https://github.com/kl/sub-batch/issues/5#issuecomment-1853618479], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AMBSVDSYPQWGZFAXEFROSV3YJF43FAVCNFSM6AAAAABAJWBT72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJTGYYTQNBXHE]. You are receiving this because you authored the thread. [Tracking image][https://github.com/notifications/beacon/AMBSVDRX2U25DAE3WD72IPTYJF43FA5CNFSM6AAAAABAJWBT72WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTOPP4S6.gif]

kl commented 10 months ago

Ok cool, I've implemented initial support now and pushed it to the master branch. Are you able to try it out? I didn't add a config option for the length yet, so right now it will ignore secondary extensions that are longer than 3 chars or contains numbers.

kl commented 10 months ago

I've released a new 2.0 version with support for secondary extensions! See the readme for the details. Closing this issue now. Feel free to re-open it if something doesn't work as expected.