Add documentation

This commit is contained in:
Némunaire 2014-06-21 16:27:47 +02:00
parent 766347bfc4
commit 42bf375491

View File

@ -15,6 +15,7 @@ class ytd(youtube_dl.YoutubeDL):
def get_extractor(url):
"""Get first matching extractor for the given URL"""
extractors = youtube_dl.extractor.gen_extractors()
for e in extractors:
@ -23,6 +24,7 @@ def get_extractor(url):
return None
def get_downloader(url):
"""Return an initialized downloader for the given URL"""
info = get_informations(url)
info["url"] = url
@ -32,6 +34,7 @@ def get_downloader(url):
return downloader(y, y.params)
def download_video(fd, info, hooks=list()):
"""Realy download the link"""
try:
for ph in hooks:
fd.add_progress_hook(ph)
@ -46,11 +49,13 @@ def download_video(fd, info, hooks=list()):
return u'content too short (expected %s bytes and served %s)' % (err.expected, err.downloaded)
def is_valid_URL(url):
"""True if an extractor is found"""
e = get_extractor(url)
return e is not None and type(e) != youtube_dl.extractor.GenericIE
def get_informations(url, ie=None):
"""Get movie's information"""
if ie is None:
ie = get_extractor(url)
@ -58,6 +63,7 @@ def get_informations(url, ie=None):
return ie.extract(url)
def dict_to_xml(fdict, parent, newdoc):
"""Generate a XML tree from a Python dictionnary"""
for k, i in fdict.items():
node = newdoc.createElement(k)
if i is None:
@ -77,6 +83,7 @@ def dict_to_xml(fdict, parent, newdoc):
parent.appendChild(node)
def gen_error(status, txt=""):
"""Generate a XML tree for error purpose"""
impl = getDOMImplementation()
newdoc = impl.createDocument(None, "gearman_musik", None)