diff --git a/tubearchivist/api/src/search_processor.py b/tubearchivist/api/src/search_processor.py index d48c6e5..7c9d28e 100644 --- a/tubearchivist/api/src/search_processor.py +++ b/tubearchivist/api/src/search_processor.py @@ -39,7 +39,7 @@ class SearchProcess: def _process_result(self, result): """detect which type of data to process""" index = result["_index"] - processed = {} + processed = False if index == "ta_video": processed = self._process_video(result["_source"]) if index == "ta_channel": @@ -53,12 +53,13 @@ class SearchProcess: if index == "ta_subtitle": processed = self._process_subtitle(result) - processed.update( - { - "_index": index, - "_score": round(result.get("_score") or 0, 2), - } - ) + if isinstance(processed, dict): + processed.update( + { + "_index": index, + "_score": round(result.get("_score") or 0, 2), + } + ) return processed diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 06129d4..40c3f52 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -892,8 +892,9 @@ class VideoView(MinView): def get(self, request, video_id): """get single video""" config_handler = AppConfig(request.user.id) - look_up = SearchHandler(f"ta_video/_doc/{video_id}", config=False) - video_data = look_up.get_data()[0]["source"] + response, _ = ElasticWrap(f"ta_video/_doc/{video_id}").get() + video_data = SearchProcess(response).process() + try: rating = video_data["stats"]["average_rating"] video_data["stats"]["average_rating"] = self.star_creator(rating)