Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
engine
Commits
e161db7c
Commit
e161db7c
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Remove obsolte class. #43 #44
parent
462d707c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/core/state.py
+0
-120
0 additions, 120 deletions
modules/core/state.py
with
0 additions
and
120 deletions
modules/core/state.py
deleted
100644 → 0
+
0
−
120
View file @
462d707c
#
# Aura Engine (https://gitlab.servus.at/aura/engine)
#
# Copyright (C) 2017-2020 - The Aura Engine Team.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import
logging
from
collections
import
deque
from
modules.base.exceptions
import
NoActiveEntryException
from
modules.base.utils
import
SimpleUtil
as
SU
from
modules.core.resources
import
ResourceClass
,
ResourceUtil
class
PlayerStateService
:
"""
PlayerStateService keeps a short history of currently playing entries. It stores the recent
active entries to a local cache `entry_history` being able to manage concurrently playing entries.
It also is in charge of resolving relevant meta information of the currently playing entry for
the TrackService plugin.
"""
config
=
None
logger
=
None
entry_history
=
None
def
__init__
(
self
,
config
):
"""
Constructor
Args:
config (AuraConfig): Holds the engine configuration
"""
self
.
config
=
config
self
.
logger
=
logging
.
getLogger
(
"
AuraEngine
"
)
self
.
entry_history
=
deque
([
None
,
None
,
None
])
#
# PUBLIC METHODS
#
def
add_to_history
(
self
,
entries
):
"""
Saves the currently pre-rolled [`Entry`] to the local cache.
"""
self
.
entry_history
.
pop
()
self
.
entry_history
.
appendleft
(
entries
)
def
get_recent_entries
(
self
):
"""
Retrieves the currently playing [`Entry`] from the local cache.
"""
return
self
.
entry_history
[
0
]
def
resolve_entry
(
self
,
source
):
"""
Retrieves the `PlaylistEntry` matching the provied source URI.
Args:
source (String): The URI of the source playing
Raises:
(NoActiveEntryException)
"""
result
=
None
entries
=
self
.
get_recent_entries
()
if
not
entries
:
raise
NoActiveEntryException
for
entry
in
entries
:
entry_source
=
entry
.
source
if
entry
.
get_content_type
()
in
ResourceClass
.
FILE
.
types
:
base_dir
=
self
.
config
.
get
(
"
audio_source_folder
"
)
extension
=
self
.
config
.
get
(
"
audio_source_extension
"
)
entry_source
=
ResourceUtil
.
uri_to_filepath
(
base_dir
,
entry
.
source
,
extension
)
if
entry_source
==
source
:
self
.
logger
.
info
(
"
Resolved
'
%s
'
entry
'
%s
'
for URI
'
%s
'"
%
(
entry
.
get_content_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
):
"""
Prints all recents entries of the history.
"""
msg
=
"
Active entry history:
\n
"
for
entries
in
self
.
entry_history
:
msg
+=
"
[
"
for
e
in
entries
:
msg
+=
"
\n
"
+
str
(
e
)
msg
+=
"
]
"
self
.
logger
.
info
(
msg
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment