예제 #1
0
def youtube(server, message, nresults, query):
    if nresults:
        nresults = min(-int(nresults.strip()), lines[message.prefix])
    else:
        nresults = lines[message.prefix]

    results = yt.search(query, results=nresults)

    for i in results:
        data = {"title": i["snippet"]["title"], "channel": i["snippet"]["channelTitle"], "url": i["id"]["videoId"]}
        yield templates[message.prefix] % data
예제 #2
0
파일: youtube.py 프로젝트: svkampen/Karkat
def youtube(server, message, nresults, query):
    if nresults:
        nresults = min(-int(nresults.strip()), lines[message.prefix])
    else:
        nresults = lines[message.prefix]

    results = yt.search(query, results=nresults)

    for i in results:
        data = {"title": i["snippet"]["title"],
                "url": i["id"]["videoId"]}

        if message.prefix != ".":
            channelinfo, stats = parallelise([lambda: yt.get_channel_info(i["snippet"]["channelId"]),
                                              lambda: yt.stats(i["id"]["videoId"])])
            data["likebar"] = likebar(int(stats["likeCount"]), int(stats["dislikeCount"]))
            data["views"] = "{:,}".format(int(stats["viewCount"]))
            data["channel"] = channelinfo["title"]
        else:
            channelinfo = yt.get_channel_info(i["snippet"]["channelId"])
            data["channel"] = channelinfo["title"]
        yield templates[message.prefix] % data
예제 #3
0
def youtube(server, message, nresults, query):
    if nresults:
        nresults = min(-int(nresults.strip()), lines[message.prefix])
    else:
        nresults = lines[message.prefix]

    results = yt.search(query, results=nresults)

    for i in results:
        data = {"title": i["snippet"]["title"], "url": i["id"]["videoId"]}

        if message.prefix != ".":
            channelinfo, stats = parallelise([
                lambda: yt.get_channel_info(i["snippet"]["channelId"]),
                lambda: yt.stats(i["id"]["videoId"])
            ])
            data["likebar"] = likebar(int(stats["likeCount"]),
                                      int(stats["dislikeCount"]))
            data["views"] = "{:,}".format(int(stats["viewCount"]))
            data["channel"] = channelinfo["title"]
        else:
            channelinfo = yt.get_channel_info(i["snippet"]["channelId"])
            data["channel"] = channelinfo["title"]
        yield templates[message.prefix] % data