示例#1
0
def check_video_download(request):
    youtube_ids = simplejson.loads(request.raw_post_data or "{}").get("youtube_ids", [])
    percentages = {}
    percentages["downloading"] = job_status("videodownload")
    for id in youtube_ids:
        videofile = get_object_or_None(VideoFile, youtube_id=id)
        percentages[id] = videofile.percent_complete if videofile else None
    return JsonResponse(percentages)
示例#2
0
def check_video_download(request):
    youtube_ids = simplejson.loads(request.raw_post_data
                                   or "{}").get("youtube_ids", [])
    percentages = {}
    percentages["downloading"] = job_status("videodownload")
    for id in youtube_ids:
        videofile = get_object_or_None(VideoFile, youtube_id=id)
        percentages[id] = videofile.percent_complete if videofile else None
    return JsonResponse(percentages)
示例#3
0
def get_video_download_status(request):
    """Get info about what video is currently being downloaded, and how many are left.
    So far, this is only used for debugging, but could be a more robust alternative to
    `check_video_download` if we change our approach slightly.
    """

    videofile = get_object_or_None(VideoFile, download_in_progress=True)
    return JsonResponse({
        "waiting_count": VideoFile.objects.filter(flagged_for_download=True).count(),
        "current_video_id": videofile.youtube_id if videofile else None,
        "current_video_percent": videofile.percent_complete if videofile else 0,
        "downloading": job_status("videodownload"),
    })
示例#4
0
def get_video_download_status(request):
    """Get info about what video is currently being downloaded, and how many are left.
    So far, this is only used for debugging, but could be a more robust alternative to
    `check_video_download` if we change our approach slightly.
    """

    videofile = get_object_or_None(VideoFile, download_in_progress=True)
    return JsonResponse({
        "waiting_count":
        VideoFile.objects.filter(flagged_for_download=True).count(),
        "current_video_id":
        videofile.youtube_id if videofile else None,
        "current_video_percent":
        videofile.percent_complete if videofile else 0,
        "downloading":
        job_status("videodownload"),
    })