示例#1
0
文件: commands.py 项目: m4p/twitch-dl
def videos(args):
    game_ids = _get_game_ids(args.game)

    print_out("<dim>Loading videos...</dim>")
    generator = twitch.channel_videos_generator(args.channel_name,
                                                args.limit,
                                                args.sort,
                                                args.type,
                                                game_ids=game_ids)

    first = 1

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

        for video in videos["edges"]:
            print_video(video["node"])

        if not has_more:
            break

        first += count
    else:
        print_out("<yellow>No videos found</yellow>")
示例#2
0
def videos(args):
    game_ids = _get_game_ids(args.game)

    print_out("<dim>Loading videos...</dim>")
    generator = twitch.channel_videos_generator(
        args.channel_name, args.limit, args.sort, args.type, game_ids=game_ids)

    first = 1

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

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

        for video in videos["edges"]:
            print_video(video["node"])

        if not args.pager:
            print_out(
                "\n<dim>There are more videos. "
                "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 videos found</yellow>")
示例#3
0
def video_info(video, playlists):
    print_out()
    print_video(video)

    print_out()
    print_out("Playlists:")
    for p in m3u8.loads(playlists).playlists:
        print_out("<b>{}</b> {}".format(p.stream_info.video, p.uri))
示例#4
0
def videos(channel_name, limit, offset, sort, **kwargs):
    user = twitch.get_user(channel_name)
    if not user:
        raise ConsoleError("Utilisateur {} non trouvé.".format(channel_name))

    videos = twitch.get_channel_videos(user["id"], limit, offset, sort)
    count = len(videos['videos'])
    if not count:
        print_out("Pas de vidéos")
        return

    first = offset + 1
    last = offset + len(videos['videos'])
    total = videos["_total"]

    for video in videos['videos']:
        print_video(video)