forked from MiczFlor/RPi-Jukebox-RFID
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7a3eab
commit 20d7284
Showing
3 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
import yaml | ||
|
||
import jukebox.plugs as plugin | ||
import jukebox.cfghandler | ||
|
||
logger = logging.getLogger('jb.player_content') | ||
cfg = jukebox.cfghandler.get_handler('jukebox') | ||
|
||
|
||
class PlayerData: | ||
|
||
def __init__(self): | ||
self.audiofile = cfg.setndefault('players', 'content', 'audiofile', value='../../shared/audio/audiofiles.yaml') | ||
self._database = {'audio': [], | ||
'podcasts': [], | ||
'livestreams': []} | ||
self._fill_database(self.audiofile) | ||
|
||
def _fill_database(self, yaml_file): | ||
with open(yaml_file, 'r') as stream: | ||
try: | ||
self._database = yaml.safe_load(stream) | ||
logger.debug("audiofiles database read") | ||
except yaml.YAMLError as err: | ||
logger.error(f"Error occured while reading {yaml_file}: {err}") | ||
|
||
@plugin.tag | ||
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()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters