dyphire / mpv-scripts

userscripts for mpv
MIT License
53 stars 5 forks source link

chapter-make-read.lua - manually importing _chapter.chp file #4

Closed Max-Enrik closed 1 year ago

Max-Enrik commented 1 year ago

Thanks for the script.

It is easily and automatically imported.

I am just wondering how to manually import the chapter.chp file. Can you guide me on this?


I have to repeat this twice for the most recently created chapter. s script-message-to createchapter create_chapter; script-message-to chapter_make_read write_chapter


How to add a file title into the chapter file name, instead create_chapter.chp?

dyphire commented 1 year ago

I am just wondering how to manually import the chapter.chp file. Can you guide me on this?

No, it can't. I haven't implemented this function, why do you need it?

I have to repeat this twice for the most recently created chapter. s script-message-to createchapter create_chapter; script-message-to chapter_make_read write_chapter

You don't need to use createchapter.lua anymore, I have implemented relevant functions in chapter-make-read.lua. just use s script-message-to chapter_make_read create_chapter; script-message-to chapter_make_read write_chapter

How to add a file title into the chapter file name, instead create_chapter.chp?

This script uses the filename by default when creating an external chapter file: https://github.com/dyphire/mpv-scripts/blob/3fe5f3ce1c51d04faec7d47b81b816aae244796e/chapter-make-read.lua#L196-L213

It works normally for me. I don't know why it doesn't work for you. It will be helpful if you can provide mpv log files.

Max-Enrik commented 1 year ago

No, it can't. I haven't implemented this function, why do you need it?

Because I watch videos from internet sources. How can the script match/be adapted?

This script uses the filename by default when creating an external chapter file:

Yes, when I play video from the local/hard disk. But no, when I play videos from internet sources.

dyphire commented 1 year ago

No, it can't. I haven't implemented this function, why do you need it?

Because I watch videos from internet sources. How can the script match/be adapted?

This script uses the filename by default when creating an external chapter file:

Yes, when I play video from the local/hard disk. But no, when I play videos from internet sources.

The latest commit of https://github.com/dyphire/mpv-scripts/commit/a9a027e97bdbc3a2ccf791a7612cbfce06fd6391 should work for network playback file. Can you test it?

Max-Enrik commented 1 year ago

OMG! You are the best! Thank you so much!

Max-Enrik commented 1 year ago

How can I delete specific chapters while playing a file?

dyphire commented 1 year ago

How can I delete specific chapters while playing a file?

You can't, because mpv doesn't support this operation.

Max-Enrik commented 1 year ago

It looks like it just doesn't support the chapter, right? Because it can delete history/bookmark scripts from their list menu.

Max-Enrik commented 1 year ago

When a file has ? in the title chapter script doesn't work.

dyphire commented 1 year ago

When a file has ? in the title chapter script doesn't work.

Cannot replicate on local file because cannot use these special characters of \/?: in filename. I guess it is still a issue with network files. Please test whether the following patches work.

Subject: [PATCH] replace special characters in media-titles

---
 chapter-make-read.lua | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/chapter-make-read.lua b/chapter-make-read.lua
index 2eb01fb..65736cc 100644
--- a/chapter-make-read.lua
+++ b/chapter-make-read.lua
@@ -114,7 +114,7 @@ local function mark_chapter()
     local fname = mp.get_property("filename/no-ext")
     if is_protocol(path) or utils.readdir(dir) == nil then
         dir = network_chap_dir
-        fname = mp.get_property("media-title")
+        fname = mp.get_property("media-title"):gsub("[\\/:%?]*", "")
     end
     local fpath = dir
     local chapter_fliename = fname .. o.chapter_flie_ext
@@ -227,7 +227,7 @@ local function write_chapter()
     local file = io.open(out_path, "w")
     if file == nil then
         dir = network_chap_dir
-        name = mp.get_property("media-title")
+        name = mp.get_property("media-title"):gsub("[\\/:%?]*", "")
         out_path = utils.join_path(dir, name .. o.chapter_flie_ext)
         file = io.open(out_path, "w")
     end
@@ -279,7 +279,7 @@ local function write_chapter_xml()
     local file = io.open(out_path, "w")
     if file == nil then
         dir = network_chap_dir
-        name = mp.get_property("media-title")
+        name = mp.get_property("media-title"):gsub("[\\/:%?]*", "")
         out_path = utils.join_path(dir, name .. "_chapter.xml")
         file = io.open(out_path, "w")
     end
-- 
Max-Enrik commented 1 year ago

The initial test was perfect! Thank you!

Max-Enrik commented 1 year ago

I had to delete the createchapter.lua file. When I deleted that script, the script failed to create chapters.

a script-message-to chapter_make_read create_chapter; script-message-to chapter_make_read write_chapter

It looks like I have to keep createchapter.lua.

dyphire commented 1 year ago

Cannot replicate

Max-Enrik commented 1 year ago

I don't want simple history would append in a .chp file. Would it not add in a .chp file?

00:01:00.1 SimpleHistory 1