dickserv

- irc bot with many useful commands
git clone git://git.acid.vegas/dickserv.git
Log | Files | Refs | Archive | README | LICENSE

imdb.py (892B)

      1 #!/usr/bin/env python
      2 # DickServ IRC Bot - Developed by acidvegas in Python (https://acid.vegas/dickserv)
      3 # imdb.py
      4 
      5 import re
      6 
      7 import config
      8 import httplib
      9 
     10 def check(url):
     11 	found = re.match('^.*?imdb.com\/title\/tt([0-9A-Za-z]+).*?$', url, re.IGNORECASE)
     12 	if found:
     13 		return found.group(1)
     14 	else:
     15 		return False
     16 
     17 def search(query):
     18 	if query.startswith('tt') and len(query) == 9:
     19 		api = httplib.get_json(f'http://omdbapi.com/?i={query}&apikey={config.api.omdbapi_key}')
     20 	else:
     21 		year = query.split()[-1]
     22 		if len(year) == 4 and year.isdigit():
     23 			query = query[:-5].replace(' ', '%20')
     24 			api = httplib.get_json(f'http://omdbapi.com/?t={query}&y={year}&apikey={config.api.omdbapi_key}')
     25 		else:
     26 			query = query.replace(' ', '%20')
     27 			api = httplib.get_json(f'http://omdbapi.com/?t={query}&apikey={config.api.omdbapi_key}')
     28 	if api['Response'] == 'True':
     29 		return api
     30 	else:
     31 		return False