コード例 #1
0
def main():
    inputs = {'channel_id': CHANNEL_ID}
    steps = [
        GetVideoList(),
    ]
    p = Pipeline(steps)
    p.run(inputs)
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
def main():
    inputs = {
        'channel_id': CHANNEL_ID,
    }

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

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
コード例 #5
0
def main():
    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': "incredible",
        'limit': 20,
        'cleanup': False,
    }

    try:
        opts, args = getopt.getopt(
            sys.argv[1:], "hc:s:l:",
            ["channel_id=", "search_word=", "limit=", "cleanup"])
    except getopt.GetoptError:
        usarg()
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            usarg()
            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"] = arg
        elif opt in "cleanup":
            inputs['cleanup'] = arg

    if not inputs['channel_id'] or not inputs['search_word']:
        usarg()
        sys.exit(2)

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

    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils)
コード例 #6
0
ファイル: main.py プロジェクト: chlin61/yt-concate
def main(argv):
    inputs = {
        'channel_id': CHANNEL_ID,
        'search_word': 'incredible',
        'limit': 20,
    }
    short_opt = 'hc:s:l:'
    long_opt = 'channel_id search_word limit'.split()
    try:
        opts, args = getopt.getopt(argv, short_opt, long_opt)
    except getopt.GetoptError:
        printStage()
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print('main.py Option')
            print('Option:')
            print('{:<6}{:>15}{}'.format(
                '-c', '--channel_id',
                'input channel ID for youtube to download video.'))
            print('{:<6}{:>15}{}'.format(
                '-s', '--search_word',
                'input Search Word to search caption from youtube video for Channel ID.'
            ))

            sys.exit()
        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'] = arg

    steps = [
        Preflight(),
        GetVideoList(),
        InitializeYT(),
        DownloadCaptions(),
        ReadCaptions(),
        Search(),
        DownloadVideos(),
        EditVideo(),
        Postflight(),
    ]
    logger = configLog()
    utils = Utils()
    p = Pipeline(steps)
    p.run(inputs, utils, logger)
コード例 #7
0
ファイル: main.py プロジェクト: Arthas-tarou/yt-concate
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)
コード例 #8
0
ファイル: main.py プロジェクト: Mokoutan-1992/yt-concate
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)
コード例 #9
0
ファイル: main.py プロジェクト: menghsin-2021/yt-concate
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)