Exemplo n.º 1
0
def scrape():

    content = request.get_json()

    if content != {}:
        res = {}

        keywords = get_keywords(content['page_url'])
        unique_kws = create_unique_combinations(keywords)

        tpb, torrents = TPB('https://thepiratebay.org'), []

        for kw in unique_kws:
            existing_magnets = [t['magnet'] for t in torrents]
            new_torrents = find_torrents('{} {}'.format(kw[0], kw[1]), tpb)

            for t in new_torrents:
                if t['magnet'] not in existing_magnets:
                    torrents.append(t)

        torrents = sorted(torrents, key=lambda torrent:
                          (torrent['seeders']))[-3:]

        return jsonify(torrents)

    return jsonify('Provide valid URL')
Exemplo n.º 2
0
    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
            })
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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
import curses
import subprocess, os
from tpb import TPB
from tpb import CATEGORIES, ORDERS
import simplefm

t = TPB('https://thepiratebay.org')


def searchTor(keyword):
    lista = []
    for i, tor in enumerate(t.search(keyword)):
        lista.append({'selected': True if i == 0 else False, 'torrent': tor})
    return lista


def print_list(stdscr, lista):
    for i, v in enumerate(lista):
        stdscr.addstr(
            i + 1, 0,
            ('*' if v['selected'] else 'o') + ' -- ' + v['torrent'].title,
            curses.color_pair(1) if v['selected'] else curses.color_pair(0))


def print_search(win, keyword, mode):
    height, width = win.getmaxyx()

    if mode == 0:
        win.attron(curses.color_pair(2))
        win.addstr(0, len(keyword), " " * (width - len(keyword)))
Exemplo n.º 7
0
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'):
Exemplo n.º 8
0
    def __init__(self):

        self.iAPI = ImageAPI()
        self.website = TPB(
            "https://thepiratebay.org/")  #Base URL for ThePirateBay
Exemplo n.º 9
0
# Very simple RESTful interface to TPB
# Uses:
#   * https://github.com/karan/TPB
#   * http://flask-restful.readthedocs.org/en/latest

from flask import Flask
from flask.ext.restful import abort, Api, Resource
from tpb import TPB
from tpb import CATEGORIES, ORDERS

tpburl = 'https://thepiratebay.se'

app = Flask(__name__)
api = Api(app)

t = TPB(tpburl)

# main subject and default value
constants = {
    'cat': [CATEGORIES, CATEGORIES.ALL],
    'order': [ORDERS, ORDERS.SEEDERS.DES]
}


def abort_on_mistake(var, filtr):
    try:
        if not ':' in filtr:
            # return default value
            return constants[var][1]
        k, v = filtr.split(':')
        return getattr(getattr(constants[var][0], k.upper()), v.upper())
Exemplo n.º 10
0
    def __init__(self):

        self.iAPI = ImageAPI()
        self.config = ConfigManager()
        self.website = TPB(
            "https://thepiratebay.monster/")  #Base URL for ThePirateBay
Exemplo n.º 11
0
#!/usr/bin/env python

from tpb import TPB

t = TPB()

# when using a proxy site
# t = TPB(domain='http://uberproxy.net/thepiratebay.sx')

for to in t.get_recent_torrents():
    print '*' * 50
    to.print_torrent()
    print '\n'
"""
# search for programming ebooks
results = t.search('hello world', category=601)

for r in results:
    print '*' * 50
    r.print_torrent()
    print '\n'
"""
Exemplo n.º 12
0
 def __init__(self):
     self.tpb = TPB(THEPIRATEBAY)
Exemplo n.º 13
0
 def __init__(self):
     self._pirategateway = TPB('https://thepiratebay.org')
Exemplo n.º 14
0
    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"	
Exemplo n.º 15
0
    airedEpisodes = getAiredEpisodesTMDB(show)
    print "Getting diff episodes for show: {}".format(show.title)
    diffEpi = diffEpisodes(show, airedEpisodes, watchedEpisodes)

    if bool(diffEpi):
        # if there is diff - scan all present downloaded files (prevent duplicates)
        presentEpisodes = scanPresentFiles(BASE_URL, ttv.slugify(show.title))
        # get new diff of old_diff and that present files that on your computer
        diffPresent = diffEpisodes(show, diffEpi, presentEpisodes)
        if bool(diffPresent):
            # if there are files to download that you havn't already downloaded - add to download dict
            print "\t\tAdding show {} to dict".format(show.title)
            EpisodesToDownload[show.title] = diffPresent

# Start of TBP API
t = TPB("http://thepiratebay.org")

# list of valid publishers - don't want any torrent from anyone..
validPublishers = [
    'ettv', 'LOL', 'FUM', 'DIMENSION', 'KILLERS', 'FLEET', 'AFG'
]

print
print "I'm going to download the following shows and episodes:"

# go over all the "to download" shows
for _show, season in EpisodesToDownload.items():
    print _show,
    for entry in season.values():
        s = "0" + str(entry.season) if len(str(entry.season)) == 1 else str(
            entry.season)