def get(self, request, *args, **kwargs): form = self.form_class() torrent_form = TorrentForm() if "search_string" in request.GET: form = self.form_class(request.GET) torrent_form = TorrentForm() results = None # get cleaned form data search_string = request.GET.get("search_string", "") category_string = request.GET.get("category", "") # construct search arguments # hardcoded to get first page, sort by number of seeders in descending order t = TPB(settings.TPB_URL) category = match_category(category_string) search = t.search(search_string, category=category).order(ORDERS.SEEDERS.ASC) results = search.page(1) # set results to None if search didn't return anything results = None if get_results_length(results) == 0 else results return render(request, self.template_name, {"form": form, "results": results, "torrent_form": torrent_form}) else: return render(request, self.template_name, {"form": form, "results": None, "torrent_form": torrent_form})
class TorrentProvider(object): def __init__(self): self.provider = TPB("https://thepiratebay.pe") self.MINIMUM_SEEDS = 5 def find(self, seriename): return self._find(seriename) @timeout_decorator.timeout(15) def _find(self, seriename): print("Searching for %s" % seriename) search = self.provider.search(seriename) search.order(ORDERS.SEEDERS.ASC).multipage() torrent = True while torrent: try: torrent = next(search.items()) except StopIteration: return None except URLError: print("Can't connect to the torrent provider") return None else: if torrent.seeders > self.MINIMUM_SEEDS: return torrent.magnet_link else: print("Can't find torrent with the minimun required seeds") torrent = False
def get(self, request, *args, **kwargs): form = self.form_class() torrent_form = TorrentForm() if 'search_string' in request.GET: form = self.form_class(request.GET) torrent_form = TorrentForm() results = None # get cleaned form data search_string = request.GET.get('search_string', "") category_string = request.GET.get('category', "") # construct search arguments # hardcoded to get first page, sort by number of seeders in descending order t = TPB(settings.TPB_URL) category = match_category(category_string) search = t.search(search_string, category=category).order(ORDERS.SEEDERS.ASC) results = search.page(1) # set results to None if search didn't return anything results = None if get_results_length(results) == 0 else results return render(request, self.template_name, { 'form': form, 'results': results, 'torrent_form': torrent_form }) else: return render(request, self.template_name, { 'form': form, 'results': None, 'torrent_form': torrent_form })
def generate_search_results(self, request): query = request.GET.get('q', None) cleaned_results = [] if not query: cleaned_results = request.session.get('search_results', None) query = request.session.get('search_query', None) elif 'sanni' in query.lower(): cleaned_results = [{'display_name': 'I <3 Sanni Harrison :-D'}] else: t = TPB('https://thepiratebay.org') results = t.search(query, category=CATEGORIES.VIDEO.ALL) cleaned_results = [{'display_name': result.title, 'url': urllib.quote(result.magnet_link), 'seeder_count': result.seeders, 'leecher_count': result.leechers } for result in results] request.session['search_results'] = cleaned_results request.session['search_query'] = query return render(request, 'search_results.html', {'object_list': cleaned_results, 'search_query': query})
def get_items(self): proto = "https" if __kupfer_settings__["https"] else "http" url = proto + "://" + __kupfer_settings__["pirate_bay_host"] api = TPB(url) results = api.search(self.query) for result in results: yield UrlLeaf(result.magnet_link, result.title) yield CustomDescriptionUrl(results.url, _('Show More Results For "%s"') % self.query, _("More results"))
def search_torrent(title): result = None pirate = TPB('https://thepiratebay.org') search = pirate.search(title, category=CATEGORIES.VIDEO.MOVIES).order(ORDERS.SEEDERS.DES) for torrent in search: result = torrent break; if(result == None or result.seeders < int(get_setting("seeders"))): return None else: return result
def melhor_torrent(nome_busca, qtd = None): from tpb import TPB from tpb import CATEGORIES, ORDERS t = TPB('https://thepiratebay.se') # configurando o site do TPB # Buscando todos os tipos de Video if not qtd: search = t.search(nome_busca, category=CATEGORIES.VIDEO.ALL).order(ORDERS.SEEDERS.DES).page(0) else: search = t.search(nome_busca, category=CATEGORIES.VIDEO.ALL).order(ORDERS.SEEDERS.DES) torrents = [] for torrent in search: torrents.append(torrent) try: if not qtd: return torrents[0].magnet_link else: return torrents[0:qtd] except IndexError: return None
class ZTShows: def __init__(self): self.settings = Settings('config.yml') self.download_manager = DownloadManager(self) self.api_tpb = None self.api_tvdb = None def load(self): self.settings.load() tpb_base_url = self.settings.get('tpb_base_url') self.api_tpb = TPB( 'https://thepiratebay.se' if not tpb_base_url else tpb_base_url) tvdb_api_key = self.settings.get('tvdb_api_key') self.api_tvdb = TVDB.TVDB( '81DD35DB106172E7' if not tvdb_api_key else tvdb_api_key) def unload(self): self.settings.save() def search(self, query, callback): def work(w_callback): w_callback(self.api_tvdb.search(query, 'en')) Thread(target=work, args=(callback, )).start() print(self.download_manager.get_torrents()) def search_episode(self, episode, callback): def work(w_callback): results = self.api_tpb.search(query).order(TPB_ORDERS.SEEDERS.DES) w_callback(results) query = '{} s{:02d}e{:02d}'.format(episode.season.show.SeriesName, episode.season.season_number, episode.EpisodeNumber) Thread(target=work, args=(callback, )).start() def download(self, torrent, completion_callback=None, play_callback=None): self.download_manager.add_magnet(torrent.magnet_link, completion_callback, play_callback) def open_player(self, torrent): def work(path): os.system(path) player_path = self.settings.get('player_path').format( video='"' + self.settings.get('save_path') + torrent.handler.name() + '"', subtitles='') t = Thread(target=work, args=(player_path, )).start() t.daemon = True
def melhor_torrent(nome_busca, qtd=None): from tpb import TPB from tpb import CATEGORIES, ORDERS t = TPB('https://thepiratebay.se') # configurando o site do TPB # Buscando todos os tipos de Video if not qtd: search = t.search(nome_busca, category=CATEGORIES.VIDEO.ALL).order( ORDERS.SEEDERS.DES).page(0) else: search = t.search(nome_busca, category=CATEGORIES.VIDEO.ALL).order( ORDERS.SEEDERS.DES) torrents = [] for torrent in search: torrents.append(torrent) try: if not qtd: return torrents[0].magnet_link else: return torrents[0:qtd] except IndexError: return None
def _find_torrent(movie, minimum_torrent_quality=2): t = TPB('https://thepiratebay.org') search = t.search("%s %s" % (movie.name, _year(movie)), category=CATEGORIES.VIDEO) search.order(ORDERS.SEEDERS.DES).page(1) best_torrent = None best_torrent_quality = None for torrent in search: (created, current_time) = torrent._created quality = _torrent_quality(torrent, created, movie) if not best_torrent or quality > best_torrent_quality: best_torrent = torrent best_torrent_quality = quality if best_torrent_quality > minimum_torrent_quality: return best_torrent
class Pirate_API(): ''' This class allows my endpoints to interact with the database as well as retrieve information from ThePirateBay's database. ''' def __init__(self): self.iAPI = ImageAPI() self.config = ConfigManager() self.website = TPB( "https://thepiratebay.monster/") #Base URL for ThePirateBay def get_none(self) -> List[dict]: ''' Returns an empty torrent object @returns -> None ''' return [{"name": "", "magnet": "", "image": ""}] def get_torrents(self, req: str) -> List[dict]: ''' Gets all torrents relative to the search query. @param {str} req: The search query to be made to ThePirateBay @returns {List[dict]} 3 top torrent results sorted by seeders. ''' counter: int = 0 obj: List[dict] = [] button_id: str = "pirate_button_" button_count: int = 1 for torrent in self.website.search(req).order(ORDERS.SEEDERS.DES): if counter <= 2: obj.append({ "name": torrent.title, "magnet": torrent.magnet_link, "image_url": self.iAPI.get_image(req), "button_id": button_id + str(button_count), }) counter += 1 button_count += 1 return obj
def main(): t = TPB('https://thepiratebay.org') createTorrentDirectory() movieFile = open("movieList.txt", "r") totRes = 0 totMovies = 0 for line in movieFile.readlines(): print "MOVIE - " + line.split("\n")[0] search = t.search(line.split("\n")[0]) for torrent in search: saveTorrentInDir("./Torrents", torrent) print "\t" + torrent.title totRes += 1 totMovies += 1 print "Total Movies = " + str(totMovies) print "TotalRes = " + str(totRes)
def get_torrent(): with open(globals.json_weekly, "r") as readfile: l_weekly = json.load(readfile) for item in l_weekly: #if item.get("torrents"): # continue tpb = TPB('https://thepiratebay.org') # create a TPB object with default domain # search for 'public domain' in 'movies' category search_text = item["title"]+" "+str(item["year"]) print "*" * 10 print "Searching for:", search_text search = tpb.search(search_text, category=CATEGORIES.VIDEO).order(ORDERS.SEEDERS.DES).page(0) torrent = [v for i,v in enumerate(search) if i==0] if len(torrent) < 1: continue # 1. no torrents retrieved # 2. do have torrents and title is different, always get the top rank of torrent if (not item.get("torrents")) or \ (item.get("torrents") and item.get("torrents")[0]["title"] != torrent[0].title): item["torrents"] = [ { "title":torrent[0].title, "magnet_link":torrent[0].magnet_link, "created":str(torrent[0].created), "size":torrent[0].size, "seeders":torrent[0].seeders, "files":torrent[0].files } ] print item["torrents"][0] with open(globals.json_weekly, "w") as outfile: json.dump(l_weekly, outfile, indent=4)
class TorrentFinder: '''A class which handles finding good torrents under given keyword.''' def __init__(self): self.tpb = TPB(THEPIRATEBAY) def find(self, keyword, filters=[], min_seeders=0, category=0): '''Finds torrents under given keyword which also pass specified filters. Returns: A list of found tpb.Torrent objects. ''' search = self.tpb.search(keyword, category=category).multipage() good_torrents = [] for torrent in search: if (torrent.seeders < min_seeders): break if all([filter_function(torrent) for filter_function in filters]): good_torrents.append(torrent) return good_torrents
class TorrentSearcher(object): def __init__(self): self._pirategateway = TPB('https://thepiratebay.org') def search_for_serie(self, name, season): chapters = {} for page in range(0, 10): torrents = self._pirategateway.search(name).order(ORDERS.SEEDERS.DES).page(page) for torrent in torrents: try: file = str(torrent).lower() seas = re.sub(r".*s([0-9]*)e[0-9]*.*", r"\1", file) chapter = re.sub(r".*e([0-9][0-9]).*", r"\1", file) if chapter == file or seas == file: continue if chapter != "" and seas != "" and int(seas) == season: if not int(chapter) in chapters.keys(): chapters[int(chapter)] = torrent except: continue return chapters
class TorrentSearcher(object): def __init__(self): self._pirategateway = TPB('https://thepiratebay.org') def search_for_serie(self, name, season): chapters = {} for page in range(0, 10): torrents = self._pirategateway.search(name).order( ORDERS.SEEDERS.DES).page(page) for torrent in torrents: try: file = str(torrent).lower() seas = re.sub(r".*s([0-9]*)e[0-9]*.*", r"\1", file) chapter = re.sub(r".*e([0-9][0-9]).*", r"\1", file) if chapter == file or seas == file: continue if chapter != "" and seas != "" and int(seas) == season: if not int(chapter) in chapters.keys(): chapters[int(chapter)] = torrent except: continue return chapters
import sys import re from tpb import TPB from tpb import CATEGORIES, ORDERS seeking = sys.argv[1] minSize = sys.argv[2] scale = sys.argv[3] if scale == 'G': scale = "GiB" elif scale == 'M': scale = "MiB" else: exit(1) t = TPB('https://thepiratebay.org') result = t.search(seeking).order(ORDERS.SEEDERS.DES).page(1) files = [] for torrent in result: match = re.match(r'.*Size ([\d\.]*?)\s(\w\w\w).*', torrent.description.text) if match: files.append({'size': match.group(1), 'scale': match.group(2), 'url':torrent.magnet_link, 'title':torrent.title}) files = filter(lambda e: e['scale'] == scale and e['size'] >= minSize, files) for file in files: print(file['title'], file['size']+file['scale'], file['url']) print("")
# <headingcell level=1> # The Pirate Bay # <codecell> from tpb import TPB from tpb import CATEGORIES, ORDERS # <codecell> t = TPB('https://thepriatebay.sx') # <codecell> search = t.search('homeland', category=CATEGORIES.VIDEO.MOVIES) # <codecell> pagSea = search.page(0).multipage() for pag in pagSea: print pag # <codecell> t.top().category(CATEGORIES.VIDEO.MOVIES) # <codecell> t.search('24').order(ORDERS.SEEDERS.ASC).page(3)
from tpb import TPB from tpb import CATEGORIES, ORDERS t = TPB('https://thepiratebay.org') # create a TPB object with default domain # search for 'public domain' in 'movies' category search = t.search('public domain', category=CATEGORIES.VIDEO.MOVIES) # return listings from page 2 of this search search.page(2) # sort this search by count of seeders, and return a multipage result search.order(ORDERS.SEEDERS.ASC).multipage() # search, order by seeders and return page 3 results t.search('python').order(ORDERS.SEEDERS.ASC).page(3) # multipage beginning on page 4 t.search('recipe book').page(4).multipage() # search, in a category and return multipage results t.search('something').category(CATEGORIES.OTHER.OTHER).multipage() # get page 3 of recent torrents t.recent().page(3) # get top torrents in Movies category t.top().category(CATEGORIES.VIDEO.MOVIES) # print all torrent descriptions for torrent in t.search('public domain'):
t = TPB('https://thepiratebay.se') print("----- MENU -----") print("1: Search for Album") print("2. Import CSV list") menu = input('? ') if menu == '1': searching = 1 magnets = [] while searching == 1 : search = input('Search for? ') s = t.search(search) sr = [] #Rip torrent data for i in s: if i.category == "Audio": sr.append([i.title,float(numbers.findall(i.size)[0]),i.seeders,i.leechers,i.magnet_link,i.torrent_link]) ct = 1 sr.sort(key=lambda sr: sr[2]) sr.reverse() if sr != []: print(CSI,"----------------------------------------------------------------",RES) for i in sr:
class PirateBay(object): def __init__(self): self.t = TPB('https://thepiratebay.org') # This is the generic "Name S00E00" format seen on TPB def gen_query_generic(self, ep): return '%s S%02dE%02d' % (ep.show.name, ep.seasonid, ep.episodeid) # This format should help with episodes that don't really fall under S00E00 def gen_query_simple(self, ep): return '%s %s' % (ep.show.name, ep.name) def find_episode(self, episode): item = None for gen in [self.gen_query_generic, self.gen_query_simple]: item = self.search(gen(episode), best_exts=config['torrents']['best_formats'], best_users=config['torrents']['best_users'], min_seeders=config['torrents']['min_seeders'], max_seeders=config['torrents']['max_seeders']) if item: return item return None def search(self, query, min_seeders=35, max_seeders=10000, best_users=[], best_exts=["mkv"]): """ A pirate bay search function that takes a query, and trys to find an optimal torrent based on a few options. It implements a basic ranking algorithim to help decided which torrents are the bets, an allows format preference, seeder amount preference, and a list of preferred users. """ log.info("Searching for %s" % query) s = self.t.search(query, category=CATEGORIES.VIDEO.TV_SHOWS) s.order(ORDERS.SEEDERS.DES) results = {} for item in s.page(1): log.debug("Valuating result %s" % item) rank = 0 if item.seeders <= 0: continue if item.user.lower() in best_users: log.debug("\tIs ranked user!") rank += 1 if min_seeders <= item.seeders <= max_seeders: log.debug("\tHas good amount of seeders") rank += 1 for term in config['torrents']['terms']: if term in item.title: log.debug("\tHas search term `%s`" % term) rank += 1 files = getValidFiles([k for k in item.files.keys()]) if len(files) != 1: continue for f in files: if os.path.splitext(f)[-1][1:] in best_exts: log.debug("\tFile has preferred format") rank += 1 results[item] = rank best = sorted(results.iteritems(), key=operator.itemgetter(1)) if len(best): return best[-1][0] return None
#notes :I love Hyena...beautiful creature. from tpb import TPB #t = TPB() # when using a proxy site t = TPB('https://thepiratebay.org') print '*' * 50 print '1) Voir les torrents récents' print '2) Faire une recherche de torrent' print '*' * 50 question_1 = raw_input('Taper le chiffre qui correspond (1 ou 2) : ') print '*' * 50 if question_1 == '1': for tr in t.recent(): print '*' * 50 tr.print_torrent() print '\n' else: recherche = raw_input('Que voulez vous rechercher ? :') results = t.search(recherche, category=0) for r in results: print '*' * 50 r.print_torrent() print '\n'
import transmissionrpc # Post data form = cgi.FieldStorage() # Transmission tc = transmissionrpc.Client(address="localhost", port=9091, user="******", password="******") # Get search text searchText = "" torrents = 0 totalTorrents = 0 if "searchText" in form: searchText = form["searchText"].value t = TPB('https://thepiratebay.se') # create a TPB object with default domain torrents = list(iter(t.search(searchText).category(CATEGORIES.AUDIO.MUSIC).order(ORDERS.SEEDERS.DES).items())) totalTorrents = len(torrents) # Add torrent torrentAdded = 0 torrentTitle = "" if "download" and "magnetLink" in form: torrentAdded = 1 torrentTitle = form["torrentTitle"].value tc.add_torrent(form["magnetLink"].value) # Header headerTemplate = Template(open("html/header.html", "r").read()) renderedHeader = headerTemplate.render().encode("utf-8").strip() # Placeholder
class Search(object): def __init__(self, domain): if domain != None: self.domain = domain else: self.domain = "https://thepiratebay.se" self.tpb = TPB(self.domain) def list_categories(self): print """List of category codes: ALL - 0 AUDIO: All - 100 Music - 101 Audio books - 102 Sound clips - 103 Flac - 104 Other - 199 VIDEO: All - 200 Movies - 201 Movies DVDR - 202 Music videos - 203 Movie clips - 204 TV shows - 205 Handheld - 206 HD movies - 207 HD TV shows - 208 3D - 209 Other - 299 APPLICATIONS: All - 300 Windows - 301 Mac - 302 Unix - 303 Handheld - 304 iOS - 305 Android - 306 Other - 399 GAMES: All - 400 PC - 401 Mac - 402 PSX - 403 Xbox 360 - 404 Wii - 405 Handheld - 406 iOS - 407 Android - 408 Other - 499 P**N: All - 500 Movies - 501 Movies DVDR - 502 Pictures - 503 Games - 504 HD Movies - 505 Movie clips - 506 Other - 599 OTHER: E-books - 601 Comics - 602 Pictures - 603 Covers - 604 Physibles - 605 Other - 699 """ sys.exit(0) def list_orders(self): print """List of sorting codes: NAME: Descending = 1 Ascending = 2 UPLOADED: Descending = 3 Ascending = 4 SIZE: Descending = 5 Ascending = 6 SEEDERS: Descending = 7 Ascending = 8 LEECHERS: Descending = 9 Ascending = 10 UPLOADER: Descending = 11 Ascending = 12 TYPE: Descending = 13 Ascending = 14 """ sys.exit(0) def search(self, category_number=0, query='', order_number=1, limit=0): self.query = query self.limit = limit self.categories = { 0 : CATEGORIES.ALL, 100 : CATEGORIES.AUDIO.ALL, 101 : CATEGORIES.AUDIO.MUSIC, 102 : CATEGORIES.AUDIO.AUDIO_BOOKS, 103 : CATEGORIES.AUDIO.SOUND_CLIPS, 104 : CATEGORIES.AUDIO.FLAC, 199 : CATEGORIES.AUDIO.OTHER, 200 : CATEGORIES.VIDEO.ALL, 201 : CATEGORIES.VIDEO.MOVIES, 202 : CATEGORIES.VIDEO.MOVIES_DVDR, 203 : CATEGORIES.VIDEO.MUSIC_VIDEOS, 204 : CATEGORIES.VIDEO.MOVIE_CLIPS, 205 : CATEGORIES.VIDEO.TV_SHOWS, 206 : CATEGORIES.VIDEO.HANDHELD, 207 : CATEGORIES.VIDEO.HD_MOVIES, 208 : CATEGORIES.VIDEO.HD_TV_SHOWS, 209 : CATEGORIES.VIDEO.THREE_DIMENSIONS, 299 : CATEGORIES.VIDEO.OTHER, 300 : CATEGORIES.APPLICATIONS.ALL, 301 : CATEGORIES.APPLICATIONS.WINDOWS, 302 : CATEGORIES.APPLICATIONS.MAC, 303 : CATEGORIES.APPLICATIONS.UNIX, 304 : CATEGORIES.APPLICATIONS.HANDHELD, 305 : CATEGORIES.APPLICATIONS.IOS, 306 : CATEGORIES.APPLICATIONS.ANDROID, 399 : CATEGORIES.APPLICATIONS.OTHER, 400 : CATEGORIES.GAMES.ALL, 401 : CATEGORIES.GAMES.PC, 402 : CATEGORIES.GAMES.MAC, 403 : CATEGORIES.GAMES.PSX, 404 : CATEGORIES.GAMES.XBOX360, 405 : CATEGORIES.GAMES.WII, 406 : CATEGORIES.GAMES.HANDHELD, 407 : CATEGORIES.GAMES.IOS, 408 : CATEGORIES.GAMES.ANDROID, 499 : CATEGORIES.GAMES.OTHER, #FIXME: Getting bug when trying to include these entries #FIX: pip install --upgrade git+https://github.com/karan/TPB.git 500 : CATEGORIES.P**N.ALL, 501 : CATEGORIES.P**N.MOVIES, 502 : CATEGORIES.P**N.MOVIES_DVDR, 503 : CATEGORIES.P**N.PICTURES, 504 : CATEGORIES.P**N.GAMES, 505 : CATEGORIES.P**N.HD_MOVIES, 506 : CATEGORIES.P**N.MOVIE_CLIPS, 599 : CATEGORIES.P**N.OTHER, 601 : CATEGORIES.OTHER.EBOOKS, 602 : CATEGORIES.OTHER.COMICS, 603 : CATEGORIES.OTHER.PICTURES, 604 : CATEGORIES.OTHER.COVERS, 605 : CATEGORIES.OTHER.PHYSIBLES, 699 : CATEGORIES.OTHER.OTHER } self.orders = { 1 : ORDERS.NAME.DES, 2 : ORDERS.NAME.ASC, 3 : ORDERS.UPLOADED.DES, 4 : ORDERS.UPLOADED.ASC, 5 : ORDERS.SIZE.DES, 6 : ORDERS.SIZE.ASC, 7 : ORDERS.SEEDERS.DES, 8 : ORDERS.SEEDERS.ASC, 9 : ORDERS.LEECHERS.DES, 10 : ORDERS.LEECHERS.ASC, 11 : ORDERS.UPLOADER.DES, 12 : ORDERS.UPLOADER.ASC, 13 : ORDERS.TYPE.DES, 15 : ORDERS.TYPE.ASC } try: self.category = self.categories[category_number] except KeyError: print "Provide correct category code." sys.exit(2) try: self.order = self.orders[order_number] except KeyError: print "Provide correct sorting code." sys.exit(3) if self.limit == 0: for torrent in self.tpb.search(self.query, category=self.category).order(self.order): print torrent.title, " - ", torrent.user print "Seeders: ", torrent.seeders print "Leechers: ", torrent.leechers print torrent.magnet_link, "\n" sys.exit(0)
# Torrent result defaults torrents = 0 totalTorrents = 0 # Get search text and perform search searchText = "*" if "searchText" in form: searchText = form["searchText"].value category = CATEGORIES.VIDEO.HD_MOVIES if quality == 'sd': category = CATEGORIES.VIDEO.MOVIES t = TPB('https://thepiratebay.se') # create a TPB object with default domain torrents = list(iter(t.search(searchText).category(category).order(ORDERS.SEEDERS.DES).items())) totalTorrents = len(torrents) # Add torrent torrentAdded = 0 torrentTitle = "" if "download" and "magnetLink" in form: # Clear form searchText = "" quality = "hd" # Add torrent torrentAdded = 1 torrentTitle = form["torrentTitle"].value tc.add_torrent(form["magnetLink"].value) # Header
album = item.find('h2').text yield artist, album i += 1 if __name__ == '__main__': arguments = docopt(doc) if arguments['-a']: num_torrents = int(arguments['<num_torrents>']) bnm = islice(get_bnm(), num_torrents) else: bnm = get_bnm() for artist, album in bnm: print artist + ' - ' + album decision = raw_input('(y/n)? ') while decision not in ['y', 'n']: decision = raw_input('(y/n)? ') if decision == 'n': continue else: torrents = t.search(artist + ' ' + album).category(CATEGORIES.AUDIO.MUSIC).order(ORDERS.SEEDERS.DES) link = first(torrents).magnet_link webbrowser.open(link)
from tpb import TPB from tpb import CATEGORIES, ORDERS t = TPB('https://thepiratebay.org') # create a TPB object with default domain search = t.search('public domain', category=CATEGORIES.VIDEO.MOVIES)
def download(self,jsonep): t = TPB('https://thepiratebay.org') #search = t.search('Game Of Thrones s04e01', category=CATEGORIES.VIDEO) no_of_season=self.ses.get() if(int(no_of_season)<10): no_of_season='0'+no_of_season epno=self.ep.get() if(int(epno)<10): epno='0'+epno searchquery=self.title+' s'+no_of_season+'e'+epno print searchquery i=0 try: for torrent in t.search(searchquery,category=CATEGORIES.VIDEO.TV_SHOWS): nameoftorr=torrent.title nameoftorr=nameoftorr.lower() size=torrent.size i=i+1 if(nameoftorr.find(searchquery.lower())): link=torrent.magnet_link; webbrowser.open_new_tab(link) try: shortdescp=jsonep['episodes'][int(self.ep.get())-1]['overview'] #print jsonep['episodes'][int(self.ep.get())]['overview'] sdesc=StringVar() sdesc.set('Short Description :') label = Label( top, textvariable=sdesc,fg='#0e385f',bg='#D3D8E8') label.place(x=50,y=375,width=300,height=30) lengthofshort=len(shortdescp) no=lengthofshort/75 temp2=0 temp3=0 for j in range(0,no+1) : shortdesc=StringVar() temp=shortdescp.find(' ',(75*j)+75,(75*j)+90) temp2=temp temp=temp%75 stri=shortdescp[(75*j)+temp3:(75*j)+75+temp] temp3=temp2%75 shortdesc.set(stri) label = Label( top, textvariable=shortdesc,fg='#0e385f',bg='#D3D8E8') if j!=no: label.place(x=50,y=(400+(30*j)),width=600,height=30) else: t=j%8 label.place(x=50,y=(400+(30*j)),width=600,height=30) label = Label( top, text='',fg='#0e385f',bg='#D3D8E8') label.place(x=50,y=(400+(30*(j+1))),width=600,height=30*t) except(Exception): print "Error"; break; if(i>10): tkMessageBox.showerror(title='Not Available',message='Torrent File not available on PirateBay') break; if(i==0): tkMessageBox.showerror(title='Not Available',message='Torrent File not available on PirateBay') except Exception: print "Net connection not established or Pirate Bay Blocked"
startlink = raw_input("what is start of the link ?\n") endlink = raw_input("\nwhat is the end of the link ?\n") # startlink = 'Scorpion.S02E' # endlink = '.HDTV.x264-LOL[ettv]' print("\nprocessing...") magnetList = [] for x in range(1, 20): t = TPB( 'https://thepiratebay.se') # create a TPB object with default domain s = startlink if (x < 10): s += "0" s += str(x) + endlink search = t.search(s) if (search.items() > 0): for t in search: print(t.title) magnetList.append(t.magnet_link) print("done looping") wannaDoThis = raw_input("Do you wish to download all of those ?") if ('y' in wannaDoThis): for y in range(0, len(magnetList)): os.startfile(magnetList[y])
# search = t.search('public domain', category=CATEGORIES.VIDEO.MOVIES) # # return listings from page 2 of this search # search.page(2) # # sort this search by count of seeders, and return a multipage result # search.order(ORDERS.SEEDERS.ASC).multipage() # # search, order by seeders and return page 3 results # t.search('python').order(ORDERS.SEEDERS.ASC).page(3) # # multipage beginning on page 4 # t.search('recipe book').page(4).multipage() # # search, in a category and return multipage results # t.search('something').category(CATEGORIES.OTHER.OTHER).multipage() # # get page 3 of recent torrents # t.recent().page(3) # get top torrents in Movies category t.top().category(CATEGORIES.VIDEO.HD_MOVIES) # print all torrent descriptions for torrent in t.search('public domain'): print(torrent.info) # print all torrent files and their sizes for torrent in t.search('public domain'): print(torrent.files)