formatting
This commit is contained in:
parent
3bd83f0462
commit
5620b9caa2
1 changed files with 33 additions and 30 deletions
|
@ -1,5 +1,6 @@
|
||||||
'''
|
'''
|
||||||
Reccomendation Engine Example
|
Recommendation Engine Example
|
||||||
|
1 Nov 2017, 0x2620
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
@ -8,35 +9,6 @@ import random
|
||||||
|
|
||||||
import ox
|
import ox
|
||||||
|
|
||||||
class Pandora:
|
|
||||||
|
|
||||||
def __init__(self, url, username, password):
|
|
||||||
self.api = ox.API(url)
|
|
||||||
self.api.signin(username=username, password=password)
|
|
||||||
|
|
||||||
def find_annotations(self, query, keys):
|
|
||||||
# print('FIND ANNOTATIONS', query, keys)
|
|
||||||
return self.api.findAnnotations({
|
|
||||||
'keys': keys,
|
|
||||||
'query': query,
|
|
||||||
'range': [0, 1000000]
|
|
||||||
})['data']['items']
|
|
||||||
|
|
||||||
def find_entities(self, query, keys):
|
|
||||||
# print('FIND ENTITIES', query, keys)
|
|
||||||
return self.api.findEntities({
|
|
||||||
'keys': keys,
|
|
||||||
'query': query,
|
|
||||||
'range': [0, 1000000]
|
|
||||||
})['data']['items']
|
|
||||||
|
|
||||||
def get(self, id, keys):
|
|
||||||
# print('GET', id, keys)
|
|
||||||
return self.api.get({
|
|
||||||
'id': id,
|
|
||||||
'keys': keys
|
|
||||||
})['data']
|
|
||||||
|
|
||||||
class Engine:
|
class Engine:
|
||||||
|
|
||||||
def __init__(self, path):
|
def __init__(self, path):
|
||||||
|
@ -143,6 +115,37 @@ class Engine:
|
||||||
with open(os.path.join(self.path, 'playlists.json'), 'w') as f:
|
with open(os.path.join(self.path, 'playlists.json'), 'w') as f:
|
||||||
f.write(json.dumps(self.playlists, indent=4, sort_keys=True))
|
f.write(json.dumps(self.playlists, indent=4, sort_keys=True))
|
||||||
|
|
||||||
|
|
||||||
|
class Pandora:
|
||||||
|
|
||||||
|
def __init__(self, url, username, password):
|
||||||
|
self.api = ox.API(url)
|
||||||
|
self.api.signin(username=username, password=password)
|
||||||
|
|
||||||
|
def find_annotations(self, query, keys):
|
||||||
|
# print('FIND ANNOTATIONS', query, keys)
|
||||||
|
return self.api.findAnnotations({
|
||||||
|
'keys': keys,
|
||||||
|
'query': query,
|
||||||
|
'range': [0, 1000000]
|
||||||
|
})['data']['items']
|
||||||
|
|
||||||
|
def find_entities(self, query, keys):
|
||||||
|
# print('FIND ENTITIES', query, keys)
|
||||||
|
return self.api.findEntities({
|
||||||
|
'keys': keys,
|
||||||
|
'query': query,
|
||||||
|
'range': [0, 1000000]
|
||||||
|
})['data']['items']
|
||||||
|
|
||||||
|
def get(self, id, keys):
|
||||||
|
# print('GET', id, keys)
|
||||||
|
return self.api.get({
|
||||||
|
'id': id,
|
||||||
|
'keys': keys
|
||||||
|
})['data']
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
engine = Engine('json')
|
engine = Engine('json')
|
||||||
engine.update()
|
engine.update()
|
||||||
|
|
Loading…
Reference in a new issue