Skip to content

Commit

Permalink
get_location for content, mpd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovylein committed Nov 13, 2023
1 parent 6b54f47 commit ef92b71
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion resources/default-settings/jukebox.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ playermpd:
playerspot:
host: localhost
status_file: ../../shared/settings/spotify_player_status.json
collection_file: ../../shared/audio/spotify/spotify_collection.yaml
collection_file: ../../shared/audiofolders/spotify/spotify_collection.yaml
second_swipe_action:
# Note: Does not follow the RPC alias convention (yet)
# Must be one of: 'toggle', 'play', 'skip', 'rewind', 'replay', 'none'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def get_files(self, path, recursive=False):
:returns: List of file(s) and directories including meta data
"""
path = sanitize(path)
self._run_cmd(self.client.update, path)
if os.path.isfile(path):
files = self._run_cmd(self.client.find, 'file', path)
elif not recursive:
Expand All @@ -220,6 +221,8 @@ def get_files(self, path, recursive=False):

@plugin.tag
def get_track(self, path):
path = sanitize(path)
self._run_cmd(self.client.update, path)
playlist = self._run_cmd(self.client.find, 'file', path)
if len(playlist) != 1:
raise ValueError(f"Path decodes to more than one file: '{path}'")
Expand Down Expand Up @@ -265,6 +268,7 @@ def get_podcast(self, path):
* file: List podcast playlist
"""
path = sanitize(path)
pass

def _get_livestream_items(self, path):
Expand All @@ -280,6 +284,7 @@ def get_livestream(self, path):
* file: List livestream playlist
"""
path = sanitize(path)
pass

# -----------------------------------------------------
Expand Down
16 changes: 10 additions & 6 deletions src/jukebox/components/playern/core/player_content.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os.path

import yaml

import jukebox.plugs as plugin
Expand All @@ -11,10 +13,10 @@
class PlayerData:

def __init__(self):
self.audiofile = cfg.setndefault('players', 'content', 'audiofile', value='../../shared/audio/audiofiles.yaml')
self._database = {'audio': [],
'podcasts': [],
'livestreams': []}
self.audiofile = cfg.setndefault('players', 'content', 'audiofile', value='../../shared/audiofolders/audiofiles.yaml')
self._database = {'music': [{}],
'podcasts': [{}],
'livestreams': [{}]}
self._fill_database(self.audiofile)

def _fill_database(self, yaml_file):
Expand All @@ -30,8 +32,10 @@ def read_player_content(self, content_type):
return self._database.get(content_type, "empty")

@plugin.tag
def get_location_of_file(self, filename):
[v.get('x', None) for v in self._database.values()]
def get_location(self, titlename):
for key, value in self._database.items():
for elem in value:
return f"mpd:{key}:{elem['location']}" if elem['name'] == titlename else None

@plugin.tag
def list_content(self):
Expand Down

0 comments on commit ef92b71

Please sign in to comment.