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