Created
April 25, 2014 09:04
-
-
Save 0xPr0xy/11282906 to your computer and use it in GitHub Desktop.
torrent cli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from BeautifulSoup import BeautifulSoup | |
| import click | |
| import requests | |
| @click.group() | |
| def cli(): | |
| pass | |
| @click.command() | |
| @click.option('--sort', default='P', help='the sorting, can be P(eers) or S(eeds)') | |
| @click.option('--media', default='tv', help='the media to search for, can be tv or movies') | |
| def list(sort,media): | |
| r = requests.get('http://torrentz.eu/verified'+sort+'?f='+media) | |
| soup = BeautifulSoup(r.text) | |
| dt = soup.findAll('a', attrs={'title':None, 'rel':None}) | |
| for x in dt: | |
| if len(x['href']) > 40: print 'http://torrentz.eu' + x['href'] + ' - ' + x.text | |
| @click.command() | |
| @click.option('--hash', required=True, help='the hash of the torrent') | |
| def download(hash): | |
| r = requests.get('http://torrentz.eu/'+hash) | |
| soup = BeautifulSoup(r.text) | |
| dt = soup.findAll('a', attrs={'rel':'e'}) | |
| for x in dt: | |
| print x['href'] | |
| cli.add_command(list) | |
| cli.add_command(download) | |
| if __name__ == '__main__': | |
| cli() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment