Skip to content
Snippets Groups Projects
Commit 72812a16 authored by David Trattnig's avatar David Trattnig
Browse files

Resolve entry by URI.

parent 501db575
No related branches found
No related tags found
No related merge requests found
......@@ -21,8 +21,8 @@ import logging
from collections import deque
from modules.base.exceptions import NoActiveEntryException
from modules.base.utils import SimpleUtil, EngineUtil
from modules.base.utils import SimpleUtil as SU, EngineUtil
from modules.core.channels import ChannelType
......@@ -73,45 +73,36 @@ class PlayerStateService:
return self.entry_history[0]
def entry_for_source(self, source):
def resolve_entry(self, source):
"""
Retrieves the `PlaylistEntry` matching the provied source URI.
"""
# TODO Implement
def store_trackservice_entry(self, filepath):
"""
Stores the entry identified by the given source in the Track Service.
Args:
filepath (String): The path of the currently playing file
source (String): The URI of the source playing
Raises:
(NoActiveEntryException): In case currently nothing is playing
(NoActiveEntryException)
"""
found = False
# entries = self.get_recent_entries()
# if not entries:
# raise NoActiveEntryException
# for active_entry in entries:
# base_dir = self.config.get("audiofolder")
# if EngineUtil.uri_to_filepath(base_dir, active_entry.source) == filepath:
# trackservice = TrackService(active_entry)
# trackservice.store(add=True, commit=True)
# active_entry.trackservice_id = trackservice.id
# active_entry.store(add=False, commit=True)
# self.logger.info("Stored active entry '%s' to TrackService as '%s'" % (active_entry, trackservice))
# found = True
# if not found:
# msg = "Found no entry in the recent history which matches the given source '%s'" % (filepath)
# self.logger.critical(SimpleUtil.red(msg))
result = None
entries = self.get_recent_entries()
if not entries:
raise NoActiveEntryException
for entry in entries:
entry_source = entry.source
if entry.channel in ChannelType.FILESYSTEM.channels:
base_dir = self.config.get("audiofolder")
entry_source = EngineUtil.uri_to_filepath(base_dir, entry.source)
if entry_source == source:
self.logger.info("Resolved '%s' entry '%s' for URI '%s'" % (entry.get_type(), entry, source))
result = entry
break
if not result:
msg = "Found no entry in the recent history which matches the given source '%s'" % (source)
self.logger.critical(SU.red(msg))
return result
def print_entry_history(self):
......
......@@ -32,6 +32,7 @@ def do_meta_filesystem(meta) =
filename = meta["filename"]
# artist = meta["artist"]
# title = meta["title"]
# print('CALLING GURU #{list.assoc(default="", "install_dir", ini)}/guru.py')
system('#{list.assoc(default="", "install_dir", ini)}/guru.py --on_play "#{filename}" &')
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment