Commits

draugr committed b01c323

hoster 180UploadCom (first working version)

Comments (0)

Files changed (1)

module/plugins/hoster/OneEightyUploadCom.py

+from module.plugins.Hoster import Hoster
+from module.lib.BeautifulSoup import BeautifulSoup, SoupStrainer
+from module.network.RequestFactory import getRequest
+
+class OneEightyUploadCom(Hoster):
+    
+    __name__ = "180UploadCom"
+    __version__ = "0.1"
+    __pattern__ = r"http://180upload.com/.*"
+    __config__ = []
+    __author__ = 'draugr'
+    
+    def init(self):
+        self.httpReq = getRequest(Hoster.__name__)
+
+    def loadHtml(self, url, postData={}):
+        trycount = 0
+        html = ''
+        
+        while trycount < 3:
+            try:
+                trycount += 1
+                html = self.httpReq.load(url, post=postData)
+                break
+            except:
+                if trycount == 3:
+                    self.logError('Failed to download website content (%s)' % url)
+                else:
+                    sleep(0.2)
+        return html
+    
+    def process(self, pyfile):
+        html = self.loadHtml(pyfile.url)
+
+        formStrainer = SoupStrainer('form', {'name': 'F1'} )
+        formSoup = BeautifulSoup(html, parseOnlyThese=formStrainer)
+        
+        #pyfile.name = showLinkSoup.form.table.tr.contents[3].string
+        pyfile.name = formSoup.form.table.tr.find( 'td', {'nowrap': 'nowrap'} ).string.strip()
+        
+        postDta = ''
+        for inp in formSoup.form.findAll( 'input', {'type': 'hidden'} ):
+            postDta += inp['name'] + '=' + inp['value'] + '&'
+        postDta = postDta[:-1]
+        
+        html = self.loadHtml(pyfile.url, postData=postDta)
+        
+        linkStrainer = SoupStrainer('a')
+        downloadSoup = BeautifulSoup(html, parseOnlyThese=linkStrainer)
+        
+        downloadImg = downloadSoup.find('img', {'src': 'http://www.180upload.com/images/downloadbutton.png'})
+        if downloadImg.parent.has_key('href'):
+            self.download(downloadImg.parent['href'])