mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Implemented ''frequent'' and ''recent'' types of ''getAlbumList.view''
This commit is contained in:
parent
3ccafda24e
commit
3eee7416ea
@ -1,7 +1,7 @@
|
|||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
from flask import request
|
from flask import request
|
||||||
from sqlalchemy import desc
|
from sqlalchemy import desc, func
|
||||||
from sqlalchemy.orm import aliased
|
from sqlalchemy.orm import aliased
|
||||||
import random
|
import random
|
||||||
import uuid
|
import uuid
|
||||||
@ -64,9 +64,9 @@ def album_list():
|
|||||||
elif ltype == 'highest':
|
elif ltype == 'highest':
|
||||||
return request.error_formatter(0, 'Not implemented')
|
return request.error_formatter(0, 'Not implemented')
|
||||||
elif ltype == 'frequent':
|
elif ltype == 'frequent':
|
||||||
return request.error_formatter(0, 'Not implemented')
|
query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.sum(Track.play_count) / func.count(Folder.tracks)))
|
||||||
elif ltype == 'recent':
|
elif ltype == 'recent':
|
||||||
return request.error_formatter(0, 'Not implemented')
|
query = query.join(Track, Folder.tracks).group_by(Folder.id).order_by(desc(func.max(Track.last_play)))
|
||||||
elif ltype == 'starred':
|
elif ltype == 'starred':
|
||||||
return request.error_formatter(0, 'Not implemented')
|
return request.error_formatter(0, 'Not implemented')
|
||||||
elif ltype == 'alphabeticalByName':
|
elif ltype == 'alphabeticalByName':
|
||||||
|
@ -7,7 +7,7 @@ from time import time as now
|
|||||||
|
|
||||||
import config
|
import config
|
||||||
from web import app
|
from web import app
|
||||||
from db import Track, Folder, User
|
from db import Track, Folder, User, now, session
|
||||||
from api import get_entity
|
from api import get_entity
|
||||||
from lastfm import LastFm
|
from lastfm import LastFm
|
||||||
|
|
||||||
@ -33,6 +33,10 @@ def stream_media():
|
|||||||
# TODO transcode
|
# TODO transcode
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
res.play_count = res.play_count + 1
|
||||||
|
res.last_play = now()
|
||||||
|
session.commit()
|
||||||
|
|
||||||
if estimateContentLength == 'true':
|
if estimateContentLength == 'true':
|
||||||
return send_file(res.path), 200, { 'Content-Length': os.path.getsize(res.path) }
|
return send_file(res.path), 200, { 'Content-Length': os.path.getsize(res.path) }
|
||||||
|
|
||||||
|
3
db.py
3
db.py
@ -150,6 +150,9 @@ class Track(Base):
|
|||||||
created = Column(DateTime, default = now)
|
created = Column(DateTime, default = now)
|
||||||
last_modification = Column(Integer)
|
last_modification = Column(Integer)
|
||||||
|
|
||||||
|
play_count = Column(Integer, default = 0)
|
||||||
|
last_play = Column(DateTime, nullable = True)
|
||||||
|
|
||||||
root_folder_id = Column(UUID, ForeignKey('folder.id'))
|
root_folder_id = Column(UUID, ForeignKey('folder.id'))
|
||||||
root_folder = relationship('Folder', primaryjoin = Folder.id == root_folder_id)
|
root_folder = relationship('Folder', primaryjoin = Folder.id == root_folder_id)
|
||||||
folder_id = Column(UUID, ForeignKey('folder.id'))
|
folder_id = Column(UUID, ForeignKey('folder.id'))
|
||||||
|
Loading…
Reference in New Issue
Block a user