Add a refresher thread to keep your sub box up to date.
This commit is contained in:
parent
78ce6a6f41
commit
29d819fe97
1 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,8 @@ from flask import request
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import bot
|
import bot
|
||||||
|
@ -233,6 +235,7 @@ def post_refresh_channel():
|
||||||
|
|
||||||
force = request.form.get('force', False)
|
force = request.form.get('force', False)
|
||||||
force = ycdl.helpers.truthystring(force)
|
force = ycdl.helpers.truthystring(force)
|
||||||
|
youtube.add_channel(channel_id, commit=False)
|
||||||
youtube.refresh_channel(channel_id, force=force)
|
youtube.refresh_channel(channel_id, force=force)
|
||||||
return make_json_response({})
|
return make_json_response({})
|
||||||
|
|
||||||
|
@ -253,5 +256,20 @@ def post_start_download():
|
||||||
|
|
||||||
return make_json_response({'video_ids': video_ids, 'state': 'downloaded'})
|
return make_json_response({'video_ids': video_ids, 'state': 'downloaded'})
|
||||||
|
|
||||||
|
####################################################################################################
|
||||||
|
####################################################################################################
|
||||||
|
####################################################################################################
|
||||||
|
####################################################################################################
|
||||||
|
|
||||||
|
def refresher_thread():
|
||||||
|
while True:
|
||||||
|
time.sleep(60 * 60 * 6)
|
||||||
|
print('Starting refresh job.')
|
||||||
|
refresh_job = threading.Thread(target=youtube.refresh_all_channels, kwargs={'force': False}, daemon=True)
|
||||||
|
refresh_job.start()
|
||||||
|
|
||||||
|
refresher = threading.Thread(target=refresher_thread, daemon=True)
|
||||||
|
refresher.start()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue