Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select.lua: select files with watch later files with g-w #15441

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

guidocella
Copy link
Contributor

@guidocella guidocella commented Dec 5, 2024

Implement selection of files with watch later config files. Requires --write-filename-in-watch-later-config.

Suggested by llyyr. He also suggested showing this when mpv opens, but it completely covers the logo and the text, and stays open after dropping a file. Alternatively "Drop files or URLs to play here." could also suggest pressing g-h.

Comment on lines 349 to 351
local watch_later_dir = mp.get_property("watch-later-dir")
watch_later_dir = mp.command_native({"expand-path",
watch_later_dir ~= "" and watch_later_dir or "~~state/watch_later"})
Copy link
Contributor

@kasper93 kasper93 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be exported as property that uses mp_get_playback_resume_dir for real directory, instead reimplementing the logic here.

Copy link

github-actions bot commented Dec 5, 2024

Download the artifacts for this pull request:

Windows
macOS

@guidocella guidocella force-pushed the recent branch 2 times, most recently from 4582d9b to 7f2cb9b Compare December 5, 2024 20:03
@guidocella
Copy link
Contributor Author

Improved performance by not stating redirect entries, sorting time went from 0.04s to 0.01s with 765 watch later files.

@verygoodlee
Copy link
Contributor

In general, played files should be showed in the history regardless of whether the playback has finished or not,
watch later file is not a real history in the sense that it does not save files that have finished playing.

watch later file is only a temporary solution for history, another disadvantage is that it support for the network file is not good, because it only save URL don't save the title, it’s impossible for user to understand https://www.youtube.com/xxx which video is it.

@kasper93
Copy link
Contributor

[select]
[select] stack traceback:
[select]        @select.lua:353: in function 'fn'
[select]        mp.defaults:235: in function 'fn'
[select]        mp.defaults:66: in function 'handler'
[select]        mp.defaults:388: in function 'handler'
[select]        mp.defaults:522: in function 'call_event_handlers'
[select]        mp.defaults:564: in function 'dispatch_events'
[select]        mp.defaults:515: in function <mp.defaults:514>
[select]        [C]: at 0x7ff6a095d0c0
[select]        [C]: at 0x7ff6a095c290
[select] Lua error: bad argument #1 to '?' (string expected, got nil)

@guidocella
Copy link
Contributor Author

Are you trying it without compiling the new current-watch-later-dir property?

@kasper93
Copy link
Contributor

Are you trying it without compiling the new current-watch-later-dir property?

I did checkout and build mpv, so it should be there, no?

@guidocella
Copy link
Contributor Author

Well how to reproduce then? I only get that error if current-watch-later-dir is undefined.

@kasper93
Copy link
Contributor

kasper93 commented Dec 10, 2024

Well how to reproduce then? I only get that error if current-watch-later-dir is undefined.

--no-config crashes, I don't do anything special.

Comment on lines 374 to 381
show_error("No watch later files with media paths found. " ..
"Enable --write-filename-in-watch-later-config to select recent files.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This OSD message is too long. It should be concise and easy to read as it disappears fast.

@guidocella
Copy link
Contributor Author

Yeah only --no-config makes the property nil.

local watch_later_dir = mp.get_property("current-watch-later-dir")

if not watch_later_dir then
show_error("No watch later files found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is warning, not an error. Nothing fails, just is not available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Every other select binding does this when nothing available though? Do you mean to change to mp.msg.warning?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Select edition shows error only if current-edition is nil, but shows empty list when there are no editions available.

I just feel like, lack of files in history is not an error, so mp.msg.warning. Maybe other indeed could be changed like that. Generally OSD message is enough, but we show also terminal message, errors are scary.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not intended. I wrote it blindly and thought no current-edtion means there are no editions like no chapter means there are no chapters in the previous binding.

end

if #watch_later_files == 0 then
show_error("No watch later files found.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is warning, not an error. Nothing fails, just is not available.

end

if #recent_files == 0 then
show_error("Enable --write-filename-in-watch-later-config to select recent files.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is warning, not an error. Nothing fails, just is not available.

Copy link
Contributor

@kasper93 kasper93 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will show, even if this option is enabled, but there is not recent files saved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It prints No watch later files found. and returns earlier if no recent files are saved. This is specifically if you have watch later files but did not enable --write-filename-in-watch-later-config.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and it will show all the time until you watch at least two files with this option, enabled. I think it should detect if this option is enabled. Because it was confusing to me to see this error, after enabling this option.

end

input.select({
prompt = "Select a recent file:",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I open directory, this will show only one file played as recent from this directory. Also opening this file will open file directly instead of directory.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't --autocreate-playlist load the other files in the directory if that's what you want?

@guidocella guidocella force-pushed the recent branch 2 times, most recently from 6292fab to ea7e22b Compare December 11, 2024 06:41
@guidocella
Copy link
Contributor Author

In general, played files should be showed in the history regardless of whether the playback has finished or not, watch later file is not a real history in the sense that it does not save files that have finished playing.

watch later file is only a temporary solution for history, another disadvantage is that it support for the network file is not good, because it only save URL don't save the title, it’s impossible for user to understand https://www.youtube.com/xxx which video is it.

Regarding this I think both watch later files and complete history file are useful in different cases. I also have a minimal script to log watched files to tmpfs just so I can resume from where I was in large directories when I close mpv by accident, while parsing watch later files is useful to check what you need to continue watching. It makes sense to reuse internal watch later files for an internal script. We can bind to g-w for watch later if needed to clarify that it's not a real history, or g-r for resume, but that needs rebinding show-properties.

Showing media-titles would be bad for filenames like 1.jpg instead.

@guidocella guidocella changed the title select.lua: select recent files with g-h select.lua: select files with watch later files with g-w Dec 15, 2024
Implement selection of files to resume playing from watch later config
files. Requires --write-filename-in-watch-later-config.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants