bunch'o'stuff
This commit is contained in:
parent
2fa3a5a015
commit
fb08870f4a
|
@ -5,6 +5,8 @@ import re
|
|||
|
||||
db_ready = False
|
||||
|
||||
CAN_DOWNVOTE = False
|
||||
|
||||
|
||||
def db_init(db):
|
||||
db.execute("""CREATE TABLE if not exists karma(
|
||||
|
@ -92,7 +94,7 @@ def karma_add(match, nick='', chan='', db=None, notice=None):
|
|||
total_karma) values(?,?,?,?)""", (nick_vote.lower(), 0, 0, 0))
|
||||
up(db, nick_vote)
|
||||
notice("Gave {} 1 karma!".format(nick_vote))
|
||||
if match.group(2) == '--':
|
||||
if match.group(2) == '--' and CAN_DOWNVOTE:
|
||||
db.execute("""INSERT or IGNORE INTO karma(
|
||||
nick_vote,
|
||||
up_karma,
|
||||
|
|
|
@ -37,9 +37,9 @@ def wolframalpha(inp, bot=None):
|
|||
if subpod:
|
||||
results.append(subpod)
|
||||
if results:
|
||||
pod_texts.append(title + ': ' + ', '.join(results))
|
||||
pod_texts.append(title + u': ' + u', '.join(results))
|
||||
|
||||
ret = ' - '.join(pod_texts)
|
||||
ret = u' - '.join(pod_texts)
|
||||
|
||||
if not pod_texts:
|
||||
return 'No results.'
|
||||
|
@ -56,4 +56,4 @@ def wolframalpha(inp, bot=None):
|
|||
if not ret:
|
||||
return 'No results.'
|
||||
|
||||
return "{} - {}".format(ret, short_url)
|
||||
return u"{} - {}".format(ret, short_url)
|
||||
|
|
|
@ -14,7 +14,7 @@ video_url = "http://youtu.be/%s"
|
|||
|
||||
|
||||
def plural(num=0, text=''):
|
||||
return "%d %s%s" % (num, text, "s"[num==1:])
|
||||
return "{:,} {}{}".format(num, text, "s"[num==1:])
|
||||
|
||||
|
||||
def get_video_description(video_id):
|
||||
|
@ -25,7 +25,7 @@ def get_video_description(video_id):
|
|||
|
||||
data = request['data']
|
||||
|
||||
out = '\x02%s\x02' % data['title']
|
||||
out = '\x02{}\x02'.format(data['title'])
|
||||
|
||||
if not data.get('duration'):
|
||||
return out
|
||||
|
@ -39,24 +39,26 @@ def get_video_description(video_id):
|
|||
out += "%ds\x02" % (length % 60)
|
||||
|
||||
if 'ratingCount' in data:
|
||||
# format
|
||||
likes = plural(int(data['likeCount']), "like")
|
||||
dislikes = plural(data['ratingCount'] - int(data['likeCount']), "dislike")
|
||||
|
||||
percent = 100 * float(data['likeCount'])/float(data['ratingCount'])
|
||||
out += ' - {}, {} (\x02{:.1f}\x02%)'.format(likes,
|
||||
dislikes, percent)
|
||||
dislikes, percent)
|
||||
|
||||
if 'viewCount' in data:
|
||||
out += ' - \x02%s\x02 views' % format(data['viewCount'], ",d")
|
||||
views = data['viewCount']
|
||||
out += ' - \x02{:,}\x02 view{}'.format(views, "s"[views==1:])
|
||||
|
||||
try:
|
||||
uploader = http.get_json(base_url + "users/{}?alt=json".format(data["uploader"]))["entry"]["author"][0]["name"]["$t"]
|
||||
except:
|
||||
uploader = data["uploader"]
|
||||
|
||||
|
||||
upload_time = time.strptime(data['uploaded'], "%Y-%m-%dT%H:%M:%S.000Z")
|
||||
out += ' - \x02%s\x02 on \x02%s\x02' % (uploader,
|
||||
time.strftime("%Y.%m.%d", upload_time))
|
||||
out += ' - \x02{}\x02 on \x02{}\x02'.format(uploader,
|
||||
time.strftime("%Y.%m.%d", upload_time))
|
||||
|
||||
if 'contentRating' in data:
|
||||
out += ' - \x034NSFW\x02'
|
||||
|
|
Reference in New Issue