Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def snarfuri(phenny, input):
- if re.match(r'(?i)' + phenny.config.prefix + titlecommands, input.group()):
- return
- uri = input.group(1)
- if input.nick in ('derpy','Chance'):
- return
- try:
- if re.compile('http(s)?://(.*).(jpg|jpeg|png|gif|tiff|bmp)').match(uri):
- return None
- title = None
- youtube = re.compile('http(s)?://(www.)?youtube.(com|co.uk|ca)?/watch.*\?.*v\=\w+')
- if youtube.match(uri) or re.compile('http(s)?://youtu.be/(.*)').match(uri):
- # due to changes in how Youtube gives out API access, we need a key from the config file
- if get_youtube_title is None:
- phenny.say("Sorry " + input.nick + " but you need to fix your URL.")
- else:
- title = get_youtube_title(uri, phenny.config.youtube_api_key)
- fimfiction = re.compile('http(s)?://(www.)?fimfiction.net/story/')
- if fimfiction.match(uri):
- title = get_story_title(uri)
- if re.compile('http(s)?://(www.)?((e621)|(e926)).net/post/show/').match(uri): #e621 or e926 link
- title = ouroboros('e621',uri)
- if re.compile('http(s)?://(www.)?twentypercentcooler.net/post/show/').match(uri):
- title = ouroboros('twentypercentcooler',uri)
- if re.compile('http(s)?://(www.)?derpiboo((.ru)|(ru.org))(/images)?/').match(uri):
- title = derpibooru(uri)
- if title:
- phenny.msg(input.sender, '[ ' + title + ' ]')
- else:
- title = gettitle(uri)
- if title: phenny.msg(input.sender, '[ ' + title + ' ]')
- except http.client.HTTPException:
- return
- snarfuri.rule = r'.*(http[s]?://[^<> "\x01]+)[,.]?'
- snarfuri.priority = 'low'
Advertisement
Add Comment
Please, Sign In to add comment