Compare commits
2 commits
c3fb943cc4
...
bb579f2f6f
| Author | SHA1 | Date | |
|---|---|---|---|
| bb579f2f6f | |||
| 1735ae79f7 |
1 changed files with 18 additions and 4 deletions
|
|
@ -107,15 +107,15 @@ class Engine:
|
||||||
)
|
)
|
||||||
videos += playlists[:channels['globalKeywords']]
|
videos += playlists[:channels['globalKeywords']]
|
||||||
playlists = playlists[channels['globalKeywords']:]
|
playlists = playlists[channels['globalKeywords']:]
|
||||||
# Count tags for the user
|
# Count products the user has seen
|
||||||
count = defaultdict(lambda: 0)
|
count = defaultdict(lambda: 0)
|
||||||
for event in user.get('events', []):
|
for event in user.get('events', []):
|
||||||
if event.get('data', {}).get('product'):
|
if event.get('data', {}).get('product'):
|
||||||
count[event['data']['product']] += 1
|
count[event['data']['product']] += 1
|
||||||
# For each tag in playlist, increment score by count
|
# For each product in playlist tags, increment score by count
|
||||||
for playlist in playlists:
|
for playlist in playlists:
|
||||||
score[playlist['name']] = random.random()
|
score[playlist['name']] = random.random()
|
||||||
for tag in [tag for tag in playlist['tags'] if tag not in sliders]:
|
for tag in set(playlist['tags']) & set(count):
|
||||||
score[playlist['name']] += count[tag]
|
score[playlist['name']] += count[tag]
|
||||||
# Select highest scoring playlists
|
# Select highest scoring playlists
|
||||||
videos += sorted(
|
videos += sorted(
|
||||||
|
|
@ -164,13 +164,19 @@ class Engine:
|
||||||
}, ['id', 'name', 'tags', 'nodename']) if entity.get('tags', []) and entity.get('nodename')]
|
}, ['id', 'name', 'tags', 'nodename']) if entity.get('tags', []) and entity.get('nodename')]
|
||||||
# Get list of storyline names
|
# Get list of storyline names
|
||||||
names = list(set([storyline['name'] for storyline in storylines]))
|
names = list(set([storyline['name'] for storyline in storylines]))
|
||||||
|
# Get list of items to use in DD
|
||||||
|
items = [item['id'] for item in self.pandora.find({
|
||||||
|
'conditions': [
|
||||||
|
{'key': 'list', 'operator': '==', 'value': 'dau:DD'}
|
||||||
|
]
|
||||||
|
}, ['id'])]
|
||||||
# Get all clips annotated with storyline references
|
# Get all clips annotated with storyline references
|
||||||
clips = [clip for clip in self.pandora.find_annotations({
|
clips = [clip for clip in self.pandora.find_annotations({
|
||||||
'conditions': [
|
'conditions': [
|
||||||
{'key': 'layer', 'operator': '==', 'value': 'storylines'}
|
{'key': 'layer', 'operator': '==', 'value': 'storylines'}
|
||||||
],
|
],
|
||||||
'operator': '&'
|
'operator': '&'
|
||||||
}, ['id', 'in', 'out', 'value']) if clip['value'] in names]
|
}, ['id', 'in', 'out', 'value']) if clip['value'] in names and clip['id'].split('/')[0] in items]
|
||||||
# Get list of ids for videos with clips
|
# Get list of ids for videos with clips
|
||||||
ids = list(set([clip['id'].split('/')[0] for clip in clips]))
|
ids = list(set([clip['id'].split('/')[0] for clip in clips]))
|
||||||
# Get and cache video data
|
# Get and cache video data
|
||||||
|
|
@ -242,6 +248,14 @@ class Pandora:
|
||||||
self.api = ox.API(url)
|
self.api = ox.API(url)
|
||||||
self.api.signin(username=username, password=password)
|
self.api.signin(username=username, password=password)
|
||||||
|
|
||||||
|
def find(self, query, keys):
|
||||||
|
# print('FIND', query, keys)
|
||||||
|
return self.api.find({
|
||||||
|
'keys': keys,
|
||||||
|
'query': query,
|
||||||
|
'range': [0, 1000000]
|
||||||
|
})['data']['items']
|
||||||
|
|
||||||
def find_annotations(self, query, keys):
|
def find_annotations(self, query, keys):
|
||||||
# print('FIND ANNOTATIONS', query, keys)
|
# print('FIND ANNOTATIONS', query, keys)
|
||||||
return self.api.findAnnotations({
|
return self.api.findAnnotations({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue