mirror of
https://github.com/vikstrous/pirate-get
synced 2025-04-23 01:58:39 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
f0cf30bd48 | |||
edc547428b | |||
c0ca18f2da | |||
|
838a5973b9 | ||
|
3ad8620fbd | ||
1e9b3142a2 |
@ -43,6 +43,10 @@ enabled = false
|
||||
; path of the database
|
||||
path = ~/downloads/pirate-get/db
|
||||
|
||||
[Search]
|
||||
; maximum number of results to show
|
||||
total-results = 50
|
||||
|
||||
[Misc]
|
||||
; specify a custom command for opening the magnet
|
||||
; ex. myprogram --open %s
|
||||
|
@ -6,7 +6,7 @@ def get_resource(filename):
|
||||
return pkgutil.get_data(__package__, 'data/' + filename)
|
||||
|
||||
|
||||
version = '0.4.0'
|
||||
version = '0.4.2'
|
||||
|
||||
categories = json.loads(get_resource('categories.json').decode())
|
||||
sorts = json.loads(get_resource('sorts.json').decode())
|
||||
@ -16,4 +16,4 @@ default_headers = {'User-Agent': 'pirate get'}
|
||||
default_timeout = 10
|
||||
|
||||
default_mirror = 'https://apibay.org'
|
||||
mirror_list = 'https://proxybay.bz/list.txt'
|
||||
mirror_list = 'https://proxy-bay.app/list.txt'
|
||||
|
@ -32,6 +32,9 @@ def parse_config_file(text):
|
||||
config.set('LocalDB', 'enabled', 'false')
|
||||
config.set('LocalDB', 'path', expanduser('~/downloads/pirate-get/db'))
|
||||
|
||||
config.add_section('Search')
|
||||
config.set('Search', 'total-results', 50)
|
||||
|
||||
config.add_section('Misc')
|
||||
# TODO: try to use configparser.BasicInterpolation
|
||||
# for interpolating in the command
|
||||
@ -146,6 +149,9 @@ def parse_args(args_in):
|
||||
default=1, type=int,
|
||||
help='the number of pages to fetch. '
|
||||
'(only used with --recent)')
|
||||
parser.add_argument('-r', '--total-results',
|
||||
type=int,
|
||||
help='maximum number of results to show')
|
||||
parser.add_argument('-L', '--local', dest='database',
|
||||
help='a csv file containing the Pirate Bay database '
|
||||
'downloaded from '
|
||||
@ -234,6 +240,10 @@ def combine_configs(config, args):
|
||||
if not args.timeout:
|
||||
args.timeout = int(config.get('Misc', 'timeout'))
|
||||
|
||||
config_total_results = int(config.get('Search', 'total-results'))
|
||||
if not args.total_results and config_total_results:
|
||||
args.total_results = config_total_results
|
||||
|
||||
args.transmission_command = ['transmission-remote']
|
||||
if args.endpoint:
|
||||
args.transmission_command.append(args.endpoint)
|
||||
@ -389,6 +399,9 @@ def pirate_main(args):
|
||||
print(json.dumps(results))
|
||||
return
|
||||
else:
|
||||
# Results are sorted on the request, so it's safe to remove results here.
|
||||
if args.total_results:
|
||||
results = results[0:args.total_results]
|
||||
printer.search_results(results, local=args.source == 'local_tpb')
|
||||
|
||||
# number of results to pick
|
||||
|
@ -146,7 +146,7 @@ def find_api(mirror, timeout):
|
||||
f = request.urlopen(req, timeout=timeout)
|
||||
if f.info().get_content_type() == 'application/json':
|
||||
return mirror + path
|
||||
except urllib.error.URLError as e:
|
||||
except urllib.error.HTTPError as e:
|
||||
res = e.fp.read().decode()
|
||||
if e.code == 503 and 'cf-browser-verification' in res:
|
||||
raise IOError('Cloudflare protected')
|
||||
|
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ if __name__ == '__main__':
|
||||
author_email='me@viktorstanchev.com',
|
||||
license='AGPL',
|
||||
packages=find_packages(),
|
||||
package_data={'': ["data/*.json", "tests/data/*"]},
|
||||
package_data={'': ["data/*", "tests/data/*"]},
|
||||
entry_points={
|
||||
'console_scripts': ['pirate-get = pirate.pirate:main']
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user