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(' ', ' ')): results.append({"name": name, "uri": magnet, "info_hash": infohash, "size": tools.size_int(size[cm].replace(' ',' ')), "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)
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)
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(' ', ' ')): results.append({ "name": name, "uri": magnet, "info_hash": infohash, "size": tools.size_int(size[cm].replace(' ', ' ')), "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)
def extract_torrents(data): try: filters.information() # print filters settings data = tools.clean_html(data) size = re.findall('</td><td>(.*?)</td><td>(.*?)</td><td>(.*?)B</td>', data) # list the size cont = 0 results = [] for cm, magnet in enumerate(re.findall(r'magnet:\?[^\'"\s<>\[\]]+', data)): name = re.search('dn=(.*?)&tr=',magnet).group(1) #find name in the magnet name = unquote_plus(name).replace('.', ' ') if filters.verify(size[cm][2] + 'B' + ' - ' + name, size[cm][2]): results.append({"name": name, "uri": magnet}) # 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)
def getPosts(blog): if blog.url.endswith('persianblog.ir'): url = "http://%s/rss.xml" % (blog.url) else: url = "http://%s/rss" % (blog.url) print "going to parse: ", url feed = feedparser.parse(url) for entry in feed.entries: if postExists(entry['link']): continue post = Post() post.title = entry['title'] post.text = clean_html(entry['description']) if hasattr(entry, 'published_parsed'): post.date = datetime.fromtimestamp(mktime(entry['published_parsed'])) elif hasattr(entry, 'updated_parsed'): post.date = datetime.fromtimestamp(mktime(entry['updated_parsed'])) else: post.date = datetime.now() post.url = entry['link'] post.blog = blog post.save() return feed