Code Monkey home page Code Monkey logo

tpb's Introduction

TPB

Unofficial Python API for ThePirateBay.

This project was forked from the original one as it was not maintained anymore.

Build Status Test Coverage Version Downloads (30 days)
Build Status Coverage Status Latest Version Downloads

Installation

$ pip install tpb

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

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'):
    print(torrent.info)

# print all torrent files and their sizes
for torrent in t.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 original author, please consider donating.

- BTC: 19dLDL4ax7xRmMiGDAbkizh6WA6Yei2zP5

- Gratipay: https://www.gratipay.com/karan/

- Flattr: https://flattr.com/profile/thekarangoel

Contribute

If you want to add any new features, or improve existing ones, feel free to send a pull request!

tpb's People

Contributors

amney avatar bitdeli-chef avatar cjil avatar easybe avatar granda avatar infothrill avatar isameer avatar jamesorlakin avatar jaormx avatar jsdt avatar miguelgazela avatar movermeyer avatar mwalercz avatar pawamoy avatar rom1504 avatar rubenroy avatar schnouki avatar sohailprasad avatar tejas-manohar avatar themylogin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

krisfris gabi200

tpb's Issues

ImportError: cannot import name 'TPB' from 'tpb'

This is my code:
from tpb import TPB
from tpb import CATEGORIES, ORDERS

t = TPB('https://boatairproxy.org/')
search = t.search('public domain', category=CATEGORIES.VIDEO.MOVIES)

I get the error in the title when i run..

No response for search

t = TPB('https://pirateproxy.tube/')

for torrent in t.search('interstellar'):
    print(torrent.info)

this is my code and the search object doesn't return anything i guess because it is not printing anything. am i going wrong somewhere or is the fault on your side?

piratebay is actually blocked in my country but the url above does work when i open it on my web browser.

Multiple print

Hello, I have a problem in my code

for torrent in torrents:
    torrent = torrents.getBestTorrent()
    print(torrent)
    print(torrent.magnetlink)

Output

The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80
The.Alpha.Test.2020.1080p.WEBRip.x264.AAC, S: 163, L: 30, 1.44 GiB
magnet:?xt=urn:btih:a31045dc1580a05b869459bb01f802e0da80d17b&dn=The.Alpha.Test.2020.1080p.WEBRip.x264.AAC&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80&tr=udp%3A%2F%2Ftracker.publicbt.com%3A80&tr=udp%3A%2F%2Ftracker.ccc.de%3A80

Why does it print the one torrent so many times? Can I print it only once?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.