This commit is contained in:
rlx 2017-11-01 16:08:17 +00:00
parent 1ad3740677
commit 6ef42c9fee

34
re.py
View file

@ -46,7 +46,22 @@ class Pandora:
'keys': keys 'keys': keys
})['data'] })['data']
def get_playlists(): class Engine:
def __init__(self):
pass
def _shift_clips(clips):
index = random.randrange(len(clips))
return clips[index:] + clips[:index - 1]
def get_videos(user):
products = []
for event in user['events']:
if 'product' in event['data']:
products.append(event['data']['product'])
def update(self):
# Get all storylines with tags # Get all storylines with tags
storylines = [{ storylines = [{
'name': entity['name'], 'name': entity['name'],
@ -83,7 +98,6 @@ def get_playlists():
with open(filename, 'w') as f: with open(filename, 'w') as f:
f.write(json.dumps(videos, indent=4, sort_keys=True)) f.write(json.dumps(videos, indent=4, sort_keys=True))
order = {video['id']: video['order'] for video in videos} order = {video['id']: video['order'] for video in videos}
print(order)
# Sort clips # Sort clips
clips = sorted( clips = sorted(
clips, clips,
@ -100,20 +114,10 @@ def get_playlists():
] ]
} for storyline in storylines] if playlist['clips']] } for storyline in storylines] if playlist['clips']]
def get_videos(user):
products = []
for event in user['events']:
if 'product' in event['data']:
products.append(event['data']['product'])
def shift_clips(clips):
index = random.randrange(len(clips))
return clips[index:] + clips[:index - 1]
if __name__ == '__main__': if __name__ == '__main__':
pandora = Pandora() pandora = Pandora()
playlists = get_playlists() engine = Engine()
with open('playlists.json', 'w') as f: playlists = engine.update()
with open('json/playlists.json', 'w') as f:
f.write(json.dumps(playlists, indent=4, sort_keys=True)) f.write(json.dumps(playlists, indent=4, sort_keys=True))
print(len(playlists), 'playlists')