2019-10-07 12:21:26 +01:00
|
|
|
from flask import Blueprint, jsonify
|
|
|
|
from datetime import date
|
|
|
|
import logging
|
|
|
|
|
2022-08-08 22:02:14 +01:00
|
|
|
from music.api.decorators import login_or_jwt, lastfm_username_required
|
2019-10-07 12:21:26 +01:00
|
|
|
|
2019-10-19 17:14:11 +01:00
|
|
|
import music.db.database as database
|
2019-10-07 12:21:26 +01:00
|
|
|
|
|
|
|
blueprint = Blueprint('fm-api', __name__)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route('/today', methods=['GET'])
|
2022-08-08 22:02:14 +01:00
|
|
|
@login_or_jwt
|
2019-10-07 12:21:26 +01:00
|
|
|
@lastfm_username_required
|
2022-08-08 22:02:14 +01:00
|
|
|
def daily_scrobbles(auth=None, user=None):
|
2019-10-07 12:21:26 +01:00
|
|
|
|
2020-04-30 14:54:05 +01:00
|
|
|
net = database.get_authed_lastfm_network(user)
|
2019-10-07 12:21:26 +01:00
|
|
|
|
2020-08-12 09:30:26 +01:00
|
|
|
total = net.count_scrobbles_from_date(input_date=date.today())
|
2019-10-07 12:21:26 +01:00
|
|
|
|
|
|
|
return jsonify({
|
|
|
|
'username': net.username,
|
|
|
|
'scrobbles_today': total
|
|
|
|
}), 200
|