You are not logged in.

#1 2018-06-28 17:17:13

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

lizzy (music player) python script that feeds your music to mpv

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 big_smile

  • 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

#2 2018-06-28 18:09:18

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,257

Re: lizzy (music player) python script that feeds your music to mpv

It looked really good until I reached elif hell  hmm

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

#3 2018-06-28 20:36:24

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: lizzy (music player) python script that feeds your music to mpv

ewaller wrote:
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 StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2018-06-29 07:35:20

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Thanks you both for reading the code and proposing enhancements. cool

ewaller wrote:

It looked really good until I reached elif hell  hmm

@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!

Xyne wrote:

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

#5 2018-07-14 10:07:04

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

OK, Lizzy got quite an overhaul, in an attempt for more pythonistic style.
Feature-wise, expect accents to work as they should. smile
(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

#6 2018-07-27 16:40:33

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: lizzy (music player) python script that feeds your music to mpv

Already loved m and this is even cooler. Thanks Arnaud for this great script.

Offline

#7 2018-07-28 02:51:13

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: lizzy (music player) python script that feeds your music to mpv

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)

Offline

#8 2018-07-29 07:25:12

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Docbroke wrote:

Wonderful. I like this.

Hello Docbroke, thanks, glad you like lizzy! Let's answer this one first:

Docbroke wrote:

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.

Docbroke wrote:

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

#9 2018-07-29 07:26:17

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Sirsurthur wrote:

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 big_smile

Offline

#10 2018-07-29 10:57:39

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: lizzy (music player) python script that feeds your music to mpv

arnaudv6 wrote:

     
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.

arnaudv6 wrote:

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.

Offline

#11 2018-07-29 13:39:49

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

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:

  1. line 35 to set forcedMusicDir to your sshfs' mounting point,

  2. 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

#12 2018-07-29 18:08:40

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: lizzy (music player) python script that feeds your music to mpv

Thanks arnaudv6, I already had changed forcedMusicDir to sshfs. After making the second change as you suggested, workflow has improved significantly.

Offline

#13 2018-07-31 05:04:07

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: lizzy (music player) python script that feeds your music to mpv

Salut Arnaud. Would it be possible to have the lyrics using the mpv tags and python-glyr ?

Offline

#14 2018-07-31 18:39:29

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Sirsurthur wrote:

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:

I will help you down that road after the holidays as much as I can, to find or write such a script.

Offline

#15 2018-08-01 16:47:48

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: lizzy (music player) python script that feeds your music to mpv

Don't worry Arnaud. Just had to install mpv-mpris and osdlyrics and now I have my lyrics !

Offline

#16 2018-08-24 14:53:48

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Sirsurthur wrote:

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

#17 2018-08-24 14:55:05

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

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 tongue.

Offline

#18 2018-08-25 05:43:54

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: lizzy (music player) python script that feeds your music to mpv

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

#19 2018-08-25 05:59:53

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Sirsurthur wrote:

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

#20 2018-08-25 06:32:48

Sirsurthur
Member
Registered: 2009-02-02
Posts: 124

Re: lizzy (music player) python script that feeds your music to mpv

Works great with the correct syntax.

Very helpful and well thought script. Thanks again Arnaud (I am using it a lot).

Offline

#21 2018-09-03 05:30:14

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,438

Re: lizzy (music player) python script that feeds your music to mpv

arnaudv6 wrote:

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.

Offline

#22 2018-09-19 21:49:12

watsonalgas
Member
Registered: 2007-01-15
Posts: 92

Re: lizzy (music player) python script that feeds your music to mpv

Is m -o lost?

Offline

#23 2018-09-25 12:54:35

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Sirsurthur wrote:

Very helpful and well thought script. Thanks again Arnaud (I am using it a lot).

Thanks !

Offline

#24 2018-09-25 12:55:54

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

Docbroke wrote:

I tested it again today and it worked great. Thanks.

Thanks for the report!

Offline

#25 2018-09-25 13:05:16

arnaudv6
Member
Registered: 2016-02-25
Posts: 73

Re: lizzy (music player) python script that feeds your music to mpv

watsonalgas wrote:

Is m -o lost?

What do you mean?
Like is m dead? I guess no smile 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

Board footer

Powered by FluxBB