mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
add methods to get recently played items
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
from flask import Blueprint
|
||||
from flask_restful import Api
|
||||
|
||||
from .recents import RecentlyAdded
|
||||
from .recents import RecentlyAdded, RecentlyPlayed
|
||||
|
||||
api_bp = Blueprint("home", __name__, url_prefix="/home")
|
||||
api = Api(api_bp)
|
||||
|
||||
|
||||
api.add_resource(RecentlyAdded, "/recents/added")
|
||||
api.add_resource(RecentlyPlayed, "/recents/played")
|
||||
|
||||
+10
-1
@@ -1,6 +1,7 @@
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from app.lib.home.recents import get_recent_items
|
||||
from app.lib.home.recentlyadded import get_recent_items
|
||||
from app.lib.home.recentlyplayed import get_recently_played
|
||||
|
||||
parser = reqparse.RequestParser()
|
||||
|
||||
@@ -15,3 +16,11 @@ class RecentlyAdded(Resource):
|
||||
limit = args["limit"]
|
||||
|
||||
return {"items": get_recent_items(cutoff, limit), "cutoff": cutoff}
|
||||
|
||||
|
||||
class RecentlyPlayed(Resource):
|
||||
def get(self):
|
||||
args = parser.parse_args()
|
||||
limit = args["limit"]
|
||||
|
||||
return {"items": get_recently_played(limit)}
|
||||
|
||||
Reference in New Issue
Block a user