diff --git a/fetch.py b/fetch.py index 778b335..5ad385c 100644 --- a/fetch.py +++ b/fetch.py @@ -72,7 +72,7 @@ for channel in Channel.select(): else: artist = "" title = song["title"] - if channel.shortname == "fm4" and "|" in artist: - artist = artist.split("|")[0] + if channel.shortname == "fm4" and "|" in title: + title = title.split("|")[0] add_entry(time, artist, title) diff --git a/server.py b/server.py index 0526260..e7c78a2 100644 --- a/server.py +++ b/server.py @@ -1,4 +1,4 @@ -from flask import jsonify +from flask import jsonify, request from playhouse.shortcuts import model_to_dict from app import app @@ -41,6 +41,9 @@ def popular(channel): .join(Channel).switch(Play).join(Song) \ .where((Song.show == 0) & (Channel.shortname == channel)) \ .group_by(Play.song).order_by(SQL('count').desc()) + if request.args.get('offset'): + print(request.args.get('offset')) + get = get.offset(int(request.args.get('offset'))) return query_to_response(get, extra_attrs=["count"], exclude=[Play.channel, Play.time, Play.id])