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):
|
if os.path.exists(filename):
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
self.playlists = json.load(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:
|
else:
|
||||||
self.playlists = []
|
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.
|
# + If clips are all marked as "pass" in a playlist, elliminate the playlist from the user playlists.
|
||||||
playlists = copy.deepcopy(self.playlists)
|
playlists = copy.deepcopy(self.playlists)
|
||||||
play = {}
|
play = {}
|
||||||
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
|
||||||
# The current max time of a clip duration is 10379.383333377269 from "DDLaunch: Erik Verlinde, Gravity as an emergent force (1956)"
|
# 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"
|
# 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"]
|
cutoff_pos = (playlist["clips"][i]["out"]-playlist["clips"][i]["orig_in"])*watch_cutoff + playlist["clips"][i]["orig_in"]
|
||||||
|
|
||||||
if event["data"]["position"] >= cutoff_pos:
|
if event["data"]["position"] >= cutoff_pos:
|
||||||
watched.append((playlist["name"],i))
|
playlist["clips"][i]["pass"] = True
|
||||||
playlist["clips"][i].get("pass",False) == True
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if "orig_in" not in playlist["clips"][i]:
|
if "orig_in" not in playlist["clips"][i]:
|
||||||
|
@ -318,15 +320,14 @@ class Engine:
|
||||||
break
|
break
|
||||||
play = {}
|
play = {}
|
||||||
|
|
||||||
d_watched = defaultdict(set)
|
for playlist in playlists.copy():
|
||||||
for k, v in watched:
|
unwatched = [clip for clip in playlist["clips"] if not clip.get("pass")]
|
||||||
d_watched[k].add(v)
|
if not unwatched:
|
||||||
for k, v in d_watched.items():
|
playlists.remove(playlist)
|
||||||
for playlist in playlists:
|
# If the number of playlists is reduced to 30, reset it to the original.
|
||||||
if playlist["name"] == k:
|
if len(playlists) < 30:
|
||||||
if len(v) == len(playlist["clips"]):
|
playlists = copy.deepcopy(self.playlists)
|
||||||
playlists.remove(playlist)
|
|
||||||
break
|
|
||||||
return(playlists)
|
return(playlists)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue