diff --git a/tubearchivist/api/src/search_processor.py b/tubearchivist/api/src/search_processor.py index 63218e4..d48c6e5 100644 --- a/tubearchivist/api/src/search_processor.py +++ b/tubearchivist/api/src/search_processor.py @@ -56,7 +56,7 @@ class SearchProcess: processed.update( { "_index": index, - "_score": round(result.get("_score", 0), 2), + "_score": round(result.get("_score") or 0, 2), } ) diff --git a/tubearchivist/home/templates/home/home.html b/tubearchivist/home/templates/home/home.html index 46721ee..ade51aa 100644 --- a/tubearchivist/home/templates/home/home.html +++ b/tubearchivist/home/templates/home/home.html @@ -9,14 +9,14 @@
{% for video in continue_vids %}
- +
- video-thumb - {% if video.source.player.progress %} -
+ video-thumb + {% if video.player.progress %} +
{% else %} -
+
{% endif %}
@@ -25,17 +25,17 @@
-
- {% if video.source.player.watched %} - seen-icon +
+ {% if video.player.watched %} + seen-icon {% else %} - unseen-icon + unseen-icon {% endif %} - {{ video.source.published }} | {{ video.source.player.duration_str }} + {{ video.published }} | {{ video.player.duration_str }}
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 24c10fa..06129d4 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -216,21 +216,20 @@ class ArchivistResultsView(ArchivistViewConfig): "query": {"bool": {"should": ids}}, "sort": [{"published": {"order": "desc"}}], } - search = SearchHandler( - "ta_video/_search", self.default_conf, data=data - ) - videos = search.get_data() + response, _ = ElasticWrap("ta_video/_search").get(data) + videos = SearchProcess(response).process() + if not videos: return False for video in videos: - youtube_id = video["source"]["youtube_id"] + youtube_id = video["youtube_id"] matched = [i for i in results if i["youtube_id"] == youtube_id] played_sec = matched[0]["position"] - total = video["source"]["player"]["duration"] + total = video["player"]["duration"] if not total: total = matched[0].get("position") * 2 - video["source"]["player"]["progress"] = 100 * (played_sec / total) + video["player"]["progress"] = 100 * (played_sec / total) return videos