bug fixes
This commit is contained in:
parent
21781747a2
commit
001e377003
1 changed files with 13 additions and 12 deletions
|
@ -33,6 +33,10 @@ class Engine:
|
|||
if os.path.exists(filename):
|
||||
with open(filename) as f:
|
||||
self.playlists = json.load(f)
|
||||
# ## the following is for testing purpose.
|
||||
# for playlist in self.playlists:
|
||||
# for clip in playlist["clips"]:
|
||||
# clip["pass"] = bool(random.getrandbits(1))
|
||||
else:
|
||||
self.playlists = []
|
||||
|
||||
|
@ -281,7 +285,6 @@ class Engine:
|
|||
# + If clips are all marked as "pass" in a playlist, elliminate the playlist from the user playlists.
|
||||
playlists = copy.deepcopy(self.playlists)
|
||||
play = {}
|
||||
watched = []
|
||||
clip_max_dur = 10800 # = 3 hours; arbitrary max duration allowed for (pause time - play time) to detect outlier/bugs
|
||||
# The current max time of a clip duration is 10379.383333377269 from "DDLaunch: Erik Verlinde, Gravity as an emergent force (1956)"
|
||||
# A user could potentially spend more than 3 hours if they keep watching after the clip enters into the subsequent "scene"
|
||||
|
@ -306,8 +309,7 @@ class Engine:
|
|||
cutoff_pos = (playlist["clips"][i]["out"]-playlist["clips"][i]["orig_in"])*watch_cutoff + playlist["clips"][i]["orig_in"]
|
||||
|
||||
if event["data"]["position"] >= cutoff_pos:
|
||||
watched.append((playlist["name"],i))
|
||||
playlist["clips"][i].get("pass",False) == True
|
||||
playlist["clips"][i]["pass"] = True
|
||||
|
||||
else:
|
||||
if "orig_in" not in playlist["clips"][i]:
|
||||
|
@ -318,15 +320,14 @@ class Engine:
|
|||
break
|
||||
play = {}
|
||||
|
||||
d_watched = defaultdict(set)
|
||||
for k, v in watched:
|
||||
d_watched[k].add(v)
|
||||
for k, v in d_watched.items():
|
||||
for playlist in playlists:
|
||||
if playlist["name"] == k:
|
||||
if len(v) == len(playlist["clips"]):
|
||||
playlists.remove(playlist)
|
||||
break
|
||||
for playlist in playlists.copy():
|
||||
unwatched = [clip for clip in playlist["clips"] if not clip.get("pass")]
|
||||
if not unwatched:
|
||||
playlists.remove(playlist)
|
||||
# If the number of playlists is reduced to 30, reset it to the original.
|
||||
if len(playlists) < 30:
|
||||
playlists = copy.deepcopy(self.playlists)
|
||||
|
||||
return(playlists)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue