updated parameters and comments

This commit is contained in:
pythagoraswitch 2018-09-26 20:24:37 +02:00
parent 59d2152758
commit acb9b499be
1 changed files with 12 additions and 15 deletions

View File

@ -85,8 +85,8 @@ class Engine:
clips[inpoint['index']]['out'] = self.pandora.get(video_id, ['duration'])['duration']
return clips
def get_videos(self, user):
def get_videos(self, user):
if user.get('events', [{}])[0].get("event")=="login":
return self.get_recommendations(user)
@ -97,8 +97,6 @@ class Engine:
# check if there were grid events for all indexes.
grid_events = {}
(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
# for event in user.get('events', []):
@ -181,7 +179,6 @@ class Engine:
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 = []):
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()}
@ -246,14 +243,14 @@ class Engine:
} for video in videos]
# Output: playlists with updated in/out time of clips that have been watched.
# Watched is defined as a video being played in full screen.
# "watch_cutoff" parameter: the portion of the clip duration to be determined as watched the whole clip. should be [0,1]
# + check (play, pause) pairs and eliminate unusual cases most likely due to a bug.
# + If (play, pause) pairs exceed XX(80-90?) percent of the clip length, eliminate the clip from the playlist.
# + Otherwise, find the last pause position of a clip and record it as "in" position of the clip.
# + If the clips are all eliminated from a playlist, eliminate the playlist.
def update_user_playlists(playlists, user, watch_cutoff = 0.8):
def update_user_playlists(playlists, user, watch_cutoff = 0.9):
# Output: playlists with updated in/out time of clips that have been watched.
# Watched is defined as a video being played in full screen.
# "watch_cutoff" parameter: the portion of the clip duration to be determined as watched the whole clip. should be [0,1]
# + check (play, pause) pairs and eliminate unusual cases most likely due to a bug.
# + If (play, pause) pairs exceed XX(80-90?) percent of the clip length, eliminate the clip from the playlist.
# + Otherwise, find the last pause position of a clip and record it as "in" position of the clip.
# + If the clips are all eliminated from a playlist, eliminate the playlist.
play = {}
watched = []
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"]
for playlist in playlists:
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:
# 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.
# i.e. clip in/out may be edited (before after edit inconsistency); skip may trigger jump to a wrong clip (bug)
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 +/- 15secs buffer. There were newer edits of clip positions with 12 seconds difference.
# 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"]):
watched.append((playlist["name"],i))
else: