You are not logged in.
Dear community, may I happily present you my intended replacement for m?
Its name is lizzy, it is a single file, written in python + curses, featuring more consistency and more features than its ancestor.
I am much eager to hear from you about:
your thoughts about the usage : bring on your best workflow obsessions : we might share them
feature propositions (please acknowledge the vision though before hitting too wide)
more pythonistic ways to code (hobbyist still learning the trade here)
faster code paths (we love speed, do not we?)
edit: Please consider using the latest version.
Last edited by arnaudv6 (2019-05-13 17:24:00)
Offline
It looked really good until I reached elif hell
You are looking to be more Pythonic. Might I suggest a data structure, say a dictionary in which the key is the key stroke, and defines the operation to perform using lambda functions?
Kind of like this:
theDict = { "a" : lambda x: someFunctionThatHandles_a (x),
"b" : lambda x: someFunctionThatHandles_b (x),
"c" : lambda x: someFunctionThatHandles_c (x),
}
keyStroke = someFunctionToReadTheKey()
theDict[keyStroke]()
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
theDict = { "a" : lambda x: someFunctionThatHandles_a (x), "b" : lambda x: someFunctionThatHandles_b (x), "c" : lambda x: someFunctionThatHandles_c (x), }
You could omit the lambdas in that example, e.g.
key_funcs = {
'a': some_function_that_handles_a,
'b': some_function_that_handles_b,
...
}
@arnaudv6
Use a try-except block to catch key errors if you take that approach (see EAFP):
key = read_the_key()
try:
func = key_funcs[key]
except KeyError:
pass # Ignore unhandled keys.
else:
func() # or func(key) or func(<other data>), depending on what the function expects.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Thanks you both for reading the code and proposing enhancements.
It looked really good until I reached elif hell
@ewaller: Now you say it, I was not proud with this part of the code, and... a dictionary is the obvious way to go: thanks!
Use a try-except block to catch key errors if you take that approach.
@Xyne: I will, thanks!
I fear I won't have time to refactor this and test regressions before a fortnight though.
Offline
OK, Lizzy got quite an overhaul, in an attempt for more pythonistic style.
Feature-wise, expect accents to work as they should.
(Search is insensitive to case and accents.)
I had very little time for testing but it should be a pleasant ride: please report any odd behaviour.
Offline
Already loved m and this is even cooler. Thanks Arnaud for this great script.
Offline
Wonderful. I like this.
Two questions
1. How to change music directory on the go ? or search outside the directory. I have a sshfs mounted drive with songs in addition to some songs stored on ssd. How to change between this two?
2. How to search for songs while mpv is running ( lizzy interface is hidden when songs are playing) ?
Last edited by Docbroke (2018-07-28 02:51:35)
Arch is home!
https://github.com/Docbroke
Offline
Wonderful. I like this.
Hello Docbroke, thanks, glad you like lizzy! Let's answer this one first:
2. How to search for songs while mpv is running (lizzy interface is hidden when songs are playing) ?
It is a shortcoming directly implied by lizzy's design goals: feed mpv with a music playlist.
You can have a look here: https://gitlab.com/Arnaudv6/lizzy#ratio … n-features
Still -I would love to be proven wrong here- if someone has an easy/attainable way of doing this, please bring it on! But I am afraid I know none.
Some advantages come along with being presented a "raw" mpv while playing, though:
mpv's behaviour is genuinely unaltered, plus your mpv options and bindings are honoured.
Knowing this you can launch a second lizzy instance in another terminal, to search music while playing.
Don't forget to provide lizzy with a file path as argument, so you can keep both playlists.
1. How to change music directory on the go ? or search outside the directory. I have a sshfs mounted drive with songs in addition to some songs stored on ssd. How to change between this two?
I admit I did not cross the case yet where I would like to search an external storage (usb/sshfs) with a lizzy instance.
Same advice could apply here: -as a workaround- use a copy of lizzy with forced library path to your sshfs.
(as long as lizzy can successfully index your sshfs files... which I never tried but it should just work: please let me know.)
I admit editing a copy of lizzy sucks though, and I want to make it easier in next lizzy version. (Maybe not too soon sorry, for I am enjoying holiday right now).
For this to work nicely, I am considering moving some of lizzy's settings in a .conf file, and adding support for profiles in, like mpv does.
This way you could launch lizzy with the profile USB-key, or SSHFS.
Offline
Already loved m and this is even cooler. Thanks Arnaud for this great script.
Hello Sirsurthur, and thanks for taking the care of writing your compliment: it feels real nice. Merci
Offline
as long as lizzy can successfully index your sshfs files... which I never tried but it should just work: please let me know.
Yes It works. Currently I have two lizzy instance, one with sshfs folder as a music directory. I have to press ^U everytime I start regular lizzy after using sshfs lizzy to clean cached file list.
I am considering moving some of lizzy's settings in a .conf file, and adding support for profiles
Having .conf file would be nice. You may allow adding shortcuts for changing directories. ( like FastDirs in moc ) OR
You can just allow selecting directory through lizzy. At present lizzy only allows descending down in music directory, think about allowing ascending upwards in the directory structure. Once user find the directory he wants, he can press ^U to update the cache (effectively allowing selecting other music directories/ or mounted volumes).
I agree with your decision of running raw mpv in place of embedding it.
Arch is home!
https://github.com/Docbroke
Offline
I meant as a -temporary- workaround you could have one untouched, right-from-download lizzy file for accessing your local collection...
And a copy of it, say lizzySSHFS where you edit:
line 35 to set forcedMusicDir to your sshfs' mounting point,
line 79 to something like:
self.musicIndexPath = self.userDataFolder + "collectionSSHFS.idx"
so you don't have to press [^U] and avoid necessary disk access over your network.
Please keep the starting spaces: indentation matters, in python.
This should make your workflow less of a burden until I implement a config file with requested feature as soon as I can.
Ultimately you will be able to set one library path per profile in the config file, with attached index file.
It will be the same functionality-wise, only cleaner both under the roof and at the command-line.
Offline
Thanks arnaudv6, I already had changed forcedMusicDir to sshfs. After making the second change as you suggested, workflow has improved significantly.
Arch is home!
https://github.com/Docbroke
Offline
Salut Arnaud. Would it be possible to have the lyrics using the mpv tags and python-glyr ?
Offline
Salut Arnaud. Would it be possible to have the lyrics using the mpv tags and python-glyr ?
Salut Sirsurthur.
Like: "is it something that could be added in lizzy?"?
Hate to say no, but this really seems perpendicular to lizzy's vision:
not supporting ID-tags even for searching...
no online services apart from ytdl
no dependency
But... I guess this would easy enough, with the appropriate script in between lizzy and mpv:
You'd have to change backEndCommand (line 36 in master presently) like so:
backEndCommand = "path/to/script"
Indeed this should be easy enough! Said script would then call mpv.
Could you do this script, or help with it? Does not even have to be python (apart from this library you found).
I can not go much further without a sample file and more details: I never used lyrics from audio file, and I read there are several techno here:
tags, several of them, https://github.com/mpv-player/mpv/issues/1404
.lrc files
online services (which python-glyr seems about, telling by small search)
I will help you down that road after the holidays as much as I can, to find or write such a script.
Offline
Don't worry Arnaud. Just had to install mpv-mpris and osdlyrics and now I have my lyrics !
Offline
Don't worry Arnaud. Just had to install mpv-mpris and osdlyrics and now I have my lyrics !
Hello Sirsurthur, glad you could make it and thanks for sharing the solution!
Offline
Hello @Docbroke, community. I added profiles support to lizzy, tested a bit and tagged this version.
Here are the guidelines to profiles: https://gitlab.com/Arnaudv6/lizzy#usage.
Next I should like to come-up with a terminal recording to showcase lizzy.
Please let me know about the functionnality/documentation and any problem/regression.
One might argue that this config.ini file adds complexity for a single-file script, but:
it is optional
in corner cases where '~/.config/user-dirs.dirs' is not well populated, there is no need to edit lizzy executable anymore.
... Now that this is implemented, I think I will try using it to see my movies also .
Offline
Hi Arnaud,
Updated lizzy script, created a config.ini and tried to launch the profile films (lizzy --profile films) but no luck. What am I doing wrong ?
Offline
Hi Arnaud,
Updated lizzy script, created a config.ini and tried to launch the profile films (lizzy --profile films) but no luck. What am I doing wrong ?
Hello Sirsurthur,
you are doing nothing wrong, I was: the help text said to invoke lizzy like you did, when it must be --profile=NAME.
Sorry about that, and thanks for reporting it.
I corrected the help text and tagged a new version.
Offline
Works great with the correct syntax.
Very helpful and well thought script. Thanks again Arnaud (I am using it a lot).
Offline
Hello @Docbroke, community. I added profiles support to lizzy, tested a bit and tagged this version.
Wonderful, I tested it the same day you posted, but couldn't get it to work, (due to profile formate issue), I thought I might be doing something wrong so didn't report hoping to test it as I was busy in other works. I tested it again today and it worked great. Thanks.
Arch is home!
https://github.com/Docbroke
Offline
Is m -o lost?
Offline
Very helpful and well thought script. Thanks again Arnaud (I am using it a lot).
Thanks !
Offline
I tested it again today and it worked great. Thanks.
Thanks for the report!
Offline
Is m -o lost?
What do you mean?
Like is m dead? I guess no but it definitively is in maintenance mode: I don't intend to develop it further, only maintain it, killing bugs when they show.
or
Like is there an equivalent feature to m's "-o" option in lizzy? Yes there is, there is no command line argument like with m, but you can select '/', as long as you don't type a filter string. Am I clear?
Offline