summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 17:05:45 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-07-29 17:05:45 +0200
commit252cf9964a2ebc78a589f75db2a7be0d25cac512 (patch)
tree0f4cd1a7949f8a3dc87eaed35f248170ee421943 /module/plugins
parentmany new stuff, some things already working (diff)
downloadpyload-252cf9964a2ebc78a589f75db2a7be0d25cac512.tar.xz
more improvements and cleaned some imports
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/Hook.py29
-rw-r--r--module/plugins/Plugin.py14
-rw-r--r--module/plugins/captcha/captcha.py1
-rw-r--r--module/plugins/container/LinkList.py1
-rw-r--r--module/plugins/crypter/CryptItCom.py2
-rw-r--r--module/plugins/hooks/ClickAndLoad.py1
-rw-r--r--module/plugins/hoster/Ftp.py1
-rw-r--r--module/plugins/hoster/PornhostCom.py2
-rw-r--r--module/plugins/hoster/PornhubCom.py2
-rw-r--r--module/plugins/hoster/RedtubeCom.py1
-rw-r--r--module/plugins/hoster/YourFilesTo.py1
-rw-r--r--module/plugins/hoster/YoutubeCom.py83
12 files changed, 48 insertions, 90 deletions
diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py
index 45435b2f6..ed62cbdb2 100644
--- a/module/plugins/Hook.py
+++ b/module/plugins/Hook.py
@@ -18,7 +18,6 @@
@interface-version: 0.2
"""
-import logging
class Hook():
@@ -26,26 +25,17 @@ class Hook():
__version__ = "0.2"
__type__ = "hook"
__description__ = """interface for hook"""
- __author_name__ = ("mkaay")
- __author_mail__ = ("mkaay@mkaay.de")
+ __author_name__ = ("mkaay", "RaNaN")
+ __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org")
def __init__(self, core):
- self.logger = logging.getLogger("log")
- self.configParser = core.parser_plugins
- self.config = {}
- self.core = core
-
- def readConfig(self):
- self.configParser.loadData()
- section = self.__name__
- try:
- self.config = self.configParser.getConfig()[section]
- except:
- self.setup()
-
+ self.core = core
+ self.log = core.log
+
+ self.setup()
+
def setup(self):
- self.configParser.set(self.__name__, {"option": "activated", "type": "bool", "name": "Activated"}, True)
- self.readConfig()
+ pass
def isActivated(self):
return self.config["activated"]
@@ -60,9 +50,6 @@ class Hook():
pass
def packageFinished(self, pypack):
- """
- not implemented!
- """
pass
def beforeReconnecting(self, ip):
diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py
index 51cd78f2d..e8df540a8 100644
--- a/module/plugins/Plugin.py
+++ b/module/plugins/Plugin.py
@@ -18,7 +18,6 @@
"""
import logging
-import re
from os.path import exists
from os.path import join
@@ -89,8 +88,14 @@ class Plugin(object):
self.pyfile = pyfile
self.thread = None # holds thread in future
+ self.setup()
+
def __call__(self):
return self.__name__
+
+ def setup(self):
+ """ more init stuff if needed """
+ pass
def preprocessing(self, thread):
""" handles important things to do before starting """
@@ -98,6 +103,8 @@ class Plugin(object):
if not self.account:
self.req.clearCookies()
+
+ self.pyfile.setStatus("starting")
return self.process(self.pyfile)
@@ -178,6 +185,9 @@ class Plugin(object):
def download(self, url, get={}, post={}, ref=True, cookies=True):
""" downloads the url content to disk """
+
+ self.pyfile.setStatus("downloading")
+
download_folder = self.config['general']['download_folder']
location = join(download_folder, self.pyfile.package().folder.decode(sys.getfilesystemencoding()))
@@ -187,5 +197,7 @@ class Plugin(object):
newname = self.req.download(url, self.pyfile.name, location, get, post, ref, cookies)
+ self.pyfile.size = self.req.dl_size
+
if newname:
self.pyfile.name = newname
diff --git a/module/plugins/captcha/captcha.py b/module/plugins/captcha/captcha.py
index db229c747..501a57737 100644
--- a/module/plugins/captcha/captcha.py
+++ b/module/plugins/captcha/captcha.py
@@ -22,7 +22,6 @@ import logging
import subprocess
import tempfile
import threading
-from os import remove
import Image
diff --git a/module/plugins/container/LinkList.py b/module/plugins/container/LinkList.py
index 1651b91ed..9321c658f 100644
--- a/module/plugins/container/LinkList.py
+++ b/module/plugins/container/LinkList.py
@@ -3,7 +3,6 @@
from module.plugins.Container import Container
-from os import linesep
class LinkList(Container):
__name__ = "LinkList"
diff --git a/module/plugins/crypter/CryptItCom.py b/module/plugins/crypter/CryptItCom.py
index cc9af8dd6..4dff06b21 100644
--- a/module/plugins/crypter/CryptItCom.py
+++ b/module/plugins/crypter/CryptItCom.py
@@ -24,7 +24,7 @@ class CryptItCom(Crypter):
def file_exists(self):
html = self.load(self.parent.url)
- if r'<div class="folder">Was ist Crypt-It</div>' in html):
+ if r'<div class="folder">Was ist Crypt-It</div>' in html:
return False
return True
diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py
index adb26eab0..536df64d5 100644
--- a/module/plugins/hooks/ClickAndLoad.py
+++ b/module/plugins/hooks/ClickAndLoad.py
@@ -18,7 +18,6 @@
@interface-version: 0.2
"""
-import asyncore
import socket
import thread
diff --git a/module/plugins/hoster/Ftp.py b/module/plugins/hoster/Ftp.py
index dc536fa1f..83daa9257 100644
--- a/module/plugins/hoster/Ftp.py
+++ b/module/plugins/hoster/Ftp.py
@@ -22,7 +22,6 @@ from os.path import exists
from os.path import join
from os.path import exists
from os import makedirs
-import re
import sys
from module.plugins.Hoster import Hoster
diff --git a/module/plugins/hoster/PornhostCom.py b/module/plugins/hoster/PornhostCom.py
index 92bc93f24..db256c2ec 100644
--- a/module/plugins/hoster/PornhostCom.py
+++ b/module/plugins/hoster/PornhostCom.py
@@ -2,9 +2,7 @@
# -*- coding: utf-8 -*-
import re
-from time import time
from module.plugins.Hoster import Hoster
-from module.unescape import unescape
class PornhostCom(Hoster):
__name__ = "PornhostCom"
diff --git a/module/plugins/hoster/PornhubCom.py b/module/plugins/hoster/PornhubCom.py
index c5fda76ae..61c388fec 100644
--- a/module/plugins/hoster/PornhubCom.py
+++ b/module/plugins/hoster/PornhubCom.py
@@ -2,9 +2,7 @@
# -*- coding: utf-8 -*-
import re
-from time import time
from module.plugins.Hoster import Hoster
-from module.unescape import unescape
class PornhubCom(Hoster):
__name__ = "PornhubCom"
diff --git a/module/plugins/hoster/RedtubeCom.py b/module/plugins/hoster/RedtubeCom.py
index 3d97e12d6..6cbd6416e 100644
--- a/module/plugins/hoster/RedtubeCom.py
+++ b/module/plugins/hoster/RedtubeCom.py
@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
import re
-from time import time
from module.plugins.Hoster import Hoster
from module.unescape import unescape
diff --git a/module/plugins/hoster/YourFilesTo.py b/module/plugins/hoster/YourFilesTo.py
index 714e37bb2..04941f759 100644
--- a/module/plugins/hoster/YourFilesTo.py
+++ b/module/plugins/hoster/YourFilesTo.py
@@ -4,7 +4,6 @@
import re
import urllib
from module.plugins.Hoster import Hoster
-from module.unescape import unescape
from time import time
class YourfilesTo(Hoster):
diff --git a/module/plugins/hoster/YoutubeCom.py b/module/plugins/hoster/YoutubeCom.py
index 978d89a37..e40b0c9ad 100644
--- a/module/plugins/hoster/YoutubeCom.py
+++ b/module/plugins/hoster/YoutubeCom.py
@@ -9,71 +9,40 @@ class YoutubeCom(Hoster):
__type__ = "hoster"
__pattern__ = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=.*"
__version__ = "0.2"
- __config__ = [ ("int", "quality" , "Quality Setting", "hd;lq"),
- ("int", "config", "Config Settings" , "default" ) ]
+ __config__ = [ ("quality", "str" , "Quality Setting", "hd") ]
__description__ = """Youtube.com Video Download Hoster"""
__author_name__ = ("spoob")
__author_mail__ = ("spoob@pyload.org")
-
- def __init__(self, parent):
- Hoster.__init__(self, parent)
- self.parent = parent
- self.html = None
- self.read_config()
- self.hd_available = False
-
- def download_html(self):
- url = self.parent.url
- self.html = self.load(url)
-
- def get_file_url(self):
- """ returns the absolute downloadable filepath
- """
- if self.html == None:
- self.download_html()
-
- videoId = self.parent.url.split("v=")[1].split("&")[0]
- videoHash = re.search(r'&t=(.+?)&', self.html).group(1)
- quality = ""
- if self.config['quality'] == "sd":
- quality = "&fmt=6"
- elif self.config['quality'] == "hd" and self.hd_available:
- quality = "&fmt=22"
- else:
- quality = "&fmt=18"
- 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:
- self.download_html()
+ def process(self, pyfile):
+ html = self.load(pyfile.url)
+
+ if re.search(r"(.*eine fehlerhafte Video-ID\.)", html) != None:
+ self.offline()
+
+ videoId = pyfile.url.split("v=")[1].split("&")[0]
+ videoHash = re.search(r'&t=(.+?)&', html).group(1)
+
+
file_name_pattern = '<meta name="title" content="(.+?)">'
is_hd_pattern = r"'IS_HD_AVAILABLE': (false|true)"
file_suffix = ".flv"
- is_hd = re.search(is_hd_pattern, self.html).group(1)
- self.hd_available = (is_hd == "true")
- if self.config['quality'] == "hd" or self.config['quality'] == "hq":
+ is_hd = re.search(is_hd_pattern, html).group(1)
+ hd_available = (is_hd == "true")
+
+ if self.getConf("quality") == "hd" or self.getConf("quality") == "hq":
file_suffix = ".mp4"
- name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix
+ name = re.search(file_name_pattern, html).group(1).replace("/", "") + file_suffix
- name = name.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
- return name
+ pyfile.name = name.replace("&amp;", "&").replace("ö", "oe").replace("ä", "ae").replace("ü", "ue")
- def file_exists(self):
- """ returns True or False
- """
- if self.html == None:
- self.download_html()
- if re.search(r"(.*eine fehlerhafte Video-ID\.)", self.html) != None:
- return False
+ if self.getConf("quality") == "sd":
+ quality = "&fmt=6"
+ elif self.getConf("quality") == "hd" and hd_available:
+ quality = "&fmt=22"
else:
- return True
+ quality = "&fmt=18"
+
+ file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality + "&asv=2"
+
+ self.download(file_url) \ No newline at end of file