From 1498fadf27bda77fc03cb267335b07df0b7e23dc Mon Sep 17 00:00:00 2001
From: simon
Date: Wed, 16 Mar 2022 12:32:42 +0700
Subject: [PATCH] implement channel playlist index overwrite
---
tubearchivist/home/src/es/index_mapping.json | 6 ++++++
tubearchivist/home/src/frontend/forms.py | 9 +++++++++
tubearchivist/home/src/index/channel.py | 2 +-
tubearchivist/home/templates/home/channel_id.html | 7 +++++++
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/tubearchivist/home/src/es/index_mapping.json b/tubearchivist/home/src/es/index_mapping.json
index a94acda..29f6b7e 100644
--- a/tubearchivist/home/src/es/index_mapping.json
+++ b/tubearchivist/home/src/es/index_mapping.json
@@ -47,6 +47,9 @@
},
"autodelete_days": {
"type": "long"
+ },
+ "index_playlists": {
+ "type": "boolean"
}
}
}
@@ -120,6 +123,9 @@
},
"autodelete_days": {
"type": "long"
+ },
+ "index_playlists": {
+ "type": "boolean"
}
}
}
diff --git a/tubearchivist/home/src/frontend/forms.py b/tubearchivist/home/src/frontend/forms.py
index 839a88a..c4ac817 100644
--- a/tubearchivist/home/src/frontend/forms.py
+++ b/tubearchivist/home/src/frontend/forms.py
@@ -183,5 +183,14 @@ class SubscribeToPlaylistForm(forms.Form):
class ChannelOverwriteForm(forms.Form):
"""custom overwrites for channel settings"""
+ PLAYLIST_INDEX = [
+ ("", "-- change playlist index --"),
+ ("0", "Disable playlist index"),
+ ("1", "Enable playlist index"),
+ ]
+
download_format = forms.CharField(label=False, required=False)
autodelete_days = forms.IntegerField(label=False, required=False)
+ index_playlists = forms.ChoiceField(
+ widget=forms.Select, choices=PLAYLIST_INDEX, required=False
+ )
diff --git a/tubearchivist/home/src/index/channel.py b/tubearchivist/home/src/index/channel.py
index 7d40fd2..10da4f4 100644
--- a/tubearchivist/home/src/index/channel.py
+++ b/tubearchivist/home/src/index/channel.py
@@ -274,7 +274,7 @@ class YoutubeChannel(YouTubeItem):
def set_overwrites(self, overwrites):
"""set per channel overwrites"""
- valid_keys = ["download_format", "autodelete_days"]
+ valid_keys = ["download_format", "autodelete_days", "index_playlists"]
to_write = self.json_data.get("channel_overwrites", {})
for key, value in overwrites.items():
diff --git a/tubearchivist/home/templates/home/channel_id.html b/tubearchivist/home/templates/home/channel_id.html
index aaa7e03..4754249 100644
--- a/tubearchivist/home/templates/home/channel_id.html
+++ b/tubearchivist/home/templates/home/channel_id.html
@@ -75,6 +75,13 @@
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 }}