From e6643388455c730937f214dc89fcea0c7447045c Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 4 Jul 2022 16:44:37 +0700 Subject: [PATCH] implement basic channel_id_about view --- .../home/templates/home/channel_id.html | 5 + .../home/templates/home/channel_id_about.html | 110 ++++++++++++++++++ tubearchivist/home/urls.py | 6 + tubearchivist/home/views.py | 30 +++++ tubearchivist/static/css/style.css | 12 ++ 5 files changed, 163 insertions(+) create mode 100644 tubearchivist/home/templates/home/channel_id_about.html diff --git a/tubearchivist/home/templates/home/channel_id.html b/tubearchivist/home/templates/home/channel_id.html index 5aefcba..57d1e05 100644 --- a/tubearchivist/home/templates/home/channel_id.html +++ b/tubearchivist/home/templates/home/channel_id.html @@ -6,6 +6,11 @@
channel_banner
+
+

Videos

+

Playlists

+

About

+
diff --git a/tubearchivist/home/templates/home/channel_id_about.html b/tubearchivist/home/templates/home/channel_id_about.html new file mode 100644 index 0000000..3650e8b --- /dev/null +++ b/tubearchivist/home/templates/home/channel_id_about.html @@ -0,0 +1,110 @@ +{% extends "home/base.html" %} +{% block content %} +{% load static %} +{% load humanize %} +
+
+ channel_banner +
+ +
+
+
+ + channel-thumb + +
+
+

{{ channel_info.channel_name }}

+ {% if channel_info.channel_subs >= 1000000 %} +

Subscribers: {{ channel_info.channel_subs|intword }}

+ {% else %} +

Subscribers: {{ channel_info.channel_subs|intcomma }}

+ {% endif %} +
+
+
+
+

Last refreshed: {{ channel_info.channel_last_refresh }}

+ {% if channel_info.channel_active %} +

Youtube: Active

+ {% else %} +

Youtube: Deactivated

+ {% endif %} +
+
+
+
+ {% if channel_info.channel_views >= 1000000 %} +

Channel views: {{ channel_info.channel_views|intword }}

+ {% elif channel_info.channel_views > 0 %} +

Channel views: {{ channel_info.channel_views|intcomma }}

+ {% endif %} + +
+ Delete {{ channel_info.channel_name }} including all videos? +
+
+
+
+ {% if channel_info.channel_description %} +
+
+

Description:

+ {{ channel_info.channel_description|linebreaks }} +
+
+ {% endif %} +
+
+
+ {% csrf_token %} +
+

Download format: + {% if channel_info.channel_overwrites.download_format %} + {{ channel_info.channel_overwrites.download_format }} + {% else %} + False + {% endif %}

+ {{ channel_overwrite_form.download_format }}
+
+
+

Auto delete watched videos after x days: + {% if channel_info.channel_overwrites.autodelete_days %} + {{ channel_info.channel_overwrites.autodelete_days }} + {% else %} + False + {% endif %}

+ {{ channel_overwrite_form.autodelete_days }}
+
+
+

Index playlists: + {% if channel_info.channel_overwrites.index_playlists %} + {{ channel_info.channel_overwrites.index_playlists }} + {% else %} + False + {% endif %}

+ {{ channel_overwrite_form.index_playlists }}
+
+
+

Enable SponsorBlock: + {% if channel_info.channel_overwrites.integrate_sponsorblock %} + {{ channel_info.channel_overwrites.integrate_sponsorblock }} + {% elif channel_info.channel_overwrites.integrate_sponsorblock == False %} + Disabled + {% else %} + False + {% endif %}

+ {{ channel_overwrite_form.integrate_sponsorblock }}
+
+ +
+
+
+

{{ channel_info }}

+
+{% endblock content %} \ No newline at end of file diff --git a/tubearchivist/home/urls.py b/tubearchivist/home/urls.py index 972e4a5..b40c403 100644 --- a/tubearchivist/home/urls.py +++ b/tubearchivist/home/urls.py @@ -6,6 +6,7 @@ from django.contrib.auth.views import LogoutView from django.urls import path from home.views import ( AboutView, + ChannelIdAboutView, ChannelIdView, ChannelView, DownloadView, @@ -42,6 +43,11 @@ urlpatterns = [ login_required(ChannelIdView.as_view()), name="channel_id", ), + path( + "channel//about/", + login_required(ChannelIdAboutView.as_view()), + name="channel_id_about", + ), path( "video//", login_required(VideoView.as_view()), diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index bb30e8d..18604c8 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -8,6 +8,7 @@ import json import urllib.parse from time import sleep +from api.src.search_processor import SearchProcess from django.conf import settings from django.contrib.auth import login from django.contrib.auth.forms import AuthenticationForm @@ -15,6 +16,7 @@ from django.http import JsonResponse from django.shortcuts import redirect, render from django.views import View from home.src.download.yt_dlp_base import CookieHandler +from home.src.es.connect import ElasticWrap from home.src.es.index_setup import get_available_backups from home.src.frontend.api_calls import PostData from home.src.frontend.forms import ( @@ -477,6 +479,34 @@ class ChannelIdView(ArchivistResultsView): return redirect("channel_id", channel_id, permanent=True) +class ChannelIdAboutView(ArchivistResultsView): + """resolves to /channel//about/ + show metadata, handle per channel conf + """ + + view_origin = "channel" + + def get(self, request, channel_id): + """handle get request""" + self.initiate_vars(request) + + path = f"ta_channel/_doc/{channel_id}" + response, _ = ElasticWrap(path).get() + + channel_info = SearchProcess(response).process() + channel_name = channel_info["channel_name"] + + self.context.update( + { + "title": "Channel: About " + channel_name, + "channel_info": channel_info, + "channel_overwrite_form": ChannelOverwriteForm, + } + ) + + return render(request, "home/channel_id_about.html", self.context) + + class ChannelView(ArchivistResultsView): """resolves to /channel/ handle functionality for channel overview page, subscribe to channel, diff --git a/tubearchivist/static/css/style.css b/tubearchivist/static/css/style.css index 45a7c0a..e34f74a 100644 --- a/tubearchivist/static/css/style.css +++ b/tubearchivist/static/css/style.css @@ -817,6 +817,18 @@ button:hover { transform: translateX(-30%); } +.info-box-item.channel-nav { + justify-content: center; +} + +.info-box-item.channel-nav a { + padding: 0 1rem; +} + +.info-box-item.channel-nav a:hover { + text-decoration: underline; +} + /* playlist overview page */ .playlist-list.list { display: grid;