mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
add video progress bar
This commit is contained in:
parent
6078d8d276
commit
d88d6d6a61
@ -49,6 +49,9 @@
|
|||||||
<div class="video-thumb-wrap {{ view_style }}">
|
<div class="video-thumb-wrap {{ view_style }}">
|
||||||
<div class="video-thumb">
|
<div class="video-thumb">
|
||||||
<img src="/cache/{{ video.source.vid_thumb_url }}" alt="video-thumb">
|
<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>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="video-play">
|
<div class="video-play">
|
||||||
<img src="{% static 'img/icon-play.svg' %}" alt="play-icon">
|
<img src="{% static 'img/icon-play.svg' %}" alt="play-icon">
|
||||||
|
@ -169,6 +169,17 @@ class ArchivistResultsView(ArchivistViewConfig):
|
|||||||
}
|
}
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
|
def match_progress(self):
|
||||||
|
"""add video progress to result context"""
|
||||||
|
results = RedisArchivist().list_items(f"{self.user_id}:progress:")
|
||||||
|
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"])
|
||||||
|
total = video["player"]["duration"]
|
||||||
|
video["player"]["progress"] = 100 * (played_sec / total)
|
||||||
|
|
||||||
def single_lookup(self, es_path):
|
def single_lookup(self, es_path):
|
||||||
"""retrieve a single item from url"""
|
"""retrieve a single item from url"""
|
||||||
search = SearchHandler(es_path, config=self.default_conf)
|
search = SearchHandler(es_path, config=self.default_conf)
|
||||||
@ -212,6 +223,7 @@ class HomeView(ArchivistResultsView):
|
|||||||
self.initiate_vars(request)
|
self.initiate_vars(request)
|
||||||
self._update_view_data()
|
self._update_view_data()
|
||||||
self.find_results()
|
self.find_results()
|
||||||
|
self.match_progress()
|
||||||
|
|
||||||
return render(request, "home/home.html", self.context)
|
return render(request, "home/home.html", self.context)
|
||||||
|
|
||||||
|
@ -391,8 +391,17 @@ button:hover {
|
|||||||
grid-template-columns: 25% auto;
|
grid-template-columns: 25% auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-progress-bar {
|
||||||
|
position: absolute;
|
||||||
|
background-color: var(--accent-font-light);
|
||||||
|
height: 7px;
|
||||||
|
left: 0;
|
||||||
|
bottom: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
.video-thumb img {
|
.video-thumb img {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.video-play img {
|
.video-play img {
|
||||||
|
Loading…
Reference in New Issue
Block a user