updated parameters and comments

This commit is contained in:
pythagoraswitch 2018-09-26 20:24:37 +02:00
parent 59d2152758
commit acb9b499be

View file

@ -85,8 +85,8 @@ class Engine:
clips[inpoint['index']]['out'] = self.pandora.get(video_id, ['duration'])['duration'] clips[inpoint['index']]['out'] = self.pandora.get(video_id, ['duration'])['duration']
return clips return clips
def get_videos(self, user):
def get_videos(self, user):
if user.get('events', [{}])[0].get("event")=="login": if user.get('events', [{}])[0].get("event")=="login":
return self.get_recommendations(user) return self.get_recommendations(user)
@ -97,8 +97,6 @@ class Engine:
# check if there were grid events for all indexes. # check if there were grid events for all indexes.
grid_events = {} grid_events = {}
(nc, np, ns) = (grid_change.get("nextClip"), grid_change.get("nextPlaylist"), grid_change.get("staySame")) (nc, np, ns) = (grid_change.get("nextClip"), grid_change.get("nextPlaylist"), grid_change.get("staySame"))
# this assumes np + nc + ns = total number of videos in the grid view (16).
# Make sure sanity check exists in front-end (error if it does not add up to 16).
video_num = nc + np + ns video_num = nc + np + ns
# for event in user.get('events', []): # for event in user.get('events', []):
@ -181,7 +179,6 @@ class Engine:
return [e[1] for e in rec_list] return [e[1] for e in rec_list]
# Current assumption: Avoid the same playlist in the grid view. In the future, the same playlist could be played in the grid view as long as these are differenct clips or separate times?
def get_recommendations(self, user, vids_exclude = []): def get_recommendations(self, user, vids_exclude = []):
channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()} channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()}
sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()} sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()}
@ -246,14 +243,14 @@ class Engine:
} for video in videos] } for video in videos]
# Output: playlists with updated in/out time of clips that have been watched. def update_user_playlists(playlists, user, watch_cutoff = 0.9):
# Watched is defined as a video being played in full screen. # Output: playlists with updated in/out time of clips that have been watched.
# "watch_cutoff" parameter: the portion of the clip duration to be determined as watched the whole clip. should be [0,1] # Watched is defined as a video being played in full screen.
# + check (play, pause) pairs and eliminate unusual cases most likely due to a bug. # "watch_cutoff" parameter: the portion of the clip duration to be determined as watched the whole clip. should be [0,1]
# + If (play, pause) pairs exceed XX(80-90?) percent of the clip length, eliminate the clip from the playlist. # + check (play, pause) pairs and eliminate unusual cases most likely due to a bug.
# + Otherwise, find the last pause position of a clip and record it as "in" position of the clip. # + If (play, pause) pairs exceed XX(80-90?) percent of the clip length, eliminate the clip from the playlist.
# + If the clips are all eliminated from a playlist, eliminate the playlist. # + Otherwise, find the last pause position of a clip and record it as "in" position of the clip.
def update_user_playlists(playlists, user, watch_cutoff = 0.8): # + If the clips are all eliminated from a playlist, eliminate the playlist.
play = {} play = {}
watched = [] watched = []
clip_max_dur = 10800 # = 3 hours; arbitrary max duration allowed for (pause time - play time) to detect outlier/bugs clip_max_dur = 10800 # = 3 hours; arbitrary max duration allowed for (pause time - play time) to detect outlier/bugs
@ -270,9 +267,9 @@ class Engine:
i = event["data"]["playlistPosition"] i = event["data"]["playlistPosition"]
for playlist in playlists: for playlist in playlists:
if playlist["name"] == event["data"]["playlist"] and i < len(playlist["clips"]): if playlist["name"] == event["data"]["playlist"] and i < len(playlist["clips"]):
if play["data"]["position"] >= max(playlist["clips"][i]["in"] - 30, 0) and event["data"]["position"] <= playlist["clips"][i]["out"] + 30: if play["data"]["position"] >= max(playlist["clips"][i]["in"] - 15, 0) and event["data"]["position"] <= playlist["clips"][i]["out"] + 15:
# This assumes the (play, pause) fits inside the clip's (in, out) segment with +/- 30secs buffer. Check if there are instances where this might not be the case. # This assumes the (play, pause) fits inside the clip's (in, out) segment with +/- 15secs buffer. There were newer edits of clip positions with 12 seconds difference.
# i.e. clip in/out may be edited (before after edit inconsistency); skip may trigger jump to a wrong clip (bug) # instances where this might not be the case: clip in/out may be largely edited (before after edit inconsistency); skip may trigger jump to a wrong clip (bug)
if event["data"]["position"] >= ((playlist["clips"][i]["out"]-playlist["clips"][i]["in"])*watch_cutoff + playlist["clips"][i]["in"]): if event["data"]["position"] >= ((playlist["clips"][i]["out"]-playlist["clips"][i]["in"])*watch_cutoff + playlist["clips"][i]["in"]):
watched.append((playlist["name"],i)) watched.append((playlist["name"],i))
else: else: