Esempio n. 1
0
def getInfo(urls):
    ##  returns list of tupels (name, size (in bytes), status (see database.File), url)

    apiurl = "http://api.netload.in/info.php"
    id_regex = re.compile(NetloadIn.__pattern)
    urls_per_query = 80

    for chunk in chunks(urls, urls_per_query):
        ids = ""
        for url in chunk:
            match = id_regex.search(url)
            if match:
                ids = ids + match.group('ID') + ";"

        api = getURL(apiurl,
                     get={'auth'   : "Zf9SnQh9WiReEsb18akjvQGqT0I830e8",
                          'bz'     : 1,
                          'md5'    : 1,
                          'file_id': ids},
                     decode=True)

        if api is None or len(api) < 10:
            self.logDebug("Prefetch failed")
            return

        if api.find("unknown_auth") >= 0:
            self.logDebug("Outdated auth code")
            return

        result = []

        for i, r in enumerate(api.splitlines()):
            try:
                tmp = r.split(";")

                try:
                    size = int(tmp[2])
                except Exception:
                    size = 0

                result.append((tmp[1], size, 2 if tmp[3] == "online" else 1, chunk[i] ))

            except Exception:
                self.logDebug("Error while processing response: %s" % r)

        yield result
Esempio n. 2
0
def getInfo(urls):
    result = []
    for chunk in chunks(urls, 10):
        for url in chunk:
            html = getURL(url)
            if r'<div class="errorMessage mb10">' in html:
                result.append((url, 0, 1, url))
            elif r'Page cannot be displayed' in html:
                result.append((url, 0, 1, url))
            else:
                try:
                    url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>'
                    file_name = re.search(url_pattern, html).group(0).split(', event)">')[1].split('</a>')[0]
                    result.append((file_name, 0, 2, url))
                except Exception:
                    pass

        # status 1=OFFLINE, 2=OK, 3=UNKNOWN
        # result.append((#name,#size,#status,#url))
        yield result
Esempio n. 3
0
def getInfo(urls):
    result = []
    for chunk in chunks(urls, 10):
        for url in chunk:
            html = getURL(url)
            if r'<div class="errorMessage mb10">' in html:
                result.append((url, 0, 1, url))
            elif r'Page cannot be displayed' in html:
                result.append((url, 0, 1, url))
            else:
                try:
                    url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>'
                    file_name = re.search(
                        url_pattern,
                        html).group(0).split(', event)">')[1].split('</a>')[0]
                    result.append((file_name, 0, 2, url))
                except Exception:
                    pass

        # status 1=OFFLINE, 2=OK, 3=UNKNOWN
        # result.append((#name,#size,#status,#url))
        yield result
Esempio n. 4
0
def getInfo(urls):
    for chunk in chunks(urls, 100):
        yield checkFile(FileserveCom, chunk)
Esempio n. 5
0
def getInfo(urls):
    for chunk in chunks(urls, 100):
        yield checkFile(FileserveCom, chunk)