1
0
mirror of https://github.com/vikstrous/pirate-get synced 2025-01-10 10:04:21 +01:00
This commit is contained in:
rnhmjoj 2015-08-30 02:00:42 +00:00
parent ee8abc5d37
commit 9e227aecfa
4 changed files with 20 additions and 20 deletions

View File

@ -1,7 +1,7 @@
import urllib.parse as parse import urllib.parse as parse
import html.parser as parser import html.parser as parser
# create a subclass and override the handler methods
class BayParser(parser.HTMLParser): class BayParser(parser.HTMLParser):
title = '' title = ''
q = '' q = ''

View File

@ -58,8 +58,8 @@ def parse_cmd(cmd, url):
ret = [i[0].strip().replace('%s', url) for i in ret] ret = [i[0].strip().replace('%s', url) for i in ret]
ret_no_quotes = [] ret_no_quotes = []
for item in ret: for item in ret:
if ((item[0] == "'" and item[-1] == "'") or ( if ((item[0] == "'" and item[-1] == "'") or
item[0] == '"' and item[-1] == '"')): (item[0] == '"' and item[-1] == '"')):
ret_no_quotes.append(item[1:-1]) ret_no_quotes.append(item[1:-1])
else: else:
ret_no_quotes.append(item) ret_no_quotes.append(item)
@ -70,7 +70,7 @@ def main():
config = load_config() config = load_config()
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='finds and downloads torrents from the Pirate Bay') description='finds and downloads torrents from the Pirate Bay')
parser.add_argument('-b', dest='browse', parser.add_argument('-b', dest='browse',
action='store_true', action='store_true',
help='display in Browse mode') help='display in Browse mode')
@ -82,7 +82,7 @@ def main():
help='specify a sort option', default='SeedersDsc') help='specify a sort option', default='SeedersDsc')
parser.add_argument('-R', dest='recent', action='store_true', parser.add_argument('-R', dest='recent', action='store_true',
help='torrents uploaded in the last 48hours.' help='torrents uploaded in the last 48hours.'
'*ignored in searches*') '*ignored in searches*')
parser.add_argument('-l', dest='list_categories', parser.add_argument('-l', dest='list_categories',
action='store_true', action='store_true',
help='list categories') help='list categories')
@ -124,8 +124,7 @@ def main():
args = parser.parse_args() args = parser.parse_args()
if (config.getboolean('Misc', 'colors') and not args.color if (config.getboolean('Misc', 'colors') and not args.color
or not config.getboolean('Misc', 'colors')): or not config.getboolean('Misc', 'colors')):
#global colored_output
pirate.data.colored_output = False pirate.data.colored_output = False
if args.save_directory: if args.save_directory:
@ -182,17 +181,18 @@ def main():
for mirror in mirrors: for mirror in mirrors:
try: try:
print('Trying', mirror, end='... ') print('Trying', mirror, end='... ')
mags, sizes, uploaded, ids = pirate.torrent.remote(args, mirror) mags, sizes, uploaded, ids = pirate.torrent.remote(args,
mirror)
except (urllib.error.URLError, socket.timeout, except (urllib.error.URLError, socket.timeout,
IOError, ValueError): IOError, ValueError):
print('Failed', color='WARN') print('Failed', color='WARN')
else: else:
site = mirror site = mirror
print('Ok', color='alt') print('Ok', color='alt')
break break
else: else:
print('No available mirrors :(', color='WARN') print('No available mirrors :(', color='WARN')
return return
if not mags: if not mags:
print('No results') print('No results')
@ -212,8 +212,8 @@ def main():
print("\nSelect links (Type 'h' for more options" print("\nSelect links (Type 'h' for more options"
", 'q' to quit)", end='\b', color='alt') ", 'q' to quit)", end='\b', color='alt')
try: try:
l=input(': ') l = input(': ')
except KeyboardInterrupt : except KeyboardInterrupt:
print('\nCancelled.') print('\nCancelled.')
return return

View File

@ -58,7 +58,7 @@ def search_results(mags, sizes, uploaded, local):
else: else:
no_seeders, no_leechers = map(int, magnet[1:]) no_seeders, no_leechers = map(int, magnet[1:])
size, unit = (float(sizes[m][0]), size, unit = (float(sizes[m][0]),
sizes[m][1]) if sizes else (0, '???') sizes[m][1]) if sizes else (0, '???')
date = uploaded[m] date = uploaded[m]
# compute the S/L ratio (Higher is better) # compute the S/L ratio (Higher is better)
@ -68,7 +68,7 @@ def search_results(mags, sizes, uploaded, local):
ratio = float('inf') ratio = float('inf')
line = ('{:4} {:5} {:5} {:5.1f} {:5.1f}' line = ('{:4} {:5} {:5} {:5.1f} {:5.1f}'
' {:3} {:<11} {:{length}}') ' {:3} {:<11} {:{length}}')
content = [m, no_seeders, no_leechers, ratio, content = [m, no_seeders, no_leechers, ratio,
size, unit, date, torrent_name[:columns - 52]] size, unit, date, torrent_name[:columns - 52]]