reset autostart on queue stop, #520
This commit is contained in:
parent
b56316932f
commit
76981635dc
|
@ -163,6 +163,7 @@ class VideoDownloader:
|
||||||
while True:
|
while True:
|
||||||
video_data = self._get_next(auto_only)
|
video_data = self._get_next(auto_only)
|
||||||
if self.task.is_stopped() or not video_data:
|
if self.task.is_stopped() or not video_data:
|
||||||
|
self._reset_auto()
|
||||||
break
|
break
|
||||||
|
|
||||||
youtube_id = video_data.get("youtube_id")
|
youtube_id = video_data.get("youtube_id")
|
||||||
|
@ -405,3 +406,18 @@ class VideoDownloader:
|
||||||
self.channels.add(channel_id)
|
self.channels.add(channel_id)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _reset_auto(self):
|
||||||
|
"""reset autostart to defaults after queue stop"""
|
||||||
|
path = "ta_download/_update_by_query"
|
||||||
|
data = {
|
||||||
|
"query": {"term": {"auto_start": {"value": True}}},
|
||||||
|
"script": {
|
||||||
|
"source": "ctx._source.auto_start = false",
|
||||||
|
"lang": "painless",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
response, _ = ElasticWrap(path, config=self.config).post(data=data)
|
||||||
|
updated = response.get("updated")
|
||||||
|
if updated:
|
||||||
|
print(f"[download] reset auto start on {updated} videos.")
|
||||||
|
|
Loading…
Reference in New Issue