diff --git a/tubearchivist/home/templates/home/home.html b/tubearchivist/home/templates/home/home.html index 62d2e9a..6cf643a 100644 --- a/tubearchivist/home/templates/home/home.html +++ b/tubearchivist/home/templates/home/home.html @@ -49,6 +49,9 @@
video-thumb + {% if video.source.player.progress %} +
+ {% endif %}
play-icon diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 660ec73..131b78f 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -169,6 +169,17 @@ class ArchivistResultsView(ArchivistViewConfig): } 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): """retrieve a single item from url""" search = SearchHandler(es_path, config=self.default_conf) @@ -212,6 +223,7 @@ class HomeView(ArchivistResultsView): self.initiate_vars(request) self._update_view_data() self.find_results() + self.match_progress() return render(request, "home/home.html", self.context) diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 53a8882..10b219b 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -391,8 +391,17 @@ button:hover { 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 { width: 100%; + position: relative; } .video-play img {