Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
aura-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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Lars Kruse
aura-engine
Commits
f32c72ed
Commit
f32c72ed
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Common model attribute for files and streams.
parent
ace669ae
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/database/model.py
+7
-7
7 additions, 7 deletions
modules/database/model.py
modules/scheduling/calendar.py
+25
-11
25 additions, 11 deletions
modules/scheduling/calendar.py
modules/scheduling/fallback_manager.py
+1
-1
1 addition, 1 deletion
modules/scheduling/fallback_manager.py
with
33 additions
and
19 deletions
modules/database/model.py
+
7
−
7
View file @
f32c72ed
...
@@ -419,7 +419,7 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
...
@@ -419,7 +419,7 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
uri
=
Column
(
String
(
1024
))
uri
=
Column
(
String
(
1024
))
duration
=
Column
(
BigInteger
)
duration
=
Column
(
BigInteger
)
filenam
e
=
Column
(
String
(
1024
))
sourc
e
=
Column
(
String
(
1024
))
entry_start
=
Column
(
DateTime
)
entry_start
=
Column
(
DateTime
)
queue_state
=
None
# Assigned when entry is about to be queued
queue_state
=
None
# Assigned when entry is about to be queued
channel
=
None
# Assigned when entry is actually played
channel
=
None
# Assigned when entry is actually played
...
@@ -510,8 +510,8 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
...
@@ -510,8 +510,8 @@ class PlaylistEntry(DB.Model, AuraDatabaseModel):
"""
"""
time_start
=
SimpleUtil
.
fmt_time
(
self
.
start_unix
)
time_start
=
SimpleUtil
.
fmt_time
(
self
.
start_unix
)
time_end
=
SimpleUtil
.
fmt_time
(
self
.
end_unix
)
time_end
=
SimpleUtil
.
fmt_time
(
self
.
end_unix
)
track
=
self
.
filenam
e
[
-
25
:]
track
=
self
.
sourc
e
[
-
25
:]
return
"
PlaylistEntry #%s [%s - %s | %ssec |
Track
: ...%s]
"
%
(
str
(
self
.
artificial_id
),
time_start
,
time_end
,
self
.
duration
,
track
)
return
"
PlaylistEntry #%s [%s - %s | %ssec |
Source
: ...%s]
"
%
(
str
(
self
.
artificial_id
),
time_start
,
time_end
,
self
.
duration
,
track
)
...
@@ -715,7 +715,7 @@ class SingleEntry(DB.Model, AuraDatabaseModel):
...
@@ -715,7 +715,7 @@ class SingleEntry(DB.Model, AuraDatabaseModel):
# Data
# Data
uri
=
Column
(
String
(
1024
))
uri
=
Column
(
String
(
1024
))
duration
=
Column
(
BigInteger
)
duration
=
Column
(
BigInteger
)
filenam
e
=
Column
(
String
(
1024
))
sourc
e
=
Column
(
String
(
1024
))
entry_start
=
Column
(
DateTime
)
entry_start
=
Column
(
DateTime
)
...
@@ -771,8 +771,8 @@ class SingleEntry(DB.Model, AuraDatabaseModel):
...
@@ -771,8 +771,8 @@ class SingleEntry(DB.Model, AuraDatabaseModel):
"""
"""
time_start
=
SimpleUtil
.
fmt_time
(
self
.
start_unix
)
time_start
=
SimpleUtil
.
fmt_time
(
self
.
start_unix
)
time_end
=
SimpleUtil
.
fmt_time
(
self
.
end_unix
)
time_end
=
SimpleUtil
.
fmt_time
(
self
.
end_unix
)
track
=
self
.
filenam
e
[
-
25
:]
track
=
self
.
sourc
e
[
-
25
:]
return
"
SingleEntry #%s [%s - %s | %ssec |
Track
: ...%s]
"
%
(
str
(
self
.
id
),
time_start
,
time_end
,
self
.
duration
,
track
)
return
"
SingleEntry #%s [%s - %s | %ssec |
Source
: ...%s]
"
%
(
str
(
self
.
id
),
time_start
,
time_end
,
self
.
duration
,
track
)
...
@@ -895,7 +895,7 @@ class SingleEntryMetaData(DB.Model, AuraDatabaseModel):
...
@@ -895,7 +895,7 @@ class SingleEntryMetaData(DB.Model, AuraDatabaseModel):
#
#
# uri = Column(String(1024))
# uri = Column(String(1024))
#
#
#
filenam
e = ""
#
sourc
e = ""
# cleansource = ""
# cleansource = ""
# cleanprotocol = ""
# cleanprotocol = ""
# type = None
# type = None
...
...
This diff is collapsed.
Click to expand it.
modules/scheduling/calendar.py
+
25
−
11
View file @
f32c72ed
...
@@ -34,6 +34,7 @@ import logging
...
@@ -34,6 +34,7 @@ import logging
from
mutagen.flac
import
FLAC
from
mutagen.flac
import
FLAC
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
modules.base.utils
import
SimpleUtil
from
modules.database.model
import
Schedule
,
Playlist
,
PlaylistEntry
,
PlaylistEntryMetaData
from
modules.database.model
import
Schedule
,
Playlist
,
PlaylistEntry
,
PlaylistEntryMetaData
from
modules.communication.redis.messenger
import
RedisMessenger
from
modules.communication.redis.messenger
import
RedisMessenger
from
modules.scheduling.calender_fetcher
import
CalendarFetcher
from
modules.scheduling.calender_fetcher
import
CalendarFetcher
...
@@ -230,13 +231,13 @@ class AuraCalendarService(threading.Thread):
...
@@ -230,13 +231,13 @@ class AuraCalendarService(threading.Thread):
playlist_db
.
store
(
havetoadd
,
commit
=
True
)
playlist_db
.
store
(
havetoadd
,
commit
=
True
)
if
playlist_db
.
entry_count
>
0
:
if
playlist_db
.
entry_count
>
0
:
self
.
store_playlist_entries
(
playlist_db
,
fetched_playlist
)
self
.
store_playlist_entries
(
schedule_db
,
playlist_db
,
fetched_playlist
)
return
playlist_db
return
playlist_db
def
store_playlist_entries
(
self
,
playlist_db
,
fetched_playlist
):
def
store_playlist_entries
(
self
,
schedule_db
,
playlist_db
,
fetched_playlist
):
"""
"""
Stores the playlist entries to the database.
Stores the playlist entries to the database.
"""
"""
...
@@ -250,19 +251,32 @@ class AuraCalendarService(threading.Thread):
...
@@ -250,19 +251,32 @@ class AuraCalendarService(threading.Thread):
entry_db
=
PlaylistEntry
()
entry_db
=
PlaylistEntry
()
havetoadd
=
True
havetoadd
=
True
# Nano-seconds to seconds
duration
=
int
(
float
(
entry
[
"
file
"
][
"
duration
"
])
/
1000000000
)
entry_db
.
duration
=
duration
entry_db
.
entry_start
=
datetime
.
fromtimestamp
(
time_marker
)
entry_db
.
entry_start
=
datetime
.
fromtimestamp
(
time_marker
)
entry_db
.
artificial_playlist_id
=
playlist_db
.
artificial_id
entry_db
.
artificial_playlist_id
=
playlist_db
.
artificial_id
entry_db
.
entry_num
=
entry_num
entry_db
.
entry_num
=
entry_num
entry_db
.
uri
=
entry
[
"
uri
"
]
entry_db
.
filename
=
entry
[
"
filename
"
]
if
"
file
"
in
entry
and
duration
in
entry
[
"
file
"
]:
# Convert nano-seconds to seconds
duration
=
int
(
float
(
entry
[
"
file
"
][
"
duration
"
])
/
1000000000
)
# except Exception:
else
:
# No duration means it's playing until the end of the schedule
self
.
logger
.
debug
(
"
Missing duration - setting duration of entry to end-of-schedule
"
)
duration
=
SimpleUtil
.
timestamp
(
schedule_db
.
schedule_end
)
-
time_marker
entry_db
.
duration
=
duration
if
"
uri
"
in
entry
:
# FIXME Refactor mix of uri/filename/file/source
entry_db
.
uri
=
entry
[
"
uri
"
]
entry_db
.
source
=
entry
[
"
uri
"
]
if
"
filename
"
in
entry
:
entry_db
.
source
=
entry
[
"
filename
"
]
entry_db
.
store
(
havetoadd
,
commit
=
True
)
entry_db
.
store
(
havetoadd
,
commit
=
True
)
self
.
store_playlist_entry_metadata
(
entry_db
,
entry
[
"
file
"
][
"
metadata
"
])
if
"
file
"
in
entry
:
self
.
store_playlist_entry_metadata
(
entry_db
,
entry
[
"
file
"
][
"
metadata
"
])
entry_num
=
entry_num
+
1
entry_num
=
entry_num
+
1
time_marker
+=
duration
time_marker
+=
duration
...
@@ -282,7 +296,7 @@ class AuraCalendarService(threading.Thread):
...
@@ -282,7 +296,7 @@ class AuraCalendarService(threading.Thread):
metadata_db
.
artificial_entry_id
=
entry_db
.
artificial_id
metadata_db
.
artificial_entry_id
=
entry_db
.
artificial_id
if
"
artist
"
not
in
metadata
:
if
"
artist
"
not
in
metadata
:
self
.
logger
.
warning
(
"
Artist not found in metadata for track
'
%s
'
. Setting to
''"
%
entry_db
.
filenam
e
)
self
.
logger
.
warning
(
"
Artist not found in metadata for track
'
%s
'
. Setting to
''"
%
entry_db
.
sourc
e
)
metadata_db
.
artist
=
""
metadata_db
.
artist
=
""
else
:
else
:
metadata_db
.
artist
=
metadata
[
"
artist
"
]
metadata_db
.
artist
=
metadata
[
"
artist
"
]
...
@@ -291,7 +305,7 @@ class AuraCalendarService(threading.Thread):
...
@@ -291,7 +305,7 @@ class AuraCalendarService(threading.Thread):
metadata_db
.
album
=
metadata
[
"
album
"
]
metadata_db
.
album
=
metadata
[
"
album
"
]
if
"
artist
"
not
in
metadata
:
if
"
artist
"
not
in
metadata
:
self
.
logger
.
warning
(
"
Title not found in metadata for track
'
%s
'
. Setting to
'
n/a
'"
%
entry_db
.
filenam
e
)
self
.
logger
.
warning
(
"
Title not found in metadata for track
'
%s
'
. Setting to
'
n/a
'"
%
entry_db
.
sourc
e
)
metadata_db
.
artist
=
"
n/a
"
metadata_db
.
artist
=
"
n/a
"
else
:
else
:
metadata_db
.
artist
=
metadata
[
"
artist
"
]
metadata_db
.
artist
=
metadata
[
"
artist
"
]
...
...
This diff is collapsed.
Click to expand it.
modules/scheduling/fallback_manager.py
+
1
−
1
View file @
f32c72ed
...
@@ -213,7 +213,7 @@ class FallbackManager:
...
@@ -213,7 +213,7 @@ class FallbackManager:
playlist
=
playlist
[
0
]
playlist
=
playlist
[
0
]
if
playlist
and
playlist
.
entries
:
if
playlist
and
playlist
.
entries
:
for
entry
in
playlist
.
entries
:
for
entry
in
playlist
.
entries
:
playlist_files
+=
entry
.
filenam
e
+
"
\n
"
playlist_files
+=
entry
.
sourc
e
+
"
\n
"
return
playlist_files
return
playlist_files
...
...
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