Beispiel #1
0
def main():
    # CHANNEL_ID = 'UCKSVUHI9rbbkXhvAXK-2uxA'
    CHANNEL_ID = 'UCzu_R-RlEXmHUIbfb0GeJDA'  # peko
    WORD = 'ペコ'
    LIMIT = 20

    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': WORD,
        'limit': LIMIT,
        'cleanup': True,
    }

    short_opts = 'hc:s:l:'
    long_opts = 'help channel_id= search_word= limit= cleanup= fast= log='.split(
    )

    try:
        opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
    except getopt.GetoptError:
        print_usage()
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print_usage()
            sys.exit(0)
        elif opt in ('-c', '--channel_id'):
            inputs['channel_id'] = arg
        elif opt in ('-s', '--search_word'):
            inputs['search_word'] = arg
        elif opt in ('-l', '--limit'):
            inputs['limit'] = int(arg)
        elif opt in ('--cleanup'):
            inputs['cleanup'] = bool(arg)

    print('CHANNEL_ID is ', inputs['channel_id'])
    print('WORD is ', inputs['search_word'])
    print('LIMIT is ', inputs['limit'])
    print('cleanup is ', inputs['cleanup'])

    if not CHANNEL_ID or not WORD:
        print_usage()
        sys.exit(2)

    steps = [
        Preflight(),
        GetVideoList(),
        InitializeYt(),
        DowloadCaptions(),
        ReadCaption(),
        Search(),
        DownladeVideos(),
        EditVideo(),
        Postflight()
    ]

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #2
0
def main():
    CHANNEL_ID = 'UCKSVUHI9rbbkXhvAXK-2uxA'
    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': "incredible",
        'limit': 20,
        'cleanup': False,
    }

    short_opts = "hc:s:l:"
    long_opts = "help channel_id= search_word= limit= cleanup".split()
    try:
        opts, args = getopt.getopt(sys.argv[1:], short_opts, long_opts)
    except getopt.GetoptError:
        print_usage()
        sys.exit(2)

    for opt, args in opts:
        if opt in ['-h', '--help']:
            print_usage()
            sys.exit()
        elif opt in ['-c', '--channel_id']:
            inputs['channel_id'] = args
        elif opt in ['-s', '--search_word']:
            inputs['search_word'] = args
        elif opt == '--limit':
            inputs['limit'] = args
        elif opt == '--cleanup':
            inputs['cleanup'] = True
    if not inputs['channel_id'] or not inputs['search_word']:
        print_usage()
        sys.exit(2)
    if not str(inputs['limit']).isdigit:
        print_usage()
        sys.exit(2)

    steps = [
        Preflight(),
        GetVideoList(),  # 取得頻道所有影片id
        InitializeYT(),  # 轉為 YT model
        DownloadCaptions(),  # 下載每個影片字幕
        ReadCaptions(),  # 以字典紀錄字幕與對應時間
        Search(),  # 搜尋所有字幕含有 search_word 的片段
        DownloadVideos(),  # 下載頻道所有影片
        EditVideo(),  # 合併 Search() 所得到的片段
        Postflight(),
    ]

    config_logger()
    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #3
0
def main():
    inputs = {'channel_id': CHANNEL_ID}

    steps = [
        Preflight(),
        GetVideoList(),
        DownloadCaptions(),
        Postflight(),
    ]

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #4
0
def main():
    inputs = {
        'channel_id': CHANNEL_ID,
    }

    steps = [
        Preflight(),
        GetVideoList(),
        DownloadCaptions(),
        ReadCaption(),
        Postflight(),
    ]

    utils = Utils()  # 建立Utils物件
    p = Pipeline(steps)  # 建立Pipeline物件
    p.run(inputs, utils)  # 執行物件
Beispiel #5
0
def main():
    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': 'incredible',
        'limit': 20,
    }
    steps = [
        Preflight(),
        GetVideoList(),
        InitalizeYT(),
        DownloadCaptions(),
        ReadCaption(),
        Search(),
        EditVideo(),
        Postflight(),
    ]

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #6
0
def main():
    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': 'blender',
    }

    steps = [
        Preflight(),
        GetVideoList(),
        InitializeYT(),
        DownloadCaptions(),
        ReadCaption(),
        Search(),
        DownloadVideos(),
        Postflight(),
    ]

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #7
0
def main():
    inputs = {
        "channel_id": CHANNEL_ID,
        "search_word": "incredible",
    }

    steps = [
        Preflight(),
        GetVideoList(),
        InitializeYT(),
        DownloadCaptions(),
        ReadCaption(),
        Search(),
        DownloadVideos(),
        Postflight(),
    ]

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
Beispiel #8
0
def main():
    CHANNEL_ID = 'UCKSVUHI9rbbkXhvAXK-2uxA'  # 頻道 id
    WORD = 'incredible'  # 要搜尋的字/詞
    LIMIT = 4  # 合併影片的最高片段數量
    loglevel = logging.WARNING

    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': WORD,
        'limit': LIMIT,
        'cleanup': False,  # 結果檔產生後,刪除程式執行中產生的檔案,如下載的影片/字幕等
        'fast': True,  # 跳過重複下載
        'loglevel': loglevel
    }

    short_opts = 'hc:s:l:'
    long_opts = 'help channel_id= search_word= limit= cleanup= fast= log='.split(
    )

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], short_opts,
            long_opts)  # 用 opts 解析 argv 所投入的參數 ,投遞只能印出檔名後的東西
    except getopt.GetoptError:
        print_usage()
        sys.exit(2)

    for opt, arg in opts:
        if opt == '-h':
            print_usage()
            sys.exit(0)
        elif opt in ('-c', '--channel_id'):
            inputs['channel_id'] = arg
        elif opt in ('-s', '--search_word'):
            inputs['search_word'] = arg
        elif opt in ('-l', '--limit'):
            inputs['limit'] = int(arg)
        elif opt in ('--cleanup'):
            inputs['cleanup'] = bool(arg)
        elif opt in ('--fast'):
            inputs['fast'] = bool(arg)
        elif opt in ('--log'):
            inputs['loglevel'] = eval(f'logging.{arg}')

    print('CHANNEL_ID is ', inputs['channel_id'])
    print('WORD is ', inputs['search_word'])
    print('LIMIT is ', inputs['limit'])
    print('cleanup is ', inputs['cleanup'])
    print('fast is ', inputs['fast'])
    print('log level is ', inputs['loglevel'])

    if not CHANNEL_ID or not WORD:
        print_usage()
        sys.exit(2)

    steps = [
        Preflight(),
        GetVideoList(),
        InitializeYT(),
        DownloadCaptions(),
        ReadCaption(),
        Search(),
        DownloadVideos(),
        EditVideo(),
        Postflight(),
    ]

    config_logger(inputs['loglevel'])
    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)