Adding functionality and improvements#4
Conversation
added the ability to return the old method of connecting external files via audio-add and sub-add.
|
Hello, @Serega007RU ! Thanks again for enhancing this script. That But currently, the script doesn't work correctly. There is nothing in the script's logs, so I'll need to go deeper. I've tried to debug it a little, seems that |
|
Regarding the "closed" handler, it's strange that it behaves this way in your case. I tested and verified everything before creating the PR. Regarding "play_from_playlist," are there any errors in your logs? |
Yes. Here's my environment, maybe it'll be useful: mpv v0.41.0 UPD: I've tried both MPV from my package version and one from Flathub, so that's probably not a problem with the libraries. I'll try to test this script on a Windows PC later too.
no. |
This is not enough, there should be more numbers further on, this is what my version looks like: I tried testing the script on MPV version UPD: I suspect this issue was fixed in mpv-player/mpv#17256 |
|
That's my Your In my case, the source was a Git commit with a tag Therefore, the difference between my MPV and your is 666 (lol) commits and about 10 months (2025-03-25 -> 2026-01-31). I guess the time has come to compile MPV from source manually. 😄 |
|
As I understand it, Pacman or Flathub are providing you with an older version of MPV. Considering the commits that fix our issue were made only three weeks ago (which isn't that long ago), I think we should find a workaround for older versions of MPV. |
Yeah, the stable release. I'll try to compile MPV from the latest commit you've shown and test if this bug is really fixed. |
|
I propose the following temporary solution: @@ -387,10 +387,19 @@ local function play_from_playlist(torrent_menu, index)
mp.commandv("loadlist", "memory://" .. torrent.playlist)
mp.set_property_number("playlist-pos-1", index)
end
+-- temporary solution to the problem
+-- https://github.com/mpv-player/mpv/pull/17256
+-- TODO remove this after a stable release of MPV with a fix appears
+local function input_select(args)
+ mp.add_timeout(0.1, function()
+ input.select(args)
+ end)
+end
+
local function show_torrent_files(torrent_menu, torrent_index)
if not torrent_menu.file_stats then
torrent_menu = curl(TORRSERVER .. "/stream?link=" .. torrent_menu.hash .. "&stat")
if not torrent_menu then return end
end
@@ -417,11 +426,11 @@ local function show_torrent_files(torrent_menu, torrent_index)
end
end
end
local selected = false
- input.select({
+ input_select({
prompt = "Select an entry of torrent:",
items = items,
default_item = last_viewed,
submit = function (index)
@@ -443,11 +452,11 @@ show_torrents = function (default_item)
local items = {}
for i, entry in ipairs(torrents) do
items[i] = entry.name or entry.title
end
- input.select({
+ input_select({
prompt = "Select a torrent:",
items = items,
default_item = default_item,
submit = function (index) |
|
I've tested MPV compiled from the commit 3ed9b79 and the script works perfectly now. Now let me test if that 0.1 sleep timeout really prevents that race condition. |
|
I think we can reduce the timer to 0.01 to make the delay less noticeable. |
|
Yeah, that timeout really prevents that undefined behaviour. But there one of 100+ torrents in my collection which causes this strange traceback: |
|
I've tested the same torrent again, and the traceback is completely different now: |
|
What version of MPV (commit number) does this problem occur in? |
|
I've tested both 0.41.0-2 from Arch repositories and 0.41.0.g3ed9b798-1 which I built myself from that fixing commit. |
|
the error occurs here https://github.com/mpv-player/mpv/blob/3ed9b798bb88940e7a619b30c2c448dc1ac3441d/player/lua/input.lua#L76 |
|
(I've coded a helper function to print tables as a string): local function table_to_string(t)
local result = "{ "
for k, v in pairs(t) do
if type(k) == "string" then
result = result .. k .. " = "
end
if type(v) == "table" then
result = result .. table_to_string(v) .. ", "
else
result = result .. tostring(v) .. ", "
end
end
result = result .. "}"
return result
endI've sent you an example torrent in dm. |
d938642 to
fc00da2
Compare
|
fixed, you can check what about this #4 (comment)? |
…e cache only if watching content from TorrServer
|
Great, now it works as intended. I've made a little changes, though. |
…rty & is_torrserver
|
Good. Let's already merge it. And again, thank you a lot for your efforts! 🤝 |
Hello @pursvir! It's me again, I can't stop and keep coming up with new things 😊
Here's what I did in this PR:
I rewrote the episode and torrent selection menu using the mp.utils.input.select API. This API is provided by MPV, it's better in functionality and usability, and it's also easier to write code for.
I added a display of whether the episode has been watched or not, using the ">" icon (this data is taken from TorgServer).
I added a display of speed and other data during file opening and caching.
I added the ability to disable the use of EDL via the configuration file, meaning I added the ability to revert to the old method of connecting external files if the user really wants to see the metadata of external files at the expense of speed.
I also refactored some of the code.