Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
django-panik-nonstop
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
radiopanik
django-panik-nonstop
Commits
d2d1bd61
Commit
d2d1bd61
authored
Mar 04, 2015
by
fred
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add utility function to get currently playing track
parent
0497e624
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
nonstop/utils.py
nonstop/utils.py
+30
-0
No files found.
nonstop/utils.py
0 → 100644
View file @
d2d1bd61
import
datetime
from
.models
import
Track
,
SomaLogLine
def
get_current_nonstop_track
():
try
:
soma_log_line
=
SomaLogLine
.
objects
.
select_related
().
order_by
(
'-play_timestamp'
)[
0
]
except
IndexError
:
# nothing yet
return
{}
if
soma_log_line
.
play_timestamp
<
(
datetime
.
datetime
.
now
()
-
datetime
.
timedelta
(
hours
=
1
)):
# last known line is way too old
return
{}
if
not
soma_log_line
.
on_air
:
# nonstop should be on air but it's not :/
return
{}
d
=
{}
current_nonstop_file
=
soma_log_line
.
filepath
if
not
'Tranches/'
in
current_nonstop_file
.
filepath
:
# nonstop is playing but it's not a nonstop track :/
return
{}
current_track
=
soma_log_line
.
filepath
.
track
if
current_track
is
None
:
# nonstop is playing a nonstop track, but it's unknown :/
return
{}
d
=
{
'track_title'
:
current_track
.
title
}
if
current_track
.
artist
:
d
[
'track_artist'
]
=
current_track
.
artist
.
name
return
d
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment