예제 #1
0
파일: youtube.py 프로젝트: dcloues/Schongo
def displayMeta(ctx, data, vid):
    """Displays a single youtube video result, given the xml node"""

    s = u""
    s += u"Title: %s " % data.getElementsByTagName("title")[0].firstChild.data
    s += u" • By: %s" % data.getElementsByTagName("author")[0].getElementsByTagName("name")[0].firstChild.data
    s += u" • Length: %s" % prettyTime(data.getElementsByTagName("yt:duration")[0].getAttribute("seconds"))
    s += u" • View Count: %s" % prettyNumber(data.getElementsByTagName("yt:statistics")[0].getAttribute("viewCount"))

    r = data.getElementsByTagName("gd:rating")
    if len(r):
        r = r[0]
        s += u" • Average Rating: %1.2f/5 over %s people" % (
            float(r.getAttribute("average")),
            prettyNumber(r.getAttribute("numRaters")),
        )
    else:
        s += u" • No ratings"

    s += u" • http://youtu.be/%s" % vid
    ctx.reply(s, "YouTube")
예제 #2
0
파일: urllog.py 프로젝트: dcloues/Schongo
def displayMeta(ctx, data, vid):
	"""Displays a single youtube video result, given the xml node"""
	
	s = u""
	s += u"Title: %s " % data.getElementsByTagName("title")[0].firstChild.data
	s += u" • By: %s"  % data.getElementsByTagName("author")[0].getElementsByTagName("name")[0].firstChild.data

	showRest = True

	r = data.getElementsByTagName("yt:state")
	if len(r):
		r = r[0]
		if r.getAttribute("name") == "restricted":
			showRest = r.getAttribute("reasonCode") == "limitedSyndication"
			if showRest:
				s += u" • Syndication Limited."
			else:
				s += u" • Video is unavailable: %s" % r.firstChild.data

	if showRest:
		s += u" • Length: %s" % prettyTime(data.getElementsByTagName("yt:duration")[0].getAttribute("seconds"))
		s += u" • View Count: %s" % prettyNumber(data.getElementsByTagName("yt:statistics")[0].getAttribute("viewCount"))

		r = data.getElementsByTagName("gd:rating")
		if len(r):
			r = r[0]
			s += u" • Average Rating: %1.2f/5 over %s people" % (
				float(r.getAttribute("average")),
				prettyNumber(r.getAttribute("numRaters"))
				)
		else:
			s += u" • No ratings"
	
	s += u" • http://youtu.be/%s" % vid
	addStatusToArchive(ctx, s, "YouTube")
	ctx.reply(s, "YouTube")