示例#1
0
def highlight(lrrbot, conn, event, respond_to, description):
    """
	Command: !highlight DESCRIPTION
	Section: misc

	For use when something particularly awesome happens onstream, adds an entry on the Highlight Reel spreadsheet: https://docs.google.com/spreadsheets/d/1yrf6d7dPyTiWksFkhISqEc-JR71dxZMkUoYrX4BR40Y
	"""

    stream_info = twitch.get_info()
    if not stream_info["live"]:
        conn.privmsg(respond_to, "Not currently streaming.")
        return
    now = datetime.datetime.now(datetime.timezone.utc)

    for video in (yield from twitch.get_videos(broadcasts=True)):
        uptime = now - dateutil.parser.parse(video["recorded_at"])
        if video["status"] == "recording":
            break
    else:
        store_highlight(stream_info["status"], description, now, irc.client.NickMask(event.source).nick)
        conn.privmsg(respond_to, "Highlight added.")
        return

    yield from gdata.add_rows_to_spreadsheet(
        SPREADSHEET,
        [format_row(stream_info["status"], description, video["url"], uptime, irc.client.NickMask(event.source).nick)],
    )

    conn.privmsg(respond_to, "Highlight added.")
示例#2
0
def get_videos(*args, **kwargs):
	videos = yield from twitch.get_videos(*args, **kwargs)
	for video in videos:
		video["recorded_at"] = dateutil.parser.parse(video["recorded_at"])
	return videos