mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
fix playlist nav builder using correct index
This commit is contained in:
parent
f26fbc0dc5
commit
3efdc1962d
@ -261,6 +261,17 @@ class YoutubeChannel:
|
|||||||
|
|
||||||
return all_entries
|
return all_entries
|
||||||
|
|
||||||
|
def get_indexed_playlists(self):
|
||||||
|
"""get all indexed playlists from channel"""
|
||||||
|
data = {
|
||||||
|
"query": {
|
||||||
|
"term": {"playlist_channel_id": {"value": self.channel_id}}
|
||||||
|
},
|
||||||
|
"sort": [{"playlist_channel.keyword": {"order": "desc"}}],
|
||||||
|
}
|
||||||
|
all_playlists = IndexPaginate("ta_playlist", data).get_results()
|
||||||
|
return all_playlists
|
||||||
|
|
||||||
|
|
||||||
class YoutubeVideo:
|
class YoutubeVideo:
|
||||||
"""represents a single youtube video"""
|
"""represents a single youtube video"""
|
||||||
@ -586,26 +597,26 @@ class YoutubePlaylist:
|
|||||||
if not current or not len(all_entries) > 1:
|
if not current or not len(all_entries) > 1:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
current_idx = current[0]["idx"]
|
current_idx = all_entries.index(current[0])
|
||||||
if current_idx == 0:
|
if current_idx == 0:
|
||||||
|
next_item = False
|
||||||
|
else:
|
||||||
|
next_item = all_entries[current_idx - 1]
|
||||||
|
next_thumb = ThumbManager().vid_thumb_path(next_item["youtube_id"])
|
||||||
|
next_item["vid_thumb"] = next_thumb
|
||||||
|
|
||||||
|
if current_idx == len(all_entries) - 1:
|
||||||
previous_item = False
|
previous_item = False
|
||||||
else:
|
else:
|
||||||
previous_item = all_entries[current_idx - 1]
|
previous_item = all_entries[current_idx + 1]
|
||||||
prev_thumb = ThumbManager().vid_thumb_path(
|
prev_thumb = ThumbManager().vid_thumb_path(
|
||||||
previous_item["youtube_id"]
|
previous_item["youtube_id"]
|
||||||
)
|
)
|
||||||
previous_item["vid_thumb"] = prev_thumb
|
previous_item["vid_thumb"] = prev_thumb
|
||||||
|
|
||||||
if current_idx == len(all_entries) - 1:
|
|
||||||
next_item = False
|
|
||||||
else:
|
|
||||||
next_item = all_entries[current_idx + 1]
|
|
||||||
next_thumb = ThumbManager().vid_thumb_path(next_item["youtube_id"])
|
|
||||||
next_item["vid_thumb"] = next_thumb
|
|
||||||
|
|
||||||
nav = {
|
nav = {
|
||||||
"playlist_meta": {
|
"playlist_meta": {
|
||||||
"current_idx": current_idx,
|
"current_idx": current[0]["idx"],
|
||||||
"playlist_id": self.playlist_id,
|
"playlist_id": self.playlist_id,
|
||||||
"playlist_name": self.playlist_dict["playlist_name"],
|
"playlist_name": self.playlist_dict["playlist_name"],
|
||||||
"playlist_channel": self.playlist_dict["playlist_channel"],
|
"playlist_channel": self.playlist_dict["playlist_channel"],
|
||||||
|
Loading…
Reference in New Issue
Block a user