Starting rebuild of eventsm watchSite and YouTube modules
This commit is contained in:
parent
cc106e2157
commit
5fed225358
3 changed files with 0 additions and 0 deletions
51
modules/youtube.py
Normal file
51
modules/youtube.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# coding=utf-8
|
||||
|
||||
import re
|
||||
import http.client
|
||||
|
||||
idAtom = "http://musik.p0m.fr/atom.php?nemubot"
|
||||
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"""
|
||||
return "music extractor"
|
||||
|
||||
def help_full ():
|
||||
return "To launch a convertion task, juste paste a youtube link (or compatible service) and wait for nemubot answer!"
|
||||
|
||||
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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue