Skip to content

Commit

Permalink
Only download videos not already downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
MCGallaspy committed Mar 17, 2016
1 parent 483629b commit 6489044
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kalite/updates/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from kalite.i18n.base import lcode_to_ietf, delete_language, get_language_name
from kalite.shared.decorators.auth import require_admin
from kalite.topic_tools.settings import CHANNEL
from kalite.topic_tools.content_models import get_topic_update_nodes, get_download_youtube_ids, annotate_content_models_by_youtube_id
from kalite.topic_tools.content_models import get_topic_update_nodes, get_download_youtube_ids, \
annotate_content_models_by_youtube_id, get as get_content_item


def process_log_from_request(handler):
Expand Down Expand Up @@ -129,10 +130,12 @@ def start_video_download(request):
lang = json.loads(request.body or "{}").get("lang", "en")

youtube_ids = get_download_youtube_ids(paths, language=lang)

ids_to_queue = {id_: title for (id_, title) in youtube_ids.iteritems()
if not get_content_item({"youtube_id": id_}).available}

queue = VideoQueue()

queue.add_files(youtube_ids, language=lang)
queue.add_files(ids_to_queue, language=lang)

force_job("videodownload", _("Download Videos"), locale=lang)

Expand Down

0 comments on commit 6489044

Please sign in to comment.