mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
add channel overwrite form to frontend, store in es
This commit is contained in:
parent
105d5bf3f7
commit
774220ab1f
@ -178,3 +178,10 @@ class SubscribeToPlaylistForm(forms.Form):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ChannelOverwriteForm(forms.Form):
|
||||||
|
"""custom overwrites for channel settings"""
|
||||||
|
|
||||||
|
download_format = forms.CharField(label=False, required=False)
|
||||||
|
autodelete_days = forms.IntegerField(label=False, required=False)
|
||||||
|
@ -274,7 +274,7 @@ class YoutubeChannel(YouTubeItem):
|
|||||||
|
|
||||||
def set_overwrites(self, overwrites):
|
def set_overwrites(self, overwrites):
|
||||||
"""set per channel overwrites"""
|
"""set per channel overwrites"""
|
||||||
valid_keys = ["format", "autodelete_days"]
|
valid_keys = ["download_format", "autodelete_days"]
|
||||||
for key in overwrites:
|
for key in overwrites:
|
||||||
if key not in valid_keys:
|
if key not in valid_keys:
|
||||||
raise ValueError(f"invalid overwrite key: {key}")
|
raise ValueError(f"invalid overwrite key: {key}")
|
||||||
@ -283,3 +283,12 @@ class YoutubeChannel(YouTubeItem):
|
|||||||
self.json_data["channel_overwrites"].update(overwrites)
|
self.json_data["channel_overwrites"].update(overwrites)
|
||||||
else:
|
else:
|
||||||
self.json_data["channel_overwrites"] = overwrites
|
self.json_data["channel_overwrites"] = overwrites
|
||||||
|
|
||||||
|
|
||||||
|
def channel_overwrites(channel_id, overwrites):
|
||||||
|
"""collection to overwrite settings per channel"""
|
||||||
|
channel = YoutubeChannel(channel_id)
|
||||||
|
channel.build_json()
|
||||||
|
channel.set_overwrites(overwrites)
|
||||||
|
channel.upload_to_es()
|
||||||
|
channel.sync_to_videos()
|
||||||
|
@ -57,6 +57,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="info-box">
|
||||||
|
<div class="info-box-item">
|
||||||
|
<form action="/channel/{{ channel_info.channel_id }}/" method="POST">
|
||||||
|
{% csrf_token %}
|
||||||
|
<p>Download format</p>
|
||||||
|
{{ channel_overwrite_form.download_format }}<br>
|
||||||
|
<p>Auto delete videos after x days</p>
|
||||||
|
{{ channel_overwrite_form.autodelete_days }}<br>
|
||||||
|
<button type="submit">Save</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% if channel_info.channel_description %}
|
{% if channel_info.channel_description %}
|
||||||
<div class="info-box-item description-box">
|
<div class="info-box-item description-box">
|
||||||
<p>Description: <button onclick="textReveal()" id="text-reveal-button">Show</button></p>
|
<p>Description: <button onclick="textReveal()" id="text-reveal-button">Show</button></p>
|
||||||
|
@ -19,6 +19,7 @@ from home.src.frontend.api_calls import PostData
|
|||||||
from home.src.frontend.forms import (
|
from home.src.frontend.forms import (
|
||||||
AddToQueueForm,
|
AddToQueueForm,
|
||||||
ApplicationSettingsForm,
|
ApplicationSettingsForm,
|
||||||
|
ChannelOverwriteForm,
|
||||||
CustomAuthForm,
|
CustomAuthForm,
|
||||||
MultiSearchForm,
|
MultiSearchForm,
|
||||||
SchedulerSettingsForm,
|
SchedulerSettingsForm,
|
||||||
@ -27,6 +28,7 @@ from home.src.frontend.forms import (
|
|||||||
UserSettingsForm,
|
UserSettingsForm,
|
||||||
)
|
)
|
||||||
from home.src.frontend.searching import SearchHandler
|
from home.src.frontend.searching import SearchHandler
|
||||||
|
from home.src.index.channel import channel_overwrites
|
||||||
from home.src.index.generic import Pagination
|
from home.src.index.generic import Pagination
|
||||||
from home.src.index.playlist import YoutubePlaylist
|
from home.src.index.playlist import YoutubePlaylist
|
||||||
from home.src.ta.config import AppConfig, ScheduleBuilder
|
from home.src.ta.config import AppConfig, ScheduleBuilder
|
||||||
@ -412,6 +414,7 @@ class ChannelIdView(ArchivistResultsView):
|
|||||||
{
|
{
|
||||||
"title": "Channel: " + channel_name,
|
"title": "Channel: " + channel_name,
|
||||||
"channel_info": channel_info,
|
"channel_info": channel_info,
|
||||||
|
"channel_overwrite_form": ChannelOverwriteForm,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -432,6 +435,19 @@ class ChannelIdView(ArchivistResultsView):
|
|||||||
to_append = {"term": {"player.watched": {"value": False}}}
|
to_append = {"term": {"player.watched": {"value": False}}}
|
||||||
self.data["query"]["bool"]["must"].append(to_append)
|
self.data["query"]["bool"]["must"].append(to_append)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def post(request, channel_id):
|
||||||
|
"""handle post request"""
|
||||||
|
print(f"handle post from {channel_id}")
|
||||||
|
channel_overwrite_form = ChannelOverwriteForm(request.POST)
|
||||||
|
if channel_overwrite_form.is_valid():
|
||||||
|
overwrites = channel_overwrite_form.cleaned_data
|
||||||
|
print(f"{channel_id}: set overwrites {overwrites}")
|
||||||
|
channel_overwrites(channel_id, overwrites=overwrites)
|
||||||
|
|
||||||
|
sleep(1)
|
||||||
|
return redirect("channel_id", channel_id, permanent=True)
|
||||||
|
|
||||||
|
|
||||||
class ChannelView(ArchivistResultsView):
|
class ChannelView(ArchivistResultsView):
|
||||||
"""resolves to /channel/
|
"""resolves to /channel/
|
||||||
|
Loading…
Reference in New Issue
Block a user