mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
list all in progress videos
This commit is contained in:
parent
aff0cfb794
commit
f6950a2ca5
@ -9,14 +9,14 @@
|
||||
<div class="video-list {{ view_style }}">
|
||||
{% for video in continue_vids %}
|
||||
<div class="video-item {{ view_style }}">
|
||||
<a href="#player" data-id="{{ video.youtube_id }}" onclick="createPlayer(this)">
|
||||
<a href="#player" data-id="{{ video.source.youtube_id }}" onclick="createPlayer(this)">
|
||||
<div class="video-thumb-wrap {{ view_style }}">
|
||||
<div class="video-thumb">
|
||||
<img src="/cache/{{ video.vid_thumb_url }}" alt="video-thumb">
|
||||
{% if video.player.progress %}
|
||||
<div class="video-progress-bar" id="progress-{{ video.youtube_id }}" style="width: {{video.player.progress}}%;"></div>
|
||||
<img src="/cache/{{ video.source.vid_thumb_url }}" alt="video-thumb">
|
||||
{% if video.source.player.progress %}
|
||||
<div class="video-progress-bar" id="progress-{{ video.source.youtube_id }}" style="width: {{video.source.player.progress}}%;"></div>
|
||||
{% else %}
|
||||
<div class="video-progress-bar" id="progress-{{ video.youtube_id }}" style="width: 0%;"></div>
|
||||
<div class="video-progress-bar" id="progress-{{ video.source.youtube_id }}" style="width: 0%;"></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="video-play">
|
||||
@ -25,17 +25,17 @@
|
||||
</div>
|
||||
</a>
|
||||
<div class="video-desc {{ view_style }}">
|
||||
<div class="video-desc-player" id="video-info-{{ video.youtube_id }}">
|
||||
{% if video.player.watched %}
|
||||
<img src="{% static 'img/icon-seen.svg' %}" alt="seen-icon" data-id="{{ video.youtube_id }}" data-status="watched" onclick="updateVideoWatchStatus(this)" class="watch-button" title="Mark as unwatched">
|
||||
<div class="video-desc-player" id="video-info-{{ video.source.youtube_id }}">
|
||||
{% if video.source.player.watched %}
|
||||
<img src="{% static 'img/icon-seen.svg' %}" alt="seen-icon" data-id="{{ video.source.youtube_id }}" data-status="watched" onclick="updateVideoWatchStatus(this)" class="watch-button" title="Mark as unwatched">
|
||||
{% else %}
|
||||
<img src="{% static 'img/icon-unseen.svg' %}" alt="unseen-icon" data-id="{{ video.youtube_id }}" data-status="unwatched" onclick="updateVideoWatchStatus(this)" class="watch-button" title="Mark as watched">
|
||||
<img src="{% static 'img/icon-unseen.svg' %}" alt="unseen-icon" data-id="{{ video.source.youtube_id }}" data-status="unwatched" onclick="updateVideoWatchStatus(this)" class="watch-button" title="Mark as watched">
|
||||
{% endif %}
|
||||
<span>{{ video.published }} | {{ video.player.duration_str }}</span>
|
||||
<span>{{ video.source.published }} | {{ video.source.player.duration_str }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<a href="{% url 'channel_id' video.channel.channel_id %}"><h3>{{ video.channel.channel_name }}</h3></a>
|
||||
<a class="video-more" href="{% url 'video' video.youtube_id %}"><h2>{{ video.title }}</h2></a>
|
||||
<a href="{% url 'channel_id' video.source.channel.channel_id %}"><h3>{{ video.source.channel.channel_name }}</h3></a>
|
||||
<a class="video-more" href="{% url 'video' video.source.youtube_id %}"><h2>{{ video.source.title }}</h2></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -175,15 +175,35 @@ class ArchivistResultsView(ArchivistViewConfig):
|
||||
if not results or not self.context["results"]:
|
||||
return
|
||||
|
||||
self.context["continue_vids"] = []
|
||||
progress = {i["youtube_id"]: i["position"] for i in results}
|
||||
self.context["continue_vids"] = self.get_in_progress(results)
|
||||
|
||||
in_progress = {i["youtube_id"]: i["position"] for i in results}
|
||||
for hit in self.context["results"]:
|
||||
video = hit["source"]
|
||||
if video["youtube_id"] in progress:
|
||||
played_sec = progress.get(video["youtube_id"])
|
||||
if video["youtube_id"] in in_progress:
|
||||
played_sec = in_progress.get(video["youtube_id"])
|
||||
total = video["player"]["duration"]
|
||||
video["player"]["progress"] = 100 * (played_sec / total)
|
||||
self.context["continue_vids"].append(video)
|
||||
|
||||
def get_in_progress(self, results):
|
||||
"""get all videos in progress"""
|
||||
ids = [{"match": {"youtube_id": i.get("youtube_id")}} for i in results]
|
||||
data = {
|
||||
"size": self.default_conf["archive"]["page_size"],
|
||||
"query": {"bool": {"should": ids}},
|
||||
}
|
||||
search = SearchHandler(
|
||||
"ta_video/_search", self.default_conf, data=data
|
||||
)
|
||||
videos = search.get_data()
|
||||
for video in videos:
|
||||
youtube_id = video["source"]["youtube_id"]
|
||||
matched = [i for i in results if i["youtube_id"] == youtube_id]
|
||||
played_sec = matched[0]["position"]
|
||||
total = video["source"]["player"]["duration"]
|
||||
video["source"]["player"]["progress"] = 100 * (played_sec / total)
|
||||
|
||||
return videos
|
||||
|
||||
def single_lookup(self, es_path):
|
||||
"""retrieve a single item from url"""
|
||||
|
Loading…
Reference in New Issue
Block a user