mirror of
https://github.com/tubearchivist/tubearchivist.git
synced 2024-12-21 09:20:12 +00:00
extend playlist_id with metadata and links
This commit is contained in:
parent
94576b4b76
commit
b1c82759bb
@ -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)
|
||||
|
@ -57,11 +57,13 @@
|
||||
{% for playlist in playlists %}
|
||||
<div class="playlist-item {{ view_style }}">
|
||||
<div class="playlist-thumbnail">
|
||||
<img src="/cache/playlists/{{ playlist.source.playlist_id }}.jpg" alt="{{ playlist.source.playlist_id }}-thumbnail">
|
||||
<a href="{% url 'playlist_id' playlist.source.playlist_id %}">
|
||||
<img src="/cache/playlists/{{ playlist.source.playlist_id }}.jpg" alt="{{ playlist.source.playlist_id }}-thumbnail">
|
||||
</a>
|
||||
</div>
|
||||
<div class="playlist-desc {{ view_style }}">
|
||||
<h3>{{ playlist.source.playlist_channel }}</h3>
|
||||
<h2>{{ playlist.source.playlist_name }}</h2>
|
||||
<a href="{% url 'channel_id' playlist.source.playlist_channel_id %}"><h3>{{ playlist.source.playlist_channel }}</h3></a>
|
||||
<a href="{% url 'playlist_id' playlist.source.playlist_id %}"><h2>{{ playlist.source.playlist_name }}</h2></a>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
@ -2,6 +2,9 @@
|
||||
{% load static %}
|
||||
{% load humanize %}
|
||||
{% block content %}
|
||||
<div class="title-bar">
|
||||
<h1>{{ playlist_info.playlist_name }}</h1>
|
||||
</div>
|
||||
<div class="info-box info-box-3">
|
||||
<div class="info-box-item">
|
||||
<div class="round-img">
|
||||
@ -18,7 +21,35 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-box-item">
|
||||
<div>
|
||||
<p>Last refreshed: {{ playlist_info.playlist_last_refresh }}</p>
|
||||
<p>Subscribed:
|
||||
{% if playlist_info.playlist_subscribed %}
|
||||
<button type="button" id="{{ playlist_info.playlist_id }}" onclick="unsubscribe(this.id)" title="Unsubscribe from {{ playlist_info.playlist_name }}">Unsubscribe</button>
|
||||
{% else %}
|
||||
false
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-box-item">
|
||||
<div>
|
||||
{% if max_hits %}
|
||||
<p>Total Videos archived: {{ playlist_info.playlist_entries|length }}/{{ max_hits }}</p>
|
||||
<p>Watched: <button title="Mark all videos from {{ playlist_info.playlist_name }} as watched" type="button" id="{{ playlist_info.playlist_id }}" onclick="isWatched(this.id)">Mark as watched</button></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if playlist_info.playlist_description %}
|
||||
<div class="info-box-item description-box">
|
||||
<p>Description: <button onclick="textReveal()" id="text-reveal-button">Show</button></p>
|
||||
<div id="text-reveal" class="description-text">
|
||||
{{ playlist_info.playlist_description|linebreaks }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="player" class="video-player"></div>
|
||||
<div class="view-controls">
|
||||
<div class="toggle">
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user