Closed mooseyboots closed 2 years ago
That's a neat idea! Any chance you can write tests for it? You can look in the tests subdirectory to see some examples, and type "make test" in the main directory to run the tests. Let me know if you get stuck or need help figuring things out! :)
Sacha
On Tue., Dec. 21, 2021, 13:05 mooseyboots, @.***> wrote:
i had a crack at implementing trimming overlapping subtitles and thought i would share what i came up with.
as per rndusr's recommendations, it includes
- customize option to ask to trim on load
- customize option to always trim on save
- custom options and prefix args to trim by:
- any number of milliseconds
- the value of subed-subtitle-spacing, or
- 1 millisecond
- customize option to either trim end of current or start of next sub.
personally i only have experience with .srt subtitle files, so that is all i have used this with. i also don't know the codebase super well. but thought i would share my efforts nonetheless.
You can view, comment on, or merge this pull request online at:
https://github.com/sachac/subed/pull/50 Commit Summary
- a3fff1d https://github.com/sachac/subed/pull/50/commits/a3fff1ddc87d644e4850bf1ff73815e616ef41f2 handle trimming of subtitles that overlap
- 6d72ef7 https://github.com/sachac/subed/pull/50/commits/6d72ef70ed506637f3f44b14ab08ed346b7a1d13 add fully configurable trimming of subtitle overlaps:
- 0a1c54f https://github.com/sachac/subed/pull/50/commits/0a1c54f377adfb7edbf9c983733d6aeeed3d2627 docstrings
File Changes
(3 files https://github.com/sachac/subed/pull/50/files)
- M subed/subed-common.el https://github.com/sachac/subed/pull/50/files#diff-b0b0c4192d685448c971c553c4d3fffdb359d0d96053584b65b4e2751ab905a2 (138)
- M subed/subed-config.el https://github.com/sachac/subed/pull/50/files#diff-e090d5c5faf1f4ff62e7b280467676c0df2d1673e19c65e68cee6d316c85928d (32)
- M subed/subed.el https://github.com/sachac/subed/pull/50/files#diff-0b220c0531feadb3db8e19a88eb3882b80f98422d0e91e139912ab3205284a68 (2)
Patch Links:
— Reply to this email directly, view it on GitHub https://github.com/sachac/subed/pull/50, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACD7ES7FGL4YEB4OJ5TV23USC6XPANCNFSM5KQYJ2RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you are subscribed to this thread.Message ID: @.***>
hey s, sure that's a good idea. i'm a silly noob with testing but am slowly getting the hang of it on another project. i'll just take a while to nut it out.
reference: #6
Sure! I'll add it to my todo list too in case I get to it first. It's a good learning opportunity. :) Thanks again for sharing this!
On Sat., Dec. 25, 2021, 06:52 mooseyboots, @.***> wrote:
hey s, sure that's a good idea. i'm a silly noob with testing but am slowly getting the hang of it on another project. i'll just take a while to nut it out.
— Reply to this email directly, view it on GitHub https://github.com/sachac/subed/pull/50#issuecomment-1001008154, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACD7ETUWRTL7YDKOERNTVTUSWWA7ANCNFSM5KQYJ2RQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
Worked on some tests tonight and rewrote it to use the functions for adjusting time stop/start. Haven't pushed my changes yet, as I want to take another look when I'm less sleepy. :) I'm a little unsure about having all the options for controlling it. Are you okay if I simplify it to just use either msecs as a numeric argument or subed-subtitle-spacing, instead of having another way to control whether subed-subtitle-spacing is used? People can set subed-subtitle-spacing to 1 if they want stop times and start times to be at least 1 msec apart, or have a function that calls it with an arg. (I'll probably change my config to that, actually.) Would that still work for your use case?
hey, that's great to hear! it would have taken me days and days of work. i'm also happy if you modify what i proposed, i'm sure you'll improve it. in my use case, i just tend to use 1ms. i really just need to blast away all overlaps before i start editing, so the gap isn't that crucial for me. i kind of wrote what i wanted but then expanded it to fit rndusr's suggestions. it was also a way for me to start learning what (interactive)
is capable of and how to tame it. it's great for me that you took a look at it, as i learn stuff when more experienced people edit my hacks.
Okay, I think I've mostly gotten things sorted out with tests and stuff at https://github.com/sachac/subed/commit/a97a9e565ea3ceaacc69db6aef4abe0602fac965 . I promise I didn't rename and fiddle with things just to be ornery. =) I wanted functions to be mostly discoverable with M-x, so I gave them (mostly) the subed-trim-overlap prefix. Customization options tend to be grouped alphabetically too, so I renamed them to be close together. I wanted to reuse the subed-adjust-subtitle-time-stop and -start functions because they seemed to have a fair bit of thought put into the logic. And then I ended up also tweaking how the sanitizing and validation functions were called so that we could have generic validation functions without having to add them to each of the specific validation functions...
Would you consider trying out this version and seeing if it works for you? It seems to pass the tests and it works interactively for me.
(Sorry for the somewhat heavy touch editing the code; I'm learning my way around maintaining subed too!)
hey, s, no probs, happy to defer to your hands.
i had a crack at implementing trimming overlapping subtitles and thought i would share what i came up with.
as per rndusr's recommendations, it includes
personally i only have experience with .srt subtitle files, so that is all i have used this with. i also don't know the codebase super well. but thought i would share my efforts nonetheless.