diff options
| -rw-r--r-- | Plugins/BluehostTo.py | 71 | ||||
| -rw-r--r-- | Plugins/ShragleCom.py | 70 | ||||
| -rw-r--r-- | Plugins/YoutubeChannel.py | 41 | ||||
| -rw-r--r-- | Plugins/YoutubeCom.py | 2 | ||||
| -rwxr-xr-x | module/network/Request.py | 25 | 
5 files changed, 202 insertions, 7 deletions
| diff --git a/Plugins/BluehostTo.py b/Plugins/BluehostTo.py new file mode 100644 index 000000000..80ed1e61b --- /dev/null +++ b/Plugins/BluehostTo.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +import re +import time + +from Plugin import Plugin + +class BluehostTo(Plugin): + +    def __init__(self, parent): +        Plugin.__init__(self, parent) +        props = {} +        props['name'] = "BluehostTo" +        props['type'] = "hoster" +        props['pattern'] = r"http://(?:www.)?bluehost.to/file/" +        props['version'] = "0.1" +        props['description'] = """Bluehost Download PLugin""" +        props['author_name'] = ("RaNaN") +        props['author_mail'] = ("RaNaN@pyload.org") +        self.props = props +        self.parent = parent +        self.html = None +        self.multi_dl = False +         +    def download_html(self): +        url = self.parent.url +        self.html = self.req.load(url) +        time.sleep(1.5) +        self.html = self.req.load(url, cookies=True) +        print self.html + +    def get_file_url(self): +        """ returns the absolute downloadable filepath +        """ +        if self.html == None: +            self.download_html() +             +        #@todo: regexp not correct, value switches its position + + +        self.BluehostVers2dl = re.search(r"(name=\"BluehostVers2dl\")?.{1,10}value=\"([^\"]+).{1,10}(name=\"BluehostVers2dl\")?", self.html).group(2) +        print self.BluehostVers2dl +        self.DownloadV2Hash = re.search(r"value=\"([^\"]+) name=\"DownloadV2Hash\"", self.html).group(1) +        print self.DownloadV2Hash +        self.PHPSESSID = re.search(r"value=\"([^\"]+) name=\"PHPSESSID\"", self.html).group(1) +        print self.PHPSESSID +        self.access = re.search(r"value=\"([^\"]+) name=\"access\"", self.html).group(1) +        print self.access +         +        url = re.search("<form target=\"_self\" action=\"([^\"]+", self.html).group(1) +        return url + +    def get_file_name(self): +        if self.html == None: +            self.download_html() +        file_name_pattern = r"<center><b>.+: (.+)<\/b><\/center>" +        return re.search(file_name_pattern, self.html).group(1) + +    def file_exists(self): +        """ returns True or False +        """ +        if self.html == None: +            self.download_html() + +        if re.search(r"html", self.html) == None: +            return False +        else: +            return True + +    def proceed(self, url, location): +        return False +        self.req.download(url, location, {'BluehostVers2dl': self.BluehostVers2dl, 'DownloadV2Hash': self.DownloadV2Hash, 'PHPSESSID': self.PHPSESSID, 'access': self.access})
\ No newline at end of file diff --git a/Plugins/ShragleCom.py b/Plugins/ShragleCom.py new file mode 100644 index 000000000..45f416872 --- /dev/null +++ b/Plugins/ShragleCom.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +import re +import time + +from Plugin import Plugin + +class ShragleCom(Plugin): + +    def __init__(self, parent): +        Plugin.__init__(self, parent) +        props = {} +        props['name'] = "ShragleCom" +        props['type'] = "hoster" +        props['pattern'] = r"http://(?:www.)?shragle.com/files/" +        props['version'] = "0.1" +        props['description'] = """Shragle Download PLugin""" +        props['author_name'] = ("RaNaN") +        props['author_mail'] = ("RaNaN@pyload.org") +        self.props = props +        self.parent = parent +        self.html = None +        self.multi_dl = False + +    def set_parent_status(self): +        """ sets all available Statusinfos about a File in self.parent.status +        """ +        if self.html == None: +            self.download_html() +        self.parent.status.filename = self.get_file_name() +        self.parent.status.url = self.get_file_url() +        self.parent.status.wait = self.wait_until() + +    def download_html(self): +        url = self.parent.url +        self.html = self.req.load(url) +        self.time_plus_wait = time.time() + 10 + +    def get_file_url(self): +        """ returns the absolute downloadable filepath +        """ +        if self.html == None: +            self.download_html() + +        self.fileID = re.search(r"name=\"fileID\" value=\"([^\"]+)", self.html).group(1) +        self.dlSession = re.search(r"name=\"dlSession\" value=\"([^\"]+)", self.html).group(1) +        self.userID = "" +        self.password = "" +        self.lang = "de" +        return "http://srv4.shragle.com/download.php" + +    def get_file_name(self): +        if self.html == None: +            self.download_html() + +        file_name_pattern = r"<\/div><h2>(.+)<\/h2" +        return re.search(file_name_pattern, self.html).group(1) + +    def file_exists(self): +        """ returns True or False +        """ +        if self.html == None: +            self.download_html() +             +        if re.search(r"html", self.html) == None: +            return False +        else: +            return True + +    def proceed(self, url, location): +        self.req.download(url, location, {'fileID': self.fileID, 'dlSession': self.dlSession, 'userID': self.userID, 'password': self.password, 'lang': self.lang})
\ No newline at end of file diff --git a/Plugins/YoutubeChannel.py b/Plugins/YoutubeChannel.py new file mode 100644 index 000000000..1a0af757e --- /dev/null +++ b/Plugins/YoutubeChannel.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python + +import re + +from Plugin import Plugin + +class YoutubeChannel(Plugin): + +    def __init__(self, parent): +        Plugin.__init__(self, parent) +        props = {} +        props['name'] = "YouTubeChannel" +        props['type'] = "container" +        props['pattern'] = r"http://(www\.)?(de\.)?\youtube\.com/user/*" +        props['version'] = "0.1" +        props['description'] = """Youtube.com Channel Download Plugin""" +        props['author_name'] = ("RaNaN") +        props['author_mail'] = ("RaNaN@pyload.org") +        self.props = props +        self.parent = parent +        self.html = None + +    def download_html(self): +        self.html = "Not needed" + +    def get_file_url(self): +        """ returns the absolute downloadable filepath +        """ +        self.user = re.search(r"/user/(.+)", self.parent.url).group(1) +        url = "http://gdata.youtube.com/feeds/api/users/" + self.user + "/uploads?max-results=50" + +        return url + +    def file_exists(self): +        """ returns True or False +        """ +        return True + +    def proceed(self, url, location): +        rep = self.req.load(url) +        self.links = re.findall(r"href\='(http:\/\/www.youtube.com\/watch\?v\=[^']+)", rep)
\ No newline at end of file diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py index d2df35686..0d738d52d 100644 --- a/Plugins/YoutubeCom.py +++ b/Plugins/YoutubeCom.py @@ -18,8 +18,6 @@ class YoutubeCom(Plugin):          self.props = props          self.parent = parent          self.html = None -        self.html_old = None         #time() where loaded the HTML -        self.time_plus_wait = None   #time() + wait in seconds      def download_html(self):          url = self.parent.url diff --git a/module/network/Request.py b/module/network/Request.py index 1bf8c8255..8e2b6ae02 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -30,7 +30,8 @@ class Request:          self.dl_size = 0          self.dl_arrived = 0          self.dl = False -	 + +        self.cookies = []          self.lastURL = None          self.cj = cookielib.CookieJar()          handler = HTTPHandler() @@ -53,7 +54,7 @@ class Request:          ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")] -    def load(self, url, get={}, post={}, ref=True): +    def load(self, url, get={}, post={}, ref=True, cookies=False):          if post:              post = urllib.urlencode(post) @@ -68,11 +69,21 @@ class Request:          url = url + get          req = urllib2.Request(url, data=post) + +          if ref and self.lastURL is not None:              req.add_header("Referer", self.lastURL) -	 + + +        if cookies: +            self.add_cookies(req) +            #add cookies +          rep = self.opener.open(req) -	 + +        for cookie in self.cj.make_cookies(rep, req): +            self.cookies.append(cookie) +          output = rep.read()          if rep.headers.has_key("content-encoding"): @@ -86,7 +97,11 @@ class Request:      def add_auth(self, user, pw):          self.downloader.addheaders.append(['Authorization', 'Basic ' + base64.encodestring(user + ':' + pw)[:-1]]) - +    def add_cookies(self, req): +        cookie_head = "" +        for cookie in self.cookies: +            cookie_head += cookie.name+"="+cookie.value+"; " +        req.add_header("Cookie", cookie_head)      #def download(url, filename, reporthook = None, data = None): #default von urlretrieve auch None?          #  return self.downloader.urlretrieve(url, filename, reporthook, data) | 
