예제 #1
0
def apply_dubbed_video_map(content_data: list, subtitles: list,
                           lang: str) -> (list, int):

    if lang != EN_LANG_CODE:

        dubbed_content = []

        dubbed_count = 0

        for item in content_data:
            if item["kind"] == NodeType.video:
                if is_video_node_dubbed(item, lang):
                    dubbed_count += 1
                elif item["youtube_id"] not in subtitles:
                    continue
            dubbed_content.append(item)

        content_data = dubbed_content

    else:
        dubbed_count = sum(
            content_datum.get("kind") == NodeType.video
            for content_datum in content_data)

    for item in content_data:
        item["remote_size"] = item.pop("download_size", 0)
        if item["remote_size"]:
            item["total_files"] = 1

    return content_data, dubbed_count
예제 #2
0
def apply_dubbed_video_map(content_data: list, subtitles: list, lang: str) -> (list, int):

    if lang != "en":

        dubbed_content = []

        dubbed_count = 0

        for item in content_data:
            if item["kind"] == NodeType.video:
                if is_video_node_dubbed(item, lang):
                    dubbed_count += 1
                elif item["youtube_id"] not in subtitles:
                    continue
            dubbed_content.append(item)

        content_data = dubbed_content

    else:
        dubbed_count = sum(content_datum.get("kind") == NodeType.video for content_datum in content_data)

    for item in content_data:
        item["remote_size"] = item.pop("download_size", 0)
        if item["remote_size"]:
            item["total_files"] = 1

    return content_data, dubbed_count