2012-04-09 12:11:03 +00:00
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
import re
|
|
|
|
import http.client
|
|
|
|
|
2012-05-18 09:38:50 +00:00
|
|
|
idAtom = "http://musik.p0m.fr/atom.php?nemubot"
|
2012-04-09 12:11:03 +00:00
|
|
|
URLS = dict ()
|
|
|
|
|
|
|
|
def load_module(datas_path):
|
|
|
|
"""Load this module"""
|
|
|
|
global URLS
|
|
|
|
URLS = dict ()
|
|
|
|
|
|
|
|
def save_module():
|
|
|
|
"""Save the dates"""
|
|
|
|
return
|
|
|
|
|
|
|
|
def help_tiny ():
|
|
|
|
"""Line inserted in the response to the command !help"""
|
2012-04-18 21:35:58 +00:00
|
|
|
return "music extractor"
|
2012-04-09 12:11:03 +00:00
|
|
|
|
|
|
|
def help_full ():
|
2012-04-18 21:35:58 +00:00
|
|
|
return "To launch a convertion task, juste paste a youtube link (or compatible service) and wait for nemubot answer!"
|
2012-04-09 12:11:03 +00:00
|
|
|
|
|
|
|
def parseanswer(msg):
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
def parseask(msg):
|
|
|
|
return False
|
|
|
|
|
|
|
|
def parselisten (msg):
|
|
|
|
global URLS
|
|
|
|
matches = [".*(http://(www\.)?youtube.com/watch\?v=([a-zA-Z0-9_-]{11})).*",
|
|
|
|
".*(http://(www\.)?youtu.be/([a-zA-Z0-9_-]{11})).*"]
|
|
|
|
for m in matches:
|
|
|
|
res = re.match (m, msg.content)
|
|
|
|
if res is not None:
|
|
|
|
#print ("seen : %s"%res.group(1))
|
|
|
|
URLS[res.group(1)] = msg
|
|
|
|
conn = http.client.HTTPConnection("musik.p0m.fr")
|
|
|
|
conn.request("GET", "/?nemubot&a=add&url=%s"%(res.group (1)))
|
|
|
|
conn.getresponse()
|
|
|
|
conn.close()
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def send_global (origin, msg):
|
|
|
|
if origin in URLS:
|
|
|
|
URLS[origin].send_chn (msg)
|
|
|
|
del URLS[origin]
|