Moode Forum
is there a command to jump Folders to folders - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: is there a command to jump Folders to folders (/showthread.php?tid=7307)



is there a command to jump Folders to folders - avior - 01-15-2025

hello
I was wondering if there a command to jump folder to folder by pressing the same key "0" button on remote control

at the moment I have it setup as

press 1 = mp3 plays
press 2 = classic plays
press 3 = etc plays

and so on

many thaanks


RE: is there a command to jump Folders to folders - Stephanowicz - 01-24-2025

(01-15-2025, 08:37 AM)avior Wrote: hello
I was wondering if there a command to jump folder to folder by pressing the same key "0" button on remote control

at the moment I have it setup as

press 1 = mp3 plays
press 2 = classic plays
press 3 = etc plays

and so on

many thaanks

Hi,

what kind of "folders" are You talking about? 
Physical folder structure? 

And what do You want to achieve? Parse every folder and play it's contents?

How do You want to achieve this? MPD commands?

afaik mpd needs a playlist if You want to refer to physical files
So You would need a script that parses the folders and creates a playlist for each - then You would need another script that has/parses a list of all playlists, an index that is counted up and a function that calls the next playlist when the remote button is pushed....

are Yout thinking of smth like this?

Cheers, 
Stephan


RE: is there a command to jump Folders to folders - Tim Curtis - 01-24-2025

It could be simpler but still not trivial and would require several moving parts like below.

1. Maintain a list of folder paths for a "jump" list
2. Create an API (command) to perform "play_next_folder" in the jump list

Most of the complexity will be in #1 because it prolly involves adding a context menu selection to Folder view for example "Add to jump list" plus the JS and PHP code behind it, and then a maintenance screen for move/delete items in the jump list plus the JS and PHP code behind it.

Then you could map button 0 to "play_next_folder"

Nice challenge for a dev that wants to learn how to add a feature to moode :-)


RE: is there a command to jump Folders to folders - Stephanowicz - 01-25-2025

(01-24-2025, 07:18 PM)Tim Curtis Wrote: It could be simpler but still not trivial and would require several moving parts like below.

1. Maintain a list of folder paths for a "jump" list
2. Create an API (command) to perform "play_next_folder" in the jump list

Most of the complexity will be in #1 because it prolly involves adding a context menu selection to Folder view for example  "Add to jump list" plus the JS and PHP code behind it, and then a maintenance screen for move/delete items in the jump list plus the JS and PHP code behind it.

Then you could map button 0 to "play_next_folder"

Nice challenge for a dev that wants to learn how to add a feature to moode :-)

Well, yes - first point is quite complex as You still need to parse the folders/subfolders contents and build a playlist from it. (as mpd always needs a playlist)

So, one could reduce the task to either "play next playlist" from all playlists - or "play next playlist" from a certain list of playlists.

That could still be an interesting feature (which could also be accomlished without moode and a simple script)


RE: is there a command to jump Folders to folders - Tim Curtis - 01-25-2025

(01-25-2025, 11:52 AM)Stephanowicz Wrote:
(01-24-2025, 07:18 PM)Tim Curtis Wrote: It could be simpler but still not trivial and would require several moving parts like below.

1. Maintain a list of folder paths for a "jump" list
2. Create an API (command) to perform "play_next_folder" in the jump list

Most of the complexity will be in #1 because it prolly involves adding a context menu selection to Folder view for example  "Add to jump list" plus the JS and PHP code behind it, and then a maintenance screen for move/delete items in the jump list plus the JS and PHP code behind it.

Then you could map button 0 to "play_next_folder"

Nice challenge for a dev that wants to learn how to add a feature to moode :-)

Well, yes - first point is quite complex as You still need to parse the folders/subfolders contents and build a playlist from it. (as mpd always needs a playlist)

So, one could reduce the task to either "play next playlist" from all playlists - or "play next playlist" from a certain list of playlists.

That could still be an interesting feature (which could also be accomlished without moode and a simple script)

MPD can add the contents of a folder or folder tree directly to the Queue. There is no need to first construct a playlist.

For example the folder below contains 3 Album subfolders containing a total of 32 tracks. 

Code:
add "NAS/TRX-FLAC/Beth Orton"

The challenge in #1 has to do with the fact that it consists of both front-end and back-end parts. If you have never coded this type of feature in moode it can seem a bit complex at first.


