def extract_magnets(data):
    try:
        filters.information()  # print filters settings
        data = tools.clean_html(data)
        size = re.findall('Size (.*?)B', data) # list the size
        seedsPeers = re.findall('<td align="right">(.*?)</td>', data)  # list the size
        seeds = seedsPeers[0:][::2]
        peers = seedsPeers[1:][::2]
        cont = 0
        results = []
        for cm, magnet in enumerate(re.findall(r'magnet:\?[^\'"\s<>\[\]]+', data)):
            name = re.search('dn=(.*?)&',magnet).group(1) #find name in the magnet
            infohash = re.search(':btih:(.*?)&', magnet).group(1)  # find name in the magnet
            name = unquote_plus(name).replace('.', ' ').title()
            if filters.verify(name, size[cm].replace('&nbsp;', ' ')):
                    results.append({"name": name, "uri": magnet, "info_hash": infohash,
                           "size": tools.size_int(size[cm].replace('&nbsp;',' ')), "seeds": int(seeds[cm]),
                           "peers": int(peers[cm]), "language": settings.language,
                           "trackers": settings.trackers
                    })  # return le torrent
                    cont += 1
            # this is common for every provider
            else:
                settings.log('[%s]%s' % (settings.name_provider_clean, filters.reason))
            if cont == settings.max_magnets:  # limit magnets
                break
        return results
    except:
        settings.log('[%s]%s' % (settings.name_provider_clean, '>>>>>>>ERROR parsing data<<<<<<<'))
        settings.dialog.notification(settings.name_provider, '>>>>>>>>ERROR parsing data<<<<<<<<', settings.icon, 1000)
Пример #2
0
def extract_magnets(data):
    try:
        filters.information()  # print filters settings
        data = tools.clean_html(data)
        size = re.findall('Size (.*?)B', data)  # list the size
        seedsPeers = re.findall('<td align="right">(.*?)</td>',
                                data)  # list the size
        seeds = seedsPeers[0:][::2]
        peers = seedsPeers[1:][::2]
        cont = 0
        results = []
        for cm, magnet in enumerate(
                re.findall(r'magnet:\?[^\'"\s<>\[\]]+', data)):
            name = re.search('dn=(.*?)&',
                             magnet).group(1)  #find name in the magnet
            infohash = re.search(':btih:(.*?)&',
                                 magnet).group(1)  # find name in the magnet
            name = unquote_plus(name).replace('.', ' ').title()
            if filters.verify(name, size[cm].replace('&nbsp;', ' ')):
                results.append({
                    "name":
                    name,
                    "uri":
                    magnet,
                    "info_hash":
                    infohash,
                    "size":
                    tools.size_int(size[cm].replace('&nbsp;', ' ')),
                    "seeds":
                    int(seeds[cm]),
                    "peers":
                    int(peers[cm]),
                    "language":
                    settings.language,
                    "trackers":
                    settings.trackers
                })  # return le torrent
                cont += 1
            # this is common for every provider
            else:
                settings.log('[%s]%s' %
                             (settings.name_provider_clean, filters.reason))
            if cont == settings.max_magnets:  # limit magnets
                break
        return results
    except:
        settings.log(
            '[%s]%s' %
            (settings.name_provider_clean, '>>>>>>>ERROR parsing data<<<<<<<'))
        settings.dialog.notification(settings.name_provider,
                                     '>>>>>>>>ERROR parsing data<<<<<<<<',
                                     settings.icon, 1000)
Пример #3
0
def extract_magnets(data):
    try:
        filters.information()  # print filters settings
        data = tools.clean_html(data)
        rows = re.findall('fa fa-download(.*?)</td>(.*?)</td>(.*?)</td>(.*?)</td>(.*?)</td>(.*?)</td>(.*?)</td>(.*?)</tr>', data, re.S)
        size = [s[2].replace('\n                            <td>', '') for s in rows]
        seeds = [s[5].replace('\n                            <td>', '') for s in rows]
        peers = [s[6].replace('\n                            <td>', '') for s in rows]
        lname = re.findall('torrent-filename">(.*?)>(.*?)<', data, re.S)  # list the name
        cont = 0
        results = []
        for cm, magnet in enumerate(re.findall(r'magnet:\?[^\'"\s<>\[\]]+', data)):
            info_magnet = tools.Magnet(magnet)
            name = unquote_plus(lname[cm][1]).replace('.',' ').title()
            if filters.verify(name,size[cm]):
                    results.append({"name": name, "uri": magnet, "info_hash": info_magnet.hash, "size": tools.size_int(size[cm]),
                           "language": 'en', "trackers": info_magnet.trackers, "seeds": int(seeds[cm]), "peers": int(peers[cm])
                           })  # return le torrent
                    cont += 1
            else:
                settings.log('[%s]%s' % (settings.name_provider_clean, filters.reason))
            if cont == settings.max_magnets:  # limit magnets
                break
        return results
    except:
        settings.log('[%s]%s' % (settings.name_provider_clean, '>>>>>>>ERROR parsing data<<<<<<<'))
        settings.dialog.notification(settings.name_provider, '>>>>>>>>ERROR parsing data<<<<<<<<', settings.icon, 1000)