From c003065419e6b428a3b033be9068dae9d0f4dbfb Mon Sep 17 00:00:00 2001 From: aj Date: Thu, 5 Sep 2019 11:42:35 +0100 Subject: [PATCH] added playlist printing, model props, added popularity sorting --- requirements.txt | 10 +++++----- spotify/api/api.py | 11 ----------- spotify/tasks/play_user_playlist.py | 7 ++----- spotify/tasks/run_user_playlist.py | 6 ++---- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5901ee9..5b1f009 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,21 +8,21 @@ google-auth==1.6.3 google-cloud-core==1.0.3 google-cloud-firestore==1.4.0 google-cloud-logging==1.12.1 -google-cloud-pubsub==0.45.0 -google-cloud-tasks==1.2.0 +google-cloud-tasks==1.2.1 googleapis-common-protos==1.6.0 grpc-google-iam-v1==0.12.3 -grpcio==1.22.0 +grpcio==1.23.0 idna==2.8 itsdangerous==1.1.0 Jinja2==2.10.1 MarkupSafe==1.1.1 protobuf==3.9.1 -pyasn1==0.4.6 +pyasn1==0.4.7 pyasn1-modules==0.2.6 pytz==2019.2 requests==2.22.0 rsa==4.0 six==1.12.0 +tabulate==0.8.3 urllib3==1.25.3 -Werkzeug==0.15.5 +Werkzeug==0.15.6 diff --git a/spotify/api/api.py b/spotify/api/api.py index 15f6571..66d7f7b 100644 --- a/spotify/api/api.py +++ b/spotify/api/api.py @@ -6,7 +6,6 @@ import json import logging from google.cloud import firestore -from google.cloud import pubsub_v1 from google.cloud import tasks_v2 from google.protobuf import timestamp_pb2 from werkzeug.security import check_password_hash, generate_password_hash @@ -18,11 +17,9 @@ import spotify.db.database as database blueprint = Blueprint('api', __name__) db = firestore.Client() -publisher = pubsub_v1.PublisherClient() tasker = tasks_v2.CloudTasksClient() task_path = tasker.queue_path('sarsooxyz', 'europe-west2', 'spotify-executions') -run_playlist_topic_path = publisher.topic_path('sarsooxyz', 'run_user_playlist') logger = logging.getLogger(__name__) @@ -660,11 +657,3 @@ def create_play_user_playlist_task(username, task['schedule_time'] = timestamp tasker.create_task(task_path, task) - - -def push_run_user_playlist_message(username, name): - - data = u'{}'.format(name) - data = data.encode('utf-8') - - publisher.publish(run_playlist_topic_path, data=data, username=username) diff --git a/spotify/tasks/play_user_playlist.py b/spotify/tasks/play_user_playlist.py index 1c254a6..9a3b3b0 100644 --- a/spotify/tasks/play_user_playlist.py +++ b/spotify/tasks/play_user_playlist.py @@ -5,19 +5,16 @@ import logging from spotframework.engine.playlistengine import PlaylistEngine from spotframework.engine.filter.shuffle import Shuffle -from spotframework.engine.filter.sort import SortReverseReleaseDate +from spotframework.engine.filter.sort import SortReleaseDate from spotframework.engine.filter.deduplicate import DeduplicateByID from spotframework.net.network import Network from spotframework.net.user import NetworkUser - import spotify.db.database as database from spotify.db.part_generator import PartGenerator db = firestore.Client() -captured_playlists = [] - logger = logging.getLogger(__name__) @@ -69,7 +66,7 @@ def play_user_playlist(username, if shuffle: processors.append(Shuffle()) else: - processors.append(SortReverseReleaseDate()) + processors.append(SortReleaseDate(reverse=True)) submit_parts = parts diff --git a/spotify/tasks/run_user_playlist.py b/spotify/tasks/run_user_playlist.py index fbc6729..966611b 100644 --- a/spotify/tasks/run_user_playlist.py +++ b/spotify/tasks/run_user_playlist.py @@ -5,7 +5,7 @@ import logging from spotframework.engine.playlistengine import PlaylistEngine from spotframework.engine.filter.shuffle import Shuffle -from spotframework.engine.filter.sort import SortReverseReleaseDate +from spotframework.engine.filter.sort import SortReleaseDate from spotframework.engine.filter.deduplicate import DeduplicateByID from spotframework.net.network import Network @@ -15,8 +15,6 @@ from spotify.db.part_generator import PartGenerator db = firestore.Client() -captured_playlists = [] - logger = logging.getLogger(__name__) @@ -61,7 +59,7 @@ def run_user_playlist(username, playlist_name): if playlist_dict['shuffle'] is True: processors.append(Shuffle()) else: - processors.append(SortReverseReleaseDate()) + processors.append(SortReleaseDate(reverse=True)) part_generator = PartGenerator(user_id=users[0].id) submit_parts = part_generator.get_recursive_parts(playlist_dict['name'])