Exemplo n.º 1
0
def _clips_list(args):
    print_out("<dim>Loading clips...</dim>")
    generator = twitch.channel_clips_generator(args.channel_name, args.period, args.limit)

    first = 1

    for clips, has_more in generator:
        count = len(clips["edges"]) if "edges" in clips else 0
        last = first + count - 1

        print_out("-" * 80)
        print_out("<yellow>Showing clips {}-{} of ??</yellow>".format(first, last))

        for clip in clips["edges"]:
            print_out()
            print_clip(clip["node"])

        if not args.pager:
            print_out(
                "\n<dim>There are more clips. "
                "Increase the --limit or use --pager to see the rest.</dim>"
            )
            break

        if not has_more or not _continue():
            break

        first += count
    else:
        print_out("<yellow>No clips found</yellow>")
Exemplo n.º 2
0
def _clips_download(args):
    generator = twitch.channel_clips_generator(args.channel_name, args.period,
                                               100)
    for clips, _ in generator:
        for clip in clips["edges"]:
            clip = clip["node"]
            url = clip["videoQualities"][0]["sourceURL"]
            target = _clip_target_filename(clip)
            if path.exists(target):
                print_out(
                    "Already downloaded: <green>{}</green>".format(target))
            else:
                print_out("Downloading: <yellow>{}</yellow>".format(target))
                download_file(url, target)
Exemplo n.º 3
0
def _clips_download(args):
    downloaded_count = 0
    generator = twitch.channel_clips_generator(args.channel_name, args.period,
                                               100)

    for clips, _ in generator:
        for clip in clips["edges"]:
            clip = clip["node"]
            url = get_clip_authenticated_url(clip["slug"], "source")
            target = _clip_target_filename(clip)

            if path.exists(target):
                print_out(
                    "Already downloaded: <green>{}</green>".format(target))
            else:
                print_out("Downloading: <yellow>{}</yellow>".format(target))
                download_file(url, target)

            downloaded_count += 1
            if args.limit and downloaded_count >= args.limit:
                return