예제 #1
0
def download(urls, name, ext, live = False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    if not urls[0].startswith('http') or not ext == 'm3u8':
        m3u8_internal = True
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # change m3u8 ext to mp4
    # rebuild urls when use internal downloader
    if ext == 'm3u8':
        ext = 'mp4'
        if m3u8_internal:
            urls = load_m3u8(urls[0])

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        save_urls(urls, name, ext)
        lenth = len(urls)
        if lenth > 1:
            launch_ffmpeg(name, ext,lenth)
            clean_slices(name, ext,lenth)
예제 #2
0
def download(urls, name, ext, live = False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # rebuild m3u8 urls when use internal downloader,
    # change the ext to segment's ext, default is "ts",
    # otherwise change the ext to "mp4".
    if ext == 'm3u8':
        if m3u8_internal:
            urls = load_m3u8(urls[0])
            ext = urlparse(urls[0])[2].split('.')[-1]
            if ext not in ['ts', 'm4s', 'mp4']:
                ext = 'ts'
        else:
            ext = 'mp4'

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        if save_urls(urls, name, ext, jobs = args.jobs):
            lenth = len(urls)
            if lenth > 1 and not args.no_merge:
                launch_ffmpeg(name, ext,lenth)
                clean_slices(name, ext,lenth)
        else:
            logger.critical("{}> donwload failed".format(name))
예제 #3
0
파일: __main__.py 프로젝트: DoctorLai/ykdl
def download(urls, name, ext, live=False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # change m3u8 ext to mp4
    # rebuild urls when use internal downloader
    if ext == 'm3u8':
        ext = 'mp4'
        if m3u8_internal:
            urls = load_m3u8(urls[0])

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        if save_urls(urls, name, ext, jobs=args.jobs):
            lenth = len(urls)
            if lenth > 1 and not args.no_merge:
                launch_ffmpeg(name, ext, lenth)
                clean_slices(name, ext, lenth)
        else:
            logger.critical("{}> donwload failed".format(name))
예제 #4
0
파일: __main__.py 프로젝트: wwqgtxx/ykdl
def download(urls, name, ext, live = False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # change m3u8 ext to mp4
    # rebuild urls when use internal downloader
    if ext == 'm3u8':
        ext = 'mp4'
        if m3u8_internal:
            urls = load_m3u8(urls[0])

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        if save_urls(urls, name, ext, jobs = args.jobs):
            lenth = len(urls)
            if lenth > 1 and not args.no_merge:
                launch_ffmpeg(name, ext,lenth)
                clean_slices(name, ext,lenth)
        else:
            logger.critical("{}> donwload failed".format(name))
예제 #5
0
def download(urls, name, ext, live=False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    if not urls[0].startswith('http') or not ext == 'm3u8':
        m3u8_internal = True
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # change m3u8 ext to mp4
    # rebuild urls when use internal downloader
    if ext == 'm3u8':
        ext = 'mp4'
        if m3u8_internal:
            urls = load_m3u8(urls[0])

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        save_urls(urls, name, ext)
        lenth = len(urls)
        if lenth > 1 and not args.no_merge:
            launch_ffmpeg(name, ext, lenth)
            clean_slices(name, ext, lenth)
예제 #6
0
파일: __main__.py 프로젝트: zhangn1985/ykdl
def download(urls, name, ext, live = False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    # for live video, always use ffmpeg to rebuild timeline.
    if live:
        m3u8_internal = False
    # rebuild m3u8 urls when use internal downloader,
    # change the ext to segment's ext, default is "ts",
    # otherwise change the ext to "mp4".
    if ext == 'm3u8':
        if m3u8_internal:
            urls = load_m3u8(urls[0])
            ext = urlparse(urls[0])[2].split('.')[-1]
            if ext not in ['ts', 'm4s', 'mp4']:
                ext = 'ts'
        else:
            ext = 'mp4'

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext, live)
    else:
        if save_urls(urls, name, ext, jobs = args.jobs):
            lenth = len(urls)
            if lenth > 1 and not args.no_merge:
                launch_ffmpeg(name, ext,lenth)
                clean_slices(name, ext,lenth)
        else:
            logger.critical("{}> donwload failed".format(name))
예제 #7
0
파일: __main__.py 프로젝트: netlovehf/ykdl
def download(urls, name, ext, live=False):
    # ffmpeg can't handle local m3u8.
    # only use ffmpeg to hanle m3u8.
    global m3u8_internal
    # for live video, always use ffmpeg to rebuild timeline.
    if ext == 'm3u8' and not live:
        live = live_m3u8(urls[0])
    if live:
        m3u8_internal = False
    # rebuild m3u8 urls when use internal downloader,
    # change the ext to segment's ext, default is "ts",
    # otherwise change the ext to "flv" or "mp4".
    audio = subtitle = None
    if ext == 'm3u8':
        if m3u8_internal:
            urls, audio, subtitle = load_m3u8(urls[0])
            ext = urlparse(urls[0])[2].split('.')[-1]
            if ext not in ['ts', 'm4s', 'mp4', 'm4a']:
                ext = 'ts'
        elif live:
            ext = 'flv'
        else:
            ext = 'mp4'

    # OK check m3u8_internal
    if not m3u8_internal:
        launch_ffmpeg_download(urls[0], name + '.' + ext)
    else:
        if save_urls(urls,
                     name,
                     ext,
                     jobs=args.jobs,
                     fail_confirm=not args.no_fail_confirm,
                     fail_retry_eta=args.fail_retry_eta):
            lenth = len(urls)
            if lenth > 1 and not args.no_merge:
                launch_ffmpeg(name, ext, lenth)
                clean_slices(name, ext, lenth)
        else:
            logger.critical('{}> donwload failed'.format(name))
        if audio:
            ext = 'm4a'
            lenth = len(audio)
            if save_urls(audio,
                         name,
                         ext,
                         jobs=args.jobs,
                         fail_confirm=not args.no_fail_confirm,
                         fail_retry_eta=args.fail_retry_eta):
                if lenth > 1 and not args.no_merge:
                    launch_ffmpeg(name, ext, lenth)
                    clean_slices(name, ext, lenth)
            else:
                logger.critical('{}> HLS audio donwload failed'.format(name))
        if subtitle:
            ext = 'srt'
            if not save_urls(subtitle[:1],
                             name,
                             ext,
                             jobs=args.jobs,
                             fail_confirm=not args.no_fail_confirm,
                             fail_retry_eta=args.fail_retry_eta):
                logger.critical(
                    '{}> HLS subtitle donwload failed'.format(name))