player/command: refactor loadfile and loadlist to be more flexible#17458
player/command: refactor loadfile and loadlist to be more flexible#17458kasper93 wants to merge 2 commits intompv-player:masterfrom
Conversation
ad02260 to
0b8eea9
Compare
|
/cc @Dudemanguy @na-na-hi @guidocella This needs some testing, but this would be my idea to make it more flexible. Same as the old #15927, but using old commands. Back then I wanted to have master command for everything, but we might start with This mostly allows Some combinations of flags naturally doesn't make sense, I didn't test this thoroughly, but should work. When requested position is not found we show warning and file is appended at the end. Same as previously would. Comments welcome, if that's something that is useful and how to make it better. |
0b8eea9 to
27f27c2
Compare
|
Having both You can also explain that index defaults to Is it feasible to pass |
It's there to mirror
Isn't this enough?
Yes, I can try that. |
That's fair though the duplication is annoying. Not sure what is better.
Sorry I missed "by default". |
43156d1 to
fc6f697
Compare
|
Updated to move relative position flags to |
fe6683e to
ce52ae0
Compare
ce52ae0 to
9e2688a
Compare
DOCS/man/input.rst
Outdated
| <prepend> | ||
| Prepend the file to the playlist. |
There was a problem hiding this comment.
As mentioned there is no reason for this to exist. append is grandfathered and I do not see it a reason to add this. If you want "mirroring" I would rather deprecate append.
There was a problem hiding this comment.
We can deprecate append instead, but I would like to hear others opinion.
I think insert 0 require user to understand array indexing and have mental model of array manipulation. Not everyone is "programmer" and prepend/append is natural language understood by anyone.
Like insert -1 may do the append, it's technically the same thing, but this wouldn't be my first guess when I was trying to append, without preexisting knowledge.
There was a problem hiding this comment.
I think
insert 0require user to understand array indexing and have mental model of array manipulation.
We can just document insert 0 and insert -1 as example usage to achieve the effect of prepend/append.
There was a problem hiding this comment.
While deprecating append is unfortunate I found the API overwhelming at first. Also prepending to the playlist is an extremely niche use case so it doesn't need to be super convenient. (--playlist-start also has this 0 index issue).
The docs say appending is the default for insert without index so why would you need to pass -1? In fact in this case you can just make append a deprecated alias for insert and it will insert at the end by default.
There was a problem hiding this comment.
I've removed all the helper names from documentation. I'm still not sure what's so bad in providing shortcuts like that.
DOCS/man/input.rst
Outdated
| <next> | ||
| Next playlist entry after the current one. | ||
| <prev> | ||
| Previous playlist entry before the current one. | ||
| <current> | ||
| The current playlist entry. With ``insert`` action. | ||
| <first> | ||
| The first playlist entry. | ||
| <last> | ||
| The last playlist entry. |
There was a problem hiding this comment.
There is no reason for any of these to exist. They can be expressed as 0 or -1 or calculated from playlist-pos.
There was a problem hiding this comment.
It's way easier to type loadfile <file> insert next instead of doing the math on playlist-pos in script. It doesn't cost anything to support those aliases. Especially if playlist-pos is not yet available, this command handles this too.
There was a problem hiding this comment.
It's way easier to type
loadfile <file> insert nextinstead of doing the math onplaylist-posin script.
There is no math involved other than prev. current is playlist-pos and next is playlist-pos-1, both are usable in input.conf without script. And even for the case for prev in input.conf, a general mechanism for more numeric manipulation capability in property expansion is better and can be useful for many more cases.
It doesn't cost anything to support those aliases.
We have enough backwards compatibility baggage already for the loadfile flags. There is no reason to add even more when we know they are redundant.
Especially if
playlist-posis not yet available, this command handles this too.
This only happens in idle mode when there is no "current item" in the playlist. next, prev, and current are meaningless at this state.
There was a problem hiding this comment.
I agree on not adding more legacy baggage and note that for the longest time loadfile only had append and replace, inserting at specific positions is very niche so it doesn't need convenient aliases.
There was a problem hiding this comment.
There is no math involved other than prev. current is playlist-pos and next is playlist-pos-1, both are usable in input.conf without script.
next being playlist-pos-1, is just a workaround of inability of doing math. But, like said, I've removed all helpers. They still exists in the code naturally, for backward compatibility, just not exposed for the users, if that's what you prefer.
a general mechanism for more numeric manipulation capability in property expansion is better
This is just moving the bar. This is simple PR for loadfile/loadlist, not adding math to property expansion. I understand that it would be useful, but out of the scope.
DOCS/man/input.rst
Outdated
| this command.) | ||
|
|
||
| The third argument is an insertion index, used only by the ``insert-at`` action. | ||
| The third argument is an insertion index, used only by the ``insert+at`` action. |
There was a problem hiding this comment.
Why does this only work with insert but not replace like loadfile does?
Also there is no flag called at here.
There was a problem hiding this comment.
Why does this only work with insert but not replace like loadfile does?
Because replace doesn't make sense for loadlist except when replacing whole playlist. Unlike loadfile which work on single files basis.
Also there is no flag called at here.
Thanks, will remove.
There was a problem hiding this comment.
Because
replacedoesn't make sense forloadlistexcept when replacing whole playlist.
It makes sense by replacing multiple consecutive items from the same loaded playlist (same playlist-path). It essentially replaces all videos from a "sub playlist".
There was a problem hiding this comment.
I didn't consider such complex usecase to be useful, but sure, added subset replace now.
There was a problem hiding this comment.
It seems that the current implementation just replaces all future entries instead of checking playlist-path? Anyway I think the proposal is overkill. loadlist can just replace the current entry. The only difference between loadfile and loadlist is that loadlist append expands playlists before playing them so I don't think replacing the current entry makes more or less sense with loadlist. In fact this behavior should just be a loadfile flag instead of duplicating the whole command.
I think the new API is simpler to digest and more flexible overall.
9e2688a to
4794d57
Compare
Replace not only stops the current file playback, but also clear whole playlist before staring the new file playback.
By allowing more flexible flags combinations we can replace current single playlist entry, instead of replacing whole thing. And on top of that adds convinience positional flags, while refactoring everything to be use enum flags, instead of hardcoded values.
4794d57 to
40fefd0
Compare
| ["apply-profile"] = {"apply", "restore"}, | ||
| ["frame-step"] = {"play", "seek", "mute"}, | ||
| ["loadfile"] = {"replace", "append", "insert-next", "insert-at", "play"}, | ||
| ["loadfile"] = {"replace", "insert", "play", "prepend", "append"}, |
No description provided.