RE: is there a command to jump Folders to folders - Stephanowicz - 01-25-2025

Ah, ok.

Nevertheless I don't think that this approach is desireable or sensibly implementable...
Where do You start? How is Your folder structure - is it flat or nested...? and, and, and....

Ok, one could reduce my last idea by not creating playlists for the folders to be played - but then one would need a list of folders to be played... Big Grin


RE: is there a command to jump Folders to folders - Tim Curtis - 01-25-2025

You don't need to know anything about the folder structure because Folder view already presents it. You simply navigate to a desired folder, click "Add to jump list" in the context menu and that folder path is added to the list. The list can be stored as a simple text file in /var/local/www/

A separate maintenance screen provides a way to remove or move items in the list. Basically a copy of the "Edit playlist" screen.

It very straight forward but as I mentioned earlier if you haven't ever implemented a feature like this in moode it will seem complex because of the number of parts.

It wouldn't go on my TODO list unless there were a significant number of requests for it.


RE: is there a command to jump Folders to folders - Stephanowicz - 01-25-2025

Ok, so here is a python script that does  
1. jump through all available playlists - forward or back ward  
2. jump through a list of folders - forward or back ward - list is named "flist" and is located in "/var/www/util/"
  
Code:
#!/usr/bin/python
###################################################################################################
#
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright 2024 Stephanowicz
# https://github.com/Stephanowicz/moOde-audioplayer-addons
#
###################################################################################################
#
# Script for jumping through either all mpd playlists
# or a list of folders
# the list of folders is located /var/local/www/util/ and named 'flist'
# it consists of a list of folderpaths - one folder each line
# the path must be a valid mpd music directory below /var/lib/mpd/music --> /NAS/..., /SATA/..., /USB/..., etc.
#
###################################################################################################
#
# command: python /var/local/www/util/jumplist.py
# arguments:      flist : play folders from flist
#                --> python /var/local/www/util/jumplist.py flist
#            
#                plist : jump through all playlists
#                --> python /var/local/www/util/jumplist.py plist
#
#                back : jump backwards through list (forward is default)
#                --> python /var/local/www/util/jumplist.py plist back
#
###################################################################################################


import sys
import os

indexfile = ''
direction = 1

if "plist" in sys.argv:
    indexfile = '/tmp/plistindex'
elif "flist" in sys.argv:
    indexfile = '/tmp/flistindex'

if "back" in sys.argv:
    direction = -1

if not indexfile == '':
    index=0
    if os.path.isfile(indexfile):
        f = open(indexfile, 'r')
        line=f.readline()
        if not line=="":
            index=int(line)
        f.close()
    
    index += direction
    print(index)
    if "plist" in sys.argv:
        stream = os.popen('mpc lsplaylists')
        mpclist = stream.read().splitlines()
        mpclen=len(mpclist)
        
        if index >= mpclen:
            index=0
        elif index < 0:
            index = mpclen-1
    elif "flist" in sys.argv:
        filelist = '/var/www/util/flist'
        if os.path.isfile(filelist):
            f = open(filelist, 'r')
            mpclist = f.read().splitlines()
            mpclen=len(mpclist)
            if index >= mpclen:
                index=0
            elif index < 0:
                index = mpclen-1
    if mpclen > 0:
        f = open(indexfile, 'w+')
        f.seek(0)
        f.write(str(index))
        f.close()

        os.system('mpc clear')
        if "plist" in sys.argv:
            subcmd = 'mpc load "' + mpclist[index] + '"'
        elif "flist" in sys.argv:
            subcmd = 'mpc add "' + mpclist[index] + '"'
        print(subcmd)
        os.system(subcmd)
        os.system('mpc play')



RE: is there a command to jump Folders to folders - Stephanowicz - 05-29-2025

Hi,

just created a python script that jumps to the next album in a playlist with different albums.
This reminded me of this question here...
So, if You have a playlist with different albums / folders this will do it for You:

https://github.com/Stephanowicz/moOde-audioplayer-addons/blob/master/addons/Stephanowicz/utils/mpd_pl_nextalbum.py

You can call it e.g in the irexec.lircrc with:

Code:
begin  
  prog = irexec  
  button = KEY_RIGHT  
  config = python /var/www/addons/Stephanowicz/utils/mpd_pl_nextalbum.py  
end


Cheers, Stephan