summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-02-08 13:04:21 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2010-02-08 13:04:21 +0100
commit9ab155e95db32e03ca6438df12d38500f9d437f9 (patch)
treecf3ba616032324fc5be9ce572b8f239fec39ac31
parentFlashGot + ClickNLoad Support + Webif. improvm.!! pyLoad FTW !! (diff)
downloadpyload-9ab155e95db32e03ca6438df12d38500f9d437f9.tar.xz
fixed click'n'load, added youtube hd option
-rw-r--r--module/Plugin.py15
-rw-r--r--module/XMLConfigParser.py23
-rw-r--r--module/config/plugin_default.xml2
-rw-r--r--module/plugins/hooks/ClickAndLoad.py4
-rw-r--r--module/plugins/hoster/YoutubeCom.py17
5 files changed, 50 insertions, 11 deletions
diff --git a/module/Plugin.py b/module/Plugin.py
index 5006da8dd..8ee882815 100644
--- a/module/Plugin.py
+++ b/module/Plugin.py
@@ -115,19 +115,26 @@ class Plugin():
self.req.download(url, location)
def set_config(self):
- for k, v in self.config:
- self.configparser.set(self.props['name'], k, v)
+ for k, v in self.config.items():
+ self.configparser.set(self.props['name'], {"option": k}, v)
- def get_config(self, value):
+ def remove_config(self, option):
+ self.configparser.remove(self.props['name'], option)
+
+ def get_config(self, value, default=None):
self.configparser.loadData()
- return self.configparser.get(self.props['name'], value)
+ return self.configparser.get(self.props['name'], value, default=default)
def read_config(self):
self.configparser.loadData()
try:
+ self.verify_config()
self.config = self.configparser.getConfig()[self.props['name']]
except:
pass
+
+ def verify_config(self):
+ pass
def init_ocr(self):
modul = __import__("module.plugins.captcha." + self.props['name'], fromlist=['captcha'])
diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py
index 678338b41..8be2df048 100644
--- a/module/XMLConfigParser.py
+++ b/module/XMLConfigParser.py
@@ -131,11 +131,30 @@ class XMLConfigParser():
self._setAttributes(section, data)
self.saveData()
self.loadData()
+
+ def remove(self, section, option):
+ root = self.root
+ for node in root.childNodes:
+ if node.nodeType == node.ELEMENT_NODE:
+ if section == node.tagName:
+ for opt in node.childNodes:
+ if opt.nodeType == opt.ELEMENT_NODE:
+ if option == opt.tagName:
+ node.removeChild(opt)
+ self.saveData()
+ return
+
def _setAttributes(self, node, data):
option = self.root.getElementsByTagName(node)[0].getElementsByTagName(data["option"])[0]
- option.setAttribute("name", data["name"])
- option.setAttribute("type", data["type"])
+ try:
+ option.setAttribute("name", data["name"])
+ except:
+ pass
+ try:
+ option.setAttribute("type", data["type"])
+ except:
+ pass
try:
option.setAttribute("input", data["input"])
except:
diff --git a/module/config/plugin_default.xml b/module/config/plugin_default.xml
index 43c220516..c1261e338 100644
--- a/module/config/plugin_default.xml
+++ b/module/config/plugin_default.xml
@@ -22,7 +22,7 @@
<password></password>
</ShareonlineBiz>
<YoutubeCom>
- <high_quality>True</high_quality>
+ <quality>hd</quality><!-- hd: high definition, hq: high quality, sd: standard definition -->
</YoutubeCom>
<YoutubeChannel>
<!-- False for no limitation -->
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index 83a328276..f7c12356b 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -36,7 +36,7 @@ class ClickAndLoad(Hook):
self.props = props
self.port = int(self.core.config['webinterface']['port'])
- if not self.core.config['webinterface']['activated']:
+ if self.core.config['webinterface']['activated']:
forwarder('127.0.0.1', 9666, '127.0.0.1', self.port)
thread.start_new_thread(asyncore.loop, ())
@@ -109,4 +109,4 @@ class sender(asyncore.dispatcher):
def handle_close(self):
self.close()
- self.receiver.close() \ No newline at end of file
+ self.receiver.close()
diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py
index 38a4934df..19fc1099d 100644
--- a/module/plugins/hoster/YoutubeCom.py
+++ b/module/plugins/hoster/YoutubeCom.py
@@ -34,10 +34,23 @@ class YoutubeCom(Plugin):
videoId = self.parent.url.split("v=")[1].split("&")[0]
videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1)
quality = ""
- if self.config['high_quality']:
+ if self.config['quality'] == "sd":
+ quality = "&fmt=6"
+ elif self.config['quality'] == "hq":
quality = "&fmt=18"
+ elif self.config['quality'] == "hd":
+ quality = "&fmt=22"
file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality
return file_url
+
+ def verify_config(self):
+ q = self.get_config("quality")
+ if not (q == "hq" or q == "hd" or q == "sd"):
+ self.config["quality"] = "hd"
+ hq = self.get_config("high_quality")
+ if hq:
+ self.remove_config("high_quality")
+ self.set_config()
def get_file_name(self):
if self.html == None:
@@ -45,7 +58,7 @@ class YoutubeCom(Plugin):
file_name_pattern = r"'VIDEO_TITLE': '(.*)',"
file_suffix = ".flv"
- if self.config['high_quality']:
+ if self.config['quality'] == "hd" or self.config['quality'] == "hq":
file_suffix = ".mp4"
name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix