dyphire / mpv-scripts

userscripts for mpv
MIT License
68 stars 5 forks source link

chapter-make-read - Refresh the chapter list manually #11

Closed agreselin closed 1 year ago

agreselin commented 1 year ago

Hi, I usually write down the chapter list in a text editor, as a <video>.<ext>.chp file. Is it possible to manually refresh the chapter list while playing <video>, reading from <video>.<ext>.chp?

dyphire commented 1 year ago
# Mark chapters
key script-message-to chapter_make_read create_chapter
# Remove current chapter
key script-message-to chapter_make_read remove_chapter
# Edit existing chapter's title
key script-message-to chapter_make_read edit_chapter

Can these key bindings not meet editing needs? Why do you need to use a text editor?

If you only added some new chapters in the text editor, it is not difficult to implement manually refresh. But if you also delete some chapters in the text editor, it will be difficult to implement manually refresh.

agreselin commented 1 year ago

Why do you need to use a text editor?

I'm used to and I like doing it this way. I used to write down a txt with the same formatting as a chp file, and then convert it to an EDL that just splitted the video into chapters. Then I found your script and liked it a lot, but I still also like to write down chapters in the text editor. I get to see all of them at once, I can quickly edit the titles or adjust a timestamp when I know I got it a bit too late or too soon… Also, this way I can name chapters without depending on mpv-user-input.

If you only added some new chapters in the text editor, it is not difficult to implement manually refresh. But if you also delete some chapters in the text editor, it will be difficult to implement manually refresh.

Yes I usually don't touch the old chapters. Sometimes I change their title but I hardly ever delete them. If it's possible to update the titles of the existing chapters it would be great, but even just adding the new ones would be useful.

dyphire commented 1 year ago

Yes I usually don't touch the old chapters. Sometimes I change their title but I hardly ever delete them. If it's possible to update the titles of the existing chapters it would be great, but even just adding the new ones would be useful.

The latest commit https://github.com/dyphire/mpv-scripts/commit/936a3da23d2131b38db36b00887d99c8200d52ad has implemented this feature, please test if it works for you.

agreselin commented 1 year ago

It loads new chapters and updates the title of the existing ones. It doesn't remove chapters I've deleted from the list but that's not a problem. Thanks man, great work :-)

dyphire commented 1 year ago

But if you also delete some chapters in the text editor, it will be difficult to implement manually refresh.

I realize that implementing this is not difficult and have optimized the implementation in the latest commit.

agreselin commented 1 year ago

Awesome!

Btw (for anyone who may stumble across this ticket), this command copies a timestamp at the current ${playback-time} in the format used by the chp file; it's what makes it easy for me to use a text editor to write down the chapter list.

Ctrl+Shift+c run "/bin/sh" "-c" "echo -n \"${playback-time/full}\" | xclip -i -selection clipboard" ; show-text "Copied timestamp for chapter-make-read.lua"

It works on GNU, I don't know about other operating systems.