mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-12-22 18:00:17 +00:00
better channel overwrite update form
This commit is contained in:
parent
dc67293052
commit
2ef8823c2d
@ -275,14 +275,18 @@ class YoutubeChannel(YouTubeItem):
|
||||
def set_overwrites(self, overwrites):
|
||||
"""set per channel overwrites"""
|
||||
valid_keys = ["download_format", "autodelete_days"]
|
||||
for key in overwrites:
|
||||
|
||||
to_write = self.json_data.get("channel_overwrites", {})
|
||||
for key, value in overwrites.items():
|
||||
if key not in valid_keys:
|
||||
raise ValueError(f"invalid overwrite key: {key}")
|
||||
if value in [0, "0"]:
|
||||
del to_write[key]
|
||||
continue
|
||||
if value:
|
||||
to_write.update({key: value})
|
||||
|
||||
if "channel_overwrites" in self.json_data.keys():
|
||||
self.json_data["channel_overwrites"].update(overwrites)
|
||||
else:
|
||||
self.json_data["channel_overwrites"] = overwrites
|
||||
self.json_data["channel_overwrites"] = to_write
|
||||
|
||||
|
||||
def channel_overwrites(channel_id, overwrites):
|
||||
|
Loading…
Reference in New Issue
Block a user