diff --git a/tubearchivist/home/src/searching.py b/tubearchivist/home/src/searching.py index 14e8c5a..62fa65f 100644 --- a/tubearchivist/home/src/searching.py +++ b/tubearchivist/home/src/searching.py @@ -121,6 +121,12 @@ class SearchHandler: date_str = datetime.strftime(date_refresh, "%d %b, %Y") hit["source"]["vid_last_refresh"] = date_str + if "playlist_last_refresh" in hit_keys: + playlist_last_refresh = hit["source"]["playlist_last_refresh"] + date_refresh = datetime.fromtimestamp(playlist_last_refresh) + date_str = datetime.strftime(date_refresh, "%d %b, %Y") + hit["source"]["playlist_last_refresh"] = date_str + if "vid_thumb_url" in hit_keys: youtube_id = hit["source"]["youtube_id"] thumb_path = ThumbManager().vid_thumb_path(youtube_id) diff --git a/tubearchivist/home/templates/home/playlist.html b/tubearchivist/home/templates/home/playlist.html index 4125ae3..26450d3 100644 --- a/tubearchivist/home/templates/home/playlist.html +++ b/tubearchivist/home/templates/home/playlist.html @@ -57,11 +57,13 @@ {% for playlist in playlists %}
- {{ playlist.source.playlist_id }}-thumbnail + + {{ playlist.source.playlist_id }}-thumbnail +
-

{{ playlist.source.playlist_channel }}

-

{{ playlist.source.playlist_name }}

+

{{ playlist.source.playlist_channel }}

+

{{ playlist.source.playlist_name }}

{% endfor %} diff --git a/tubearchivist/home/templates/home/playlist_id.html b/tubearchivist/home/templates/home/playlist_id.html index 44b87d8..6274010 100644 --- a/tubearchivist/home/templates/home/playlist_id.html +++ b/tubearchivist/home/templates/home/playlist_id.html @@ -2,6 +2,9 @@ {% load static %} {% load humanize %} {% block content %} +
+

{{ playlist_info.playlist_name }}

+
@@ -18,7 +21,35 @@ {% endif %}
+
+
+

Last refreshed: {{ playlist_info.playlist_last_refresh }}

+

Subscribed: + {% if playlist_info.playlist_subscribed %} + + {% else %} + false + {% endif %} +

+
+
+
+
+ {% if max_hits %} +

Total Videos archived: {{ playlist_info.playlist_entries|length }}/{{ max_hits }}

+

Watched:

+ {% endif %} +
+
+{% if playlist_info.playlist_description %} +
+

Description:

+
+ {{ playlist_info.playlist_description|linebreaks }} +
+
+{% endif %}
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 9af0b7a..1b5e16d 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -601,18 +601,25 @@ class PlaylistIdView(View): search = SearchHandler(url, data) videos_hits = search.get_data() max_hits = search.max_hits + playlist_info = self.get_playlist_info( + playlist_id_detail, view_config["es_url"] + ) + playlist_name = playlist_info["playlist_name"] if max_hits: source = videos_hits[0]["source"] channel_info = source["channel"] - playlist_name = source["playlist"]["playlist_name"] pagination_handler.validate(max_hits) pagination = pagination_handler.pagination else: - channel_info = False + channel_info = self.get_channel_info( + playlist_info["playlist_channel_id"], view_config["es_url"] + ) + videos_hits = False pagination = False context = { + "playlist_info": playlist_info, "playlist_name": playlist_name, "channel_info": channel_info, "videos": videos_hits, @@ -664,12 +671,19 @@ class PlaylistIdView(View): def get_channel_info(channel_id_detail, es_url): """get channel info from channel index if no videos""" url = f"{es_url}/ta_channel/_doc/{channel_id_detail}" - data = False - search = SearchHandler(url, data) + search = SearchHandler(url, data=False) channel_data = search.get_data() channel_info = channel_data[0]["source"] - channel_name = channel_info["channel_name"] - return channel_info, channel_name + return channel_info + + @staticmethod + def get_playlist_info(playlist_id_detail, es_url): + """get playlist info header to no fail if playlist is empty""" + url = f"{es_url}/ta_playlist/_doc/{playlist_id_detail}" + search = SearchHandler(url, data=False) + playlist_data = search.get_data() + playlist_info = playlist_data[0]["source"] + return playlist_info class PlaylistView(View):