migrated to uri id base
This commit is contained in:
parent
0cc962cf0d
commit
dfeb1555c8
@ -114,7 +114,7 @@ def playlist():
|
||||
if len(playlist_references) == 0 and request_json.get('playlist_references', None) != -1:
|
||||
playlist_references = None
|
||||
|
||||
playlist_id = request_json.get('id', None)
|
||||
playlist_uri = request_json.get('uri', None)
|
||||
playlist_shuffle = request_json.get('shuffle', None)
|
||||
playlist_type = request_json.get('type', None)
|
||||
|
||||
@ -143,14 +143,14 @@ def playlist():
|
||||
'playlist_references': playlist_references if playlist_references is not None else [],
|
||||
'include_recommendations': playlist_recommendation if playlist_recommendation is not None else False,
|
||||
'recommendation_sample': playlist_recommendation_sample if playlist_recommendation_sample is not None else 10,
|
||||
'playlist_id': None,
|
||||
'uri': None,
|
||||
'shuffle': playlist_shuffle if playlist_shuffle is not None else False,
|
||||
'type': playlist_type if playlist_type is not None else 'default'
|
||||
}
|
||||
|
||||
if user_ref.get().to_dict()['spotify_linked']:
|
||||
new_playlist_id = create_playlist(session['username'], playlist_name)
|
||||
to_add['playlist_id'] = new_playlist_id
|
||||
new_playlist = create_playlist(session['username'], playlist_name)
|
||||
to_add['uri'] = str(new_playlist.uri)
|
||||
|
||||
if playlist_type == 'recents':
|
||||
to_add['day_boundary'] = playlist_day_boundary if playlist_day_boundary is not None else 21
|
||||
@ -186,8 +186,8 @@ def playlist():
|
||||
else:
|
||||
dic['playlist_references'] = playlist_references
|
||||
|
||||
if playlist_id is not None:
|
||||
dic['playlist_id'] = playlist_id
|
||||
if playlist_uri is not None:
|
||||
dic['uri'] = playlist_uri
|
||||
|
||||
if playlist_shuffle is not None:
|
||||
dic['shuffle'] = playlist_shuffle
|
||||
@ -580,7 +580,7 @@ def execute_user(username):
|
||||
|
||||
for iterate_playlist in playlists:
|
||||
if len(iterate_playlist['parts']) > 0 or len(iterate_playlist['playlist_references']) > 0:
|
||||
if iterate_playlist.get('playlist_id', None):
|
||||
if iterate_playlist.get('uri', None):
|
||||
|
||||
if os.environ.get('DEPLOY_DESTINATION', None) == 'PROD':
|
||||
create_run_user_playlist_task(username, iterate_playlist['name'], seconds_delay)
|
||||
|
@ -26,10 +26,10 @@ def create_playlist(username, name):
|
||||
user_dict['refresh_token'],
|
||||
user_dict['access_token']))
|
||||
|
||||
resp = net.create_playlist(net.user.username, name)
|
||||
playlist = net.create_playlist(net.user.username, name)
|
||||
|
||||
if resp and resp.get('id', None):
|
||||
return resp['id']
|
||||
if playlist is not None:
|
||||
return playlist
|
||||
else:
|
||||
logger.error(f'no response received {username} / {name}')
|
||||
return None
|
||||
|
@ -81,7 +81,7 @@ def play_user_playlist(username,
|
||||
submit_parts = [i for i in {j for j in submit_parts}]
|
||||
|
||||
if playlist_type == 'recents':
|
||||
boundary_date = datetime.datetime.now() - datetime.timedelta(days=int(day_boundary))
|
||||
boundary_date = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=int(day_boundary))
|
||||
tracks = engine.get_recent_playlist(boundary_date,
|
||||
submit_parts,
|
||||
processors,
|
||||
|
@ -8,6 +8,8 @@ from spotframework.engine.processor.shuffle import Shuffle
|
||||
from spotframework.engine.processor.sort import SortReleaseDate
|
||||
from spotframework.engine.processor.deduplicate import DeduplicateByID
|
||||
|
||||
from spotframework.model.uri import Uri
|
||||
|
||||
from spotframework.net.network import Network
|
||||
from spotframework.net.user import NetworkUser
|
||||
import spotify.db.database as database
|
||||
@ -36,7 +38,7 @@ def run_user_playlist(username, playlist_name):
|
||||
|
||||
playlist_dict = playlists[0].to_dict()
|
||||
|
||||
if playlist_dict['playlist_id'] is None:
|
||||
if playlist_dict['uri'] is None:
|
||||
logger.critical(f'no playlist id to populate ({username}/{playlist_name})')
|
||||
return None
|
||||
|
||||
@ -65,7 +67,8 @@ def run_user_playlist(username, playlist_name):
|
||||
submit_parts = part_generator.get_recursive_parts(playlist_dict['name'])
|
||||
|
||||
if playlist_dict['type'] == 'recents':
|
||||
boundary_date = datetime.datetime.now() - datetime.timedelta(days=int(playlist_dict['day_boundary']))
|
||||
boundary_date = datetime.datetime.now(datetime.timezone.utc) - \
|
||||
datetime.timedelta(days=int(playlist_dict['day_boundary']))
|
||||
tracks = engine.get_recent_playlist(boundary_date,
|
||||
submit_parts,
|
||||
processors,
|
||||
@ -79,13 +82,13 @@ def run_user_playlist(username, playlist_name):
|
||||
include_recommendations=playlist_dict['include_recommendations'],
|
||||
recommendation_limit=int(playlist_dict['recommendation_sample']))
|
||||
|
||||
engine.execute_playlist(tracks, playlist_dict['playlist_id'])
|
||||
engine.execute_playlist(tracks, Uri(playlist_dict['uri']))
|
||||
|
||||
overwrite = playlist_dict.get('description_overwrite', None)
|
||||
suffix = playlist_dict.get('description_suffix', None)
|
||||
|
||||
engine.change_description(sorted(submit_parts),
|
||||
playlist_dict['playlist_id'],
|
||||
uri=Uri(playlist_dict['uri']),
|
||||
overwrite=overwrite,
|
||||
suffix=suffix)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user