mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 11:50:14 +00:00
moove limit_count functionality into VideoDownload class to avoid having to reload the celery worker on config change
This commit is contained in:
parent
97819318da
commit
641698c350
@ -375,6 +375,10 @@ class VideoDownloader:
|
|||||||
|
|
||||||
def download_list(self):
|
def download_list(self):
|
||||||
""" download the list of youtube_ids """
|
""" download the list of youtube_ids """
|
||||||
|
limit_count = self.config['downloads']['limit_count']
|
||||||
|
if limit_count:
|
||||||
|
self.youtube_id_list = self.youtube_id_list[:limit_count]
|
||||||
|
|
||||||
for youtube_id in self.youtube_id_list:
|
for youtube_id in self.youtube_id_list:
|
||||||
try:
|
try:
|
||||||
self.dl_single_vid(youtube_id)
|
self.dl_single_vid(youtube_id)
|
||||||
|
@ -17,7 +17,6 @@ from home.src.config import AppConfig
|
|||||||
|
|
||||||
|
|
||||||
CONFIG = AppConfig().config
|
CONFIG = AppConfig().config
|
||||||
LIMIT_COUNT = CONFIG['downloads']['limit_count']
|
|
||||||
REDIS_HOST = CONFIG['application']['REDIS_HOST']
|
REDIS_HOST = CONFIG['application']['REDIS_HOST']
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'home.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'home.settings')
|
||||||
@ -41,12 +40,8 @@ def download_pending():
|
|||||||
""" download latest pending videos """
|
""" download latest pending videos """
|
||||||
pending_handler = PendingList()
|
pending_handler = PendingList()
|
||||||
pending_vids = pending_handler.get_all_pending()[0]
|
pending_vids = pending_handler.get_all_pending()[0]
|
||||||
pending = [i['youtube_id'] for i in pending_vids]
|
to_download = [i['youtube_id'] for i in pending_vids]
|
||||||
pending.reverse()
|
to_download.reverse()
|
||||||
if LIMIT_COUNT:
|
|
||||||
to_download = pending[:LIMIT_COUNT]
|
|
||||||
else:
|
|
||||||
to_download = pending
|
|
||||||
if to_download:
|
if to_download:
|
||||||
download_handler = VideoDownloader(to_download)
|
download_handler = VideoDownloader(to_download)
|
||||||
download_handler.download_list()
|
download_handler.download_list()
|
||||||
|
Loading…
Reference in New Issue
Block a user