You are not logged in.

#26 2016-06-18 06:48:02

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

Re: m : finds and plays music [bash script]

chickenPie4tea wrote:

Shouldn't the script just create the directory itself?
...
"No file matches. Get first youtube result? (Y/n)"
...
but before I typed anything it started downloading form youtube.
...
Forgot to say I like it! it works quickly. I think the title of the thread should be
"m: finds plays and downloads music"

I think I might not have been clear in my previous answer,
it seems you ran m without setting your music library's directory variable at first.
Fault is mine. m was not ergonomic I see it.
It improved it with 2016.06.07 version, which prevents the user from having to set this variable.

Back then if you created ‘/home/dka/music MP3’ directory, thanks for your efforts at trying my poor script...
But you might want to give it another try.
When properly detected, your music library is quikly indexed by -u switch,
and m only downloads music you actually don't have locally.

I hope this helps. Your experience is precious and already helped me a lot to improve m. So thanks chickenPie4tea.

Offline

#27 2016-06-18 07:18:53

chickenPie4tea
Member
Registered: 2012-08-21
Posts: 309

Re: m : finds and plays music [bash script]

oh I never had a problem, just reported it for others but I like and use it. I will try out your new version.


You can like linux without becoming a fanatic!

Offline

#28 2017-05-25 12:10:03

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

Re: m : finds and plays music [bash script]

version bump : 2017.05.24, with a new option '-o' that plays the first file matching search terms. And quite some code cleaning.

Offline

#29 2017-06-05 17:11:32

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

Re: m : finds and plays music [bash script]

Thanks for sharing the script, I do like the speed.

I added a functionality to exclude a directory from the indexing path, since I have a folder with encoded mp3s that I use on portable devices.  I simply added an "exclude_dir" variable and added this to the "find" command:

-path "${path_to_music}/${exclude_path}" -prune -o -print

You can probably come up with something to add as many exclude dirs as needed, but I just need to exclude one.

Offline

#30 2017-06-10 09:21:26

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

Re: m : finds and plays music [bash script]

Version  bump.

Thank you watsonalgas for using m!

I am considering integrating your feature.
Then I should replace '-o' flag with '-or', that is not POSIX, but it works in BSDs and Linux.

I can think of other cases: conferences, audiobooks... that might be in ~/Music, but that you might not want to find with m.

In my case, I have them in subfolders, much like this:

Music
 |- MP3
 |- Audiobooks
 |- Conferences

Then I can either point $XDG_MUSIC_DIR to Music/MP3/ or set forced_music_path in m.
What do you think of it?

Offline

#31 2017-06-10 12:41:59

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

Re: m : finds and plays music [bash script]

I tried to get the script from http://arnaudv6.free.fr/m and I got this

Your requested URL has been blocked as per the directions received from Department of Telecommunications, Government of India. Please contact administrator for more information.

Nevermind I used tor to get it.

Offline

#32 2017-06-10 17:17:50

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: m : finds and plays music [bash script]

Wow, free.fr is a French ISP and looks like DoT ordered to block the whole domain neutral

Offline

#33 2017-06-11 07:49:39

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

Re: m : finds and plays music [bash script]

x33a wrote:

Wow, free.fr is a French ISP and looks like DoT ordered to block the whole domain neutral

Wow... I created a github repository which should settle the problem:
https://github.com/Arnaudv6/m/

Offline

#34 2017-06-11 23:42:24

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

Re: m : finds and plays music [bash script]

arnaudv6 wrote:

I can think of other cases: conferences, audiobooks... that might be in ~/Music, but that you might not want to find with m.

In my case, I have them in subfolders, much like this:

Music
 |- MP3
 |- Audiobooks
 |- Conferences

Then I can either point $XDG_MUSIC_DIR to Music/MP3/ or set forced_music_path in m.
What do you think of it?


In your case, your music dir is actually MP3, so that's what you would want to point to, but in my situation it made sense to exclude just the one directory and include everything else.  I think exclusion is a good feature either way.

I also thought of some other features: a play all option and a select random option.  I haven't thought about how to implement these yet, though.

With it being on GitHub now people can submit pull requests, which is cool.

Offline

#35 2017-06-13 15:09:59

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

Re: m : finds and plays music [bash script]

Hello watsonalgas
Thanks for your suggestions. I fear they have in common a more complex handling of the database:

watsonalgas wrote:

in my situation it made sense to exclude just the one directory and include everything else.  I think exclusion is a good feature either way.

Well unless you have some kiss suggestions, features like exclusion-list, multiple music directories... are better left out of m.
It is dead simple to create a m_update.sh script like this:

#!/usr/bin/env bash
find "${path_to_music}" -mindepth 1    \
    -path "${path_to_music}/${exclude_path}" -prune -o -print \
    | cut -c$((${#path_to_music}+2))-  \
    | sort > "${music_db_file}"

But it would get much more complex to document the feature and extend it (wildcards, remote storage, online services...) in m. I think.

watsonalgas wrote:

I also thought of some other features: a play all option and a select random option.  I haven't thought about how to implement these yet, though.

With it being on GitHub now people can submit pull requests, which is cool.

When updating/creating the database, m creates an entry for each directory, before listing their content. This is a feature I like: it allows playing an artist or a CD at once (with mpv backend at least).
But... presently there is no indication (trailing slash) in m database on whether an item is a directory or not. Sooo...

  • Add the slash like that: https://unix.stackexchange.com/a/4849 is nice, but then we loose BSD compatibility. (Update process is quite slow yet because of it).

  • And checking in the filesystem whether an item is a directory or not defeats the point of a database, doesn't it?

This is a burden:

  • When you want to have random playing (if randomly chosen item is a directory, you get stuck with its content possibly for quite some tracks.

  • With "play all" feature as well, for m would instruct mpv to play the directory, and then each item of it: every thing would get played twice.

Sidenote: random playing is a feature I would love to integrate. I am investigating further and would welcome any help on the trailing slash thing.

Arnaud

Offline

#36 2017-06-16 02:13:28

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

Re: m : finds and plays music [bash script]

arnaudv6 wrote:

Well unless you have some kiss suggestions, features like exclusion-list, multiple music directories... are better left out of m.
It is dead simple to create a m_update.sh script like this:

#!/usr/bin/env bash
find "${path_to_music}" -mindepth 1    \
    -path "${path_to_music}/${exclude_path}" -prune -o -print \
    | cut -c$((${#path_to_music}+2))-  \
    | sort > "${music_db_file}"

But it would get much more complex to document the feature and extend it (wildcards, remote storage, online services...) in m. I think.

No, I wasn't thinking of anything complex like that, just excluding one directory out of the main suits my purposes, and excluding more than one would be trivial too, I think, but anything else would make the script too complex.

arnaudv6 wrote:

When updating/creating the database, m creates an entry for each directory, before listing their content. This is a feature I like: it allows playing an artist or a CD at once (with mpv backend at least).
But... presently there is no indication (trailing slash) in m database on whether an item is a directory or not. Sooo...

  • Add the slash like that: https://unix.stackexchange.com/a/4849 is nice, but then we loose BSD compatibility. (Update process is quite slow yet because of it).

  • And checking in the filesystem whether an item is a directory or not defeats the point of a database, doesn't it?

This is a burden:

  • When you want to have random playing (if randomly chosen item is a directory, you get stuck with its content possibly for quite some tracks.

  • With "play all" feature as well, for m would instruct mpv to play the directory, and then each item of it: every thing would get played twice.

Sidenote: random playing is a feature I would love to integrate. I am investigating further and would welcome any help on the trailing slash thing.

The only thing I could think of is using

sed -e '/\./!d' -e '/\//!d' 

to choose only filenames with dots, but this would select an album directory with a dot as part of the name.  We could also use maybe files that start with a track number (two digits and then a dot) to make it more accurate, but that depends on filename scheme.

Last edited by watsonalgas (2017-06-16 02:13:59)

Offline

#37 2017-06-16 10:17:20

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

Re: m : finds and plays music [bash script]

Hello watsonalgas

...It turns out mpv has an effective shuffle play mode.
I was also able to add a trailling slash to directories for further needs.

if you run 'm -s' and press enter to select the first entry, you will play all your music in shuffled order.

There is a caveat: I did not implement shuffle play if you use [space] to make a multiple selection in sentaku yet.
Hope it suits you better.

Offline

#38 2017-08-08 16:53:24

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

Re: m : finds and plays music [bash script]

arnaudv6 wrote:

if you run 'm -s' and press enter to select the first entry, you will play all your music in shuffled order.

As a matter of fact, you can play all your music shuffled by simply issuing

m -o -s

Offline

#39 2017-08-26 15:34:51

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

Re: m : finds and plays music [bash script]

Great script ; very useful. Is it possible to play an album (~ a folder) and not only a single music file ?

Offline

#40 2017-08-26 20:45:32

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

Re: m : finds and plays music [bash script]

Sirsurthur wrote:

Great script ; very useful. Is it possible to play an album (~ a folder) and not only a single music file ?

Thanks!
Yes it is: I use mpv as a backend, and only have to select the line of the directory in search results.

For instance I get multiple results if I type:

m vida cold

first is "Coldplay - Viva la Vida" album, then all the files in it.
If I select the first line, mpv will play the folder / album.

Knowing this, you can shorten your way by adding the "-o" (oneshot) argument: m will play at once the first result (in this case the folder).

Hope this helps

Arnaudv6

edit: typo, add -> adding

Last edited by arnaudv6 (2017-08-27 06:13:51)

Offline

Board footer

Powered by FluxBB