-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Playlists not displaying correctly in terminal #5868
Comments
This is on purpose. Corresponding commit: 05c398f |
Ok, but then there's no simple way to display currently playing list in terminal? (I know it is a bit weird but I have been using mpv as terminal based music player for years: with a few tweaks in config it works really well...) |
Yes, unfortunately. You are also not the first to have this problem/a desire for clean terminal output. You could try the following (untested) Lua script:
Save it as a file and put it into a |
Thanks a lot! I adapted a bit the script to my needs, leaving it here just in case: $ cat .mpv/scripts/pl.lua
json = require "json"
mp.add_forced_key_binding(
"L",
"print-playlist",
function()
pl = json.decode(mp.get_property("playlist", "[]"))
for _, v in pairs(pl) do
print (v["current"] and ">" or " ", v["filename"])
end
end
) |
Mapping to Also there are many json modules for lua. With this query I have found craigmj/json4lua. Also mpv needs lua 5.2. On Ubuntu you need to install:
Then
I see there is also https://github.com/mpx/lua-cjson/ but I have not tried it |
Not only does mpv provide a parse_json function to Lua, but also you don't need to deal with json at all if you use get_property_native. |
One change I think the print-playlist function script should have is no default keybinding, so you can bind it in input.conf.
in one thing I've been wondering about: can you have a keybindings change depending on if you're playing with and without video for mpv? Reason for this is the script won't show playlist for videos: it just prints to the console. But if you can have mpv see that you're playing a video, than it will change |
I'm getting good results with this script (lightly tested). It also prints the playlist conditionally. Thanks to @HawaiinPizza's for the suggestion. Here's the output:
|
@jagrg The Gitlab repo now redirects to If you still have the LUA script stored locally, is sharing here viable? |
Sorry about that. Here it goes:
https://git.sr.ht/~jagrg/dotfiles/tree/master/item/common/.config/mpv/scripts/print-playlist.lua
|
Functions, but the script has
Can be mapped to another key in
Also printing |
mpv version and platform
mpv 0.27.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects
Reproduction steps
L run echo "${playlist}"
in~/.mpv/input.conf
mpv folder_with_mp3_files/
to play a list of audio filesL
to display the currently playing list in the terminalExpected behavior
A nicely formatted playlist should be displayed showing currently playing item, etc.
Actual behavior
The terminal has some broken characters:
Problem seems to be there:
https://github.com/mpv-player/mpv/blob/master/player/command.c#L127
I upgraded recently to Ubuntu 18.04, and got a new mpv version with it. I cannot say if the problem is with some missing font on my side, or wrong encoding, or if it is a new mpv feature. I was using this playlist feature and had no problem with my previous setup (mpv 0.14.0 and Ubuntu 16.04)
I also searched for a config to disable special characters in the terminal display, did not find it (the man page is kind of "rich"...)
Log file
https://0x0.st/s23T.txt
The text was updated successfully, but these errors were encountered: