From 385f0b4b5efc6df8b81717dc2cb40213076d1127 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 1 Dec 2011 01:37:22 +1300 Subject: [PATCH] Reverted to a modified version of the Skybot youtube plugin --- plugins/youtube.py | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/plugins/youtube.py b/plugins/youtube.py index 737bcdf..e9bfebe 100644 --- a/plugins/youtube.py +++ b/plugins/youtube.py @@ -23,40 +23,32 @@ def get_video_description(vid_id): return j = j['data'] - out = {} - out["title"] = '%s' % j['title'] + + out = '\x02%s\x02' % j['title'] if not j.get('duration'): return out + out += ' - length \x02' length = j['duration'] - ti = "" if length / 3600: # > 1 hour - ti += '%dh ' % (length / 3600) + out += '%dh ' % (length / 3600) if length / 60: - ti += '%dm ' % (length / 60 % 60) - out["length"] = ti - #out += "%ds\x02" % (length % 60) - - if 'ratingCount' in j and 'likeCount' in j: - out["likes"] = int(j['likeCount']) - out["dislikes"] = int(j['ratingCount']) - int(j['likeCount']) - - if 'rating' in j: - out["rating"] = (j['rating']) + out += '%dm ' % (length / 60 % 60) + out += "%ds\x02" % (length % 60) if 'viewCount' in j: - out["views"] = j['viewCount'] + out += ' - \x02%s\x02 views' % locale.format('%d', + j['viewCount'], 1) upload_time = time.strptime(j['uploaded'], "%Y-%m-%dT%H:%M:%S.000Z") - out["uploadtime"] = (j['uploader']) + out += ' - \x02%s\x02 on \x02%s\x02' % (j['uploader'], + time.strftime("%Y.%m.%d", upload_time)) + if 'contentRating' in j: + out += ' - \x034NSFW\x02' - # title. uploader. length. upload date. - give = '\x02' + j[u'title'] + '\x02' - give += " - Length: " + GetInHMS(j['duration']) - give += " - "+ j[u'uploaded'][:10] + " by " + j[u'uploader'] - return give + return out def GetInHMS(seconds): hours = seconds / 3600 @@ -87,4 +79,4 @@ def youtube(inp): vid_id = j['data']['items'][0]['id'] - return get_video_description(vid_id) + " - " + video_url % vid_id \ No newline at end of file + return get_video_description(vid_id) + " - " + video_url % vid_id