Tweaked IMDB.py a bit
This commit is contained in:
parent
eba21e1584
commit
9779943b91
1 changed files with 4 additions and 20 deletions
|
@ -1,26 +1,11 @@
|
||||||
# IMDb lookup plugin by Ghetto Wizard (2011) and blha303 (2013)
|
# IMDb lookup plugin by Ghetto Wizard (2011) and blha303 (2013)
|
||||||
|
|
||||||
from util import hook, http
|
from util import hook, http, text
|
||||||
import re
|
import re
|
||||||
import json
|
|
||||||
|
|
||||||
id_re = re.compile("tt\d+")
|
id_re = re.compile("tt\d+")
|
||||||
|
imdb_re = (r'(.*:)//(imdb.com|www.imdb.com)(:[0-9]+)?(.*)', re.I)
|
||||||
|
|
||||||
def truncate(msg):
|
|
||||||
nmsg = msg.split(" ")
|
|
||||||
out = None
|
|
||||||
x = 0
|
|
||||||
for i in nmsg:
|
|
||||||
if x <= 7:
|
|
||||||
if out:
|
|
||||||
out = out + " " + nmsg[x]
|
|
||||||
else:
|
|
||||||
out = nmsg[x]
|
|
||||||
x = x + 1
|
|
||||||
if x <= 7:
|
|
||||||
return out
|
|
||||||
else:
|
|
||||||
return out + "..."
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def imdb(inp):
|
def imdb(inp):
|
||||||
|
@ -49,7 +34,6 @@ def imdb(inp):
|
||||||
else:
|
else:
|
||||||
return 'Unknown error.'
|
return 'Unknown error.'
|
||||||
|
|
||||||
imdb_re = (r'(.*:)//(imdb.com|www.imdb.com)(:[0-9]+)?(.*)', re.I)
|
|
||||||
|
|
||||||
@hook.regex(*imdb_re)
|
@hook.regex(*imdb_re)
|
||||||
def imdb_url(match):
|
def imdb_url(match):
|
||||||
|
@ -61,7 +45,7 @@ def imdb_url(match):
|
||||||
return 'Movie not found!'
|
return 'Movie not found!'
|
||||||
elif content['Response'] == 'True':
|
elif content['Response'] == 'True':
|
||||||
content['URL'] = 'http://www.imdb.com/title/%(imdbID)s' % content
|
content['URL'] = 'http://www.imdb.com/title/%(imdbID)s' % content
|
||||||
content['Plot'] = truncate(content['Plot'])
|
content['Plot'] = text.truncate_str(content['Plot'], 50)
|
||||||
out = '\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s'
|
out = '\x02%(Title)s\x02 (%(Year)s) (%(Genre)s): %(Plot)s'
|
||||||
if content['Runtime'] != 'N/A':
|
if content['Runtime'] != 'N/A':
|
||||||
out += ' \x02%(Runtime)s\x02.'
|
out += ' \x02%(Runtime)s\x02.'
|
||||||
|
|
Reference in a new issue