コード例 #1
0
ファイル: megaupload.py プロジェクト: bmravec/DownMan
class MUDecryptor (GenericHost):
    status = 'Unchecked'

    def __init__ (self, url, downman):
        self.url = url
        self.name = url
        self.total = 0

        self.folderid = re.search ('\?f=([A-Za-z0-9]+)', self.url).group (1)

    def start_get_info (self):
        self.tfile = TempFile ('http://megaupload.com/xml/folderfiles.php?folderid=%s' % (self.folderid))
        self.tfile.completed_cb = self.handle_tfile_done
        self.tfile.start ()

    def handle_tfile_done (self, tfile):
        rows = re.findall ('<ROW .*?</ROW>', tfile.contents)

        if len (rows) != 0:
            self.links = []

        for row in rows:
            self.links.append (re.search ('url="([^"]*)"', row).group (1))

        self.set_state (STATE_INFO_COMPLETED)
コード例 #2
0
ファイル: generichost.py プロジェクト: bmravec/DownMan
class GenericHost (Download):
    proto = 'http'
    case_handlers = []
    pdtotal = 0

    def __init__ (self, url, downman):
        self.url = url
        self.name = url
        self.downman = downman
        self.speed = downman.speedlimit.create_download ()

    def start_get_info (self):
        self.tfile = TempFile (self.url)
        self.tfile.completed_cb = self.stage_download_completed
        self.tfile.start ()

        self.set_state (STATE_INFO)

    def start_download (self):
        self.tfile = TempFile (self.url)
        self.tfile.completed_cb = self.stage_download_completed
        self.tfile.start ()

        self.set_state (STATE_CONNECTING)

    def stage_download_completed (self, tfile):
        for handler in self.case_handlers:
            m = re.search (handler[0], self.tfile.contents)
            if m != None:
                handler[1] (m)

    def download_completed (self, wfile):
        self.status = 'Download Complete'
        self.set_state (STATE_COMPLETED)

    def download_progress (self, dt, dd, ut, ud):
        self.downloaded = dd
        if dt != 0:
            self.total = dt

        diff = dd - self.pdtotal
        self.pdtotal = dd
        val = self.speed.update_downloaded (diff)
        self.speed.wait (val)

    def print_progress (self, num):
        self.status = 'Starting in %d seconds' % (num)

    def close (self):
        if self.tfile:
            self.tfile.close ()