Exemple #1
0
 def handle_starttag(self, tag, attrs):
     if tag == "a":
         for item in attrs:
             if item[0] == "href":
                 url = item[1]
                 if not download.is_remote(item):
                     #fix relative links
                     url = download.path_join(self.url, url)
                 if not url.startswith("mailto:"):
                     self.urls.append(url)
Exemple #2
0
 def handle_starttag(self, tag, attrs):
     if tag == "a":
         for item in attrs:
             if item[0] == "href":
                 url = item[1]
                 if not download.is_remote(item):
                     #fix relative links
                     url = download.path_join(self.url, url)
                 if not url.startswith("mailto:"):
                     self.urls.append(url)
Exemple #3
0
    def check_metalink(self, src):
        '''
        Decode a metalink file, can be local or remote
        First parameter, file to download, URL or file path to download from
        Returns the results of the check in a dictonary
        '''
        self.running = True
        src = download.complete_url(src)
        
        try:
            metalinkobj = download.parse_metalink(src, nocheck=False)
        except:
            print _("ERROR parsing XML.")
            raise
            
        if not metalinkobj:
            return False
        
        if metalinkobj.type == "dynamic":
            origin = metalinkobj.origin
            if origin != src and origin != "":
                try:
                    result = self.check_metalink(origin)
                    self.running = True
                    return result
                except:
                    print "Error downloading from origin %s, not using." % origin
        
        urllist = metalinkobj.files
        if len(urllist) == 0:
            print _("No urls to download file from.")
            self.running = False
            return False

        #results = {}
        for filenode in urllist:
            #size = filenode.size
            #name = filenode.filename
            #print "=" * 79
            #print _("File") + ": %s " % name + _("Size") + ": %s" % size
            myheaders = {}
            if download.is_remote(src):
                myheaders = {'referer': src}
            self.check_file_node(filenode, myheaders)

        self.running = False
Exemple #4
0
    def check_metalink(self, src):
        '''
        Decode a metalink file, can be local or remote
        First parameter, file to download, URL or file path to download from
        Returns the results of the check in a dictonary
        '''
        self.running = True
        src = download.complete_url(src)

        try:
            metalinkobj = download.parse_metalink(src, nocheck=False)
        except:
            print _("ERROR parsing XML.")
            raise

        if not metalinkobj:
            return False

        if metalinkobj.type == "dynamic":
            origin = metalinkobj.origin
            if origin != src and origin != "":
                try:
                    result = self.check_metalink(origin)
                    self.running = True
                    return result
                except:
                    print "Error downloading from origin %s, not using." % origin

        urllist = metalinkobj.files
        if len(urllist) == 0:
            print _("No urls to download file from.")
            self.running = False
            return False

        #results = {}
        for filenode in urllist:
            #size = filenode.size
            #name = filenode.filename
            #print "=" * 79
            #print _("File") + ": %s " % name + _("Size") + ": %s" % size
            myheaders = {}
            if download.is_remote(src):
                myheaders = {'referer': src}
            self.check_file_node(filenode, myheaders)

        self.running = False