You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that ThePirateBay depends on lxml. If you run into problems in the compilation of lxml through pip, install the libxml2-dev and libxslt-dev packages on your system.
Usage
fromtpbimportTPBfromtpbimportCATEGORIES, ORDERSt=TPB('https://thepiratebay.org') # create a TPB object with default domain# search for 'public domain' in 'movies' categorysearch=t.search('public domain', category=CATEGORIES.VIDEO.MOVIES)
# return listings from page 2 of this searchsearch.page(2)
# sort this search by count of seeders, and return a multipage resultsearch.order(ORDERS.SEEDERS.ASC).multipage()
# search, order by seeders and return page 3 resultst.search('python').order(ORDERS.SEEDERS.ASC).page(3)
# multipage beginning on page 4t.search('recipe book').page(4).multipage()
# search, in a category and return multipage resultst.search('something').category(CATEGORIES.OTHER.OTHER).multipage()
# get page 3 of recent torrentst.recent().page(3)
# get top torrents in Movies categoryt.top().category(CATEGORIES.VIDEO.MOVIES)
# print all torrent descriptionsfortorrentint.search('public domain'):
print(torrent.info)
# print all torrent files and their sizesfortorrentint.search('public domain'):
print(torrent.files)
Torrent details available
Attributes
title # the title of the torrent
url # TPB url for the torrent
category # the main category
sub_category # the sub category
magnet_link # magnet download link
torrent_link # .torrent download link
created # uploaded date time
size # size of torrent
user # username of uploader
seeders # number of seeders
leechers # number of leechers
Properties
created # creation date -- parsed when accessed
info # detailed torrent description -- needs separate request
files # dictionary of files and their size -- needs separate request
Tests
Tests can be ran using tox.
$ pip install tox
$ tox
Alternatively, you will need to install dependencies manually:
$ pip install -r tests/requirements.txt
Then, to execute the tests simply run:
$ python -m unittest discover
By default the tests are ran on a local test server with predownloaded original
responses. You can activate the remote running option by:
$ REMOTE=true python -m unittest discover
Donations
If TPB has helped you in any way, and you'd like to help the developer, please consider donating.