adjusted to the variable 'pass' for nextClip and staySame cases in get_videos

This commit is contained in:
pythagoraswitch 2018-11-19 22:24:41 +01:00
parent 4c2cb60d9c
commit 21781747a2

View file

@ -147,25 +147,41 @@ class Engine:
stay_same_index = video_indx[nc+np:] stay_same_index = video_indx[nc+np:]
rec_list = [] rec_list = []
# select next clip for nextClip pool except when the playlist has only one clip.
# Make sure the playlist exists for staySame pool; otherwise add it to nextPlaylist pool.
for i in stay_same_index:
if prev_grid_list[i].get("playlist") not in [playlist["name"] for playlist in playlists]:
next_playlist_index.append(stay_same_index)
# select next clip for nextClip pool except when the playlist has only one clip. It skips the clip with "pass":True when selecting the next clip.
for i in next_clip_index: for i in next_clip_index:
if prev_grid_list[i].get('playlist') is None: if prev_grid_list[i].get("playlist") not in [playlist["name"] for playlist in playlists]:
# add this to deal with the absence of "playlist" data in old grid event. # add this to deal with the absence of "playlist" data in old grid event or the case where the playlist has been eliminated.
# If there's no playlist data recorded, add the nextClip pool to nextPlaylist pool.
next_playlist_index.append(next_clip_index) next_playlist_index.append(next_clip_index)
break break
else: else:
for playlist in playlists: for playlist in playlists:
if playlist.get('name')== prev_grid_list[i].get('playlist'): if playlist.get('name')== prev_grid_list[i].get('playlist'):
unwatched_clips_indx = [j for j in range(len(playlist["clips"])) if playlist["clips"][j].get("pass",False)!=True]
if len(playlist["clips"]) == 1: if len(playlist["clips"]) == 1:
next_playlist_index.append(i) next_playlist_index.append(i)
break break
# Discuss how this behavour should be: should it switch to a new playlist if it is the end of the playlist clip sequence already? # Discuss how this behavour should be: should it switch to a new playlist if it is the end of the playlist clip sequence already?
elif prev_grid_list[i].get('playlistPosition', 0) + 1 == len(playlist['clips']): elif prev_grid_list[i].get('playlistPosition', 0) + 1 == len(playlist['clips']):
playlist_pos = 0 if unwatched_clips_indx[0] != prev_grid_list[i]['playlistPosition']:
playlist_pos = unwatched_clips_indx[0]
else:
next_playlist_index.append(i)
else: else:
playlist_pos = prev_grid_list[i].get('playlistPosition', 0) + 1 if len([j for j in unwatched_clips_indx if j > prev_grid_list[i]['playlistPosition']]) == 0:
if unwatched_clips_indx[0] != prev_grid_list[i]['playlistPosition']:
playlist_pos = unwatched_clips_indx[0]
else:
next_playlist_index.append(i)
else:
playlist_pos = [j for j in unwatched_clips_indx if j > prev_grid_list[i]['playlistPosition']][0]
rec_list.append((i, { rec_list.append((i, {
'clips': playlist['clips'], 'clips': playlist['clips'],
# 'position': random.randrange(len(playlist['clips'])), # 'position': random.randrange(len(playlist['clips'])),