Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djrandom-py-deleted-112
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This project is pending deletion, and will be deleted on
2025-06-14
. Repository and other project resources are read-only.
Show more breadcrumbs
ale
djrandom-py-deleted-112
Commits
1fba61a2
Commit
1fba61a2
authored
13 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
add a play log
parent
b9be3109
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/djrandom/frontend/frontend.py
+7
-1
7 additions, 1 deletion
server/djrandom/frontend/frontend.py
server/djrandom/model/mp3.py
+9
-0
9 additions, 0 deletions
server/djrandom/model/mp3.py
with
16 additions
and
1 deletion
server/djrandom/frontend/frontend.py
+
7
−
1
View file @
1fba61a2
...
@@ -6,7 +6,8 @@ from flask import Flask, request, Response, abort, jsonify, \
...
@@ -6,7 +6,8 @@ from flask import Flask, request, Response, abort, jsonify, \
render_template
,
session
render_template
,
session
from
djrandom
import
daemonize
from
djrandom
import
daemonize
from
djrandom
import
utils
from
djrandom
import
utils
from
djrandom.model.mp3
import
MP3
from
djrandom.model.mp3
import
MP3
,
PlayLog
form
djrandom
.
model
.
playlist
import
Playlist
from
djrandom.database
import
Session
,
init_db
from
djrandom.database
import
Session
,
init_db
from
djrandom.frontend
import
search
from
djrandom.frontend
import
search
from
sqlalchemy
import
distinct
from
sqlalchemy
import
distinct
...
@@ -80,10 +81,15 @@ def play_callback(sha1):
...
@@ -80,10 +81,15 @@ def play_callback(sha1):
mp3
=
MP3
.
query
.
get
(
sha1
)
mp3
=
MP3
.
query
.
get
(
sha1
)
if
not
mp3
:
if
not
mp3
:
abort
(
404
)
abort
(
404
)
# Increase play count.
if
mp3
.
play_count
:
if
mp3
.
play_count
:
mp3
.
play_count
+=
1
mp3
.
play_count
+=
1
else
:
else
:
mp3
.
play_count
=
1
mp3
.
play_count
=
1
# Add a playlog entry.
plog
=
PlayLog
(
sha1
=
sha1
,
userid
=
session
[
'
userid
'
],
stamp
=
datetime
.
now
())
Session
.
add
(
plog
)
Session
.
add
(
mp3
)
Session
.
add
(
mp3
)
Session
.
commit
()
Session
.
commit
()
return
jsonify
(
status
=
True
)
return
jsonify
(
status
=
True
)
...
...
This diff is collapsed.
Click to expand it.
server/djrandom/model/mp3.py
+
9
−
0
View file @
1fba61a2
...
@@ -54,3 +54,12 @@ class MP3(Base):
...
@@ -54,3 +54,12 @@ class MP3(Base):
'
album
'
:
self
.
album
,
'
album
'
:
self
.
album
,
'
genre
'
:
self
.
genre
,
'
genre
'
:
self
.
genre
,
'
sha1
'
:
self
.
sha1
}
'
sha1
'
:
self
.
sha1
}
class
PlayLog
(
Base
):
__tablename__
=
'
playlog
'
sha1
=
Column
(
String
(
40
))
userid
=
Column
(
String
(
40
),
index
=
True
)
stamp
=
Column
(
DateTime
())
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