mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-09 09:59:51 +01:00
implement browse mode
This commit is contained in:
parent
496b0f09b0
commit
9e7d00e0ce
@ -320,6 +320,13 @@ def search_mirrors(printer, args):
|
||||
def pirate_main(args):
|
||||
printer = Printer(args.color)
|
||||
|
||||
# browse mode needs a specific category
|
||||
if args.browse:
|
||||
if args.category == 'All' or args.category == 0:
|
||||
printer.print('You must select a specific category in browse mode.'
|
||||
' ("All" is not valid)', color='ERROR')
|
||||
sys.exit(1)
|
||||
|
||||
# print version
|
||||
if args.version:
|
||||
printer.print('pirate-get, version {}'.format(pirate.data.version))
|
||||
|
@ -102,7 +102,9 @@ def build_request_path(mode, category, terms):
|
||||
elif mode == 'recent':
|
||||
query = '/precompiled/data_top100_recent.json'
|
||||
elif mode == 'browse':
|
||||
raise NotImplementedError
|
||||
if category == 0:
|
||||
raise Exception('You must specify a category')
|
||||
query = '/q.php?q=category:{}'.format(category)
|
||||
else:
|
||||
raise Exception('Invalid mode', mode)
|
||||
|
||||
|
@ -77,11 +77,11 @@ class TestTorrent(unittest.TestCase):
|
||||
(('search', 100, ['abc']), '/q.php?q=abc&cat=100'),
|
||||
(('search', 100, ['abc', 'def']), '/q.php?q=abc%20def&cat=100'),
|
||||
(('search', 100, ['\u1234']), '/q.php?q=%E1%88%B4&cat=100'),
|
||||
(('browse', 100, []), '/q.php?q=category%3A100'),
|
||||
]
|
||||
fail = [
|
||||
(('browse', 100, []), NotImplementedError),
|
||||
(('browse', 0, []), NotImplementedError),
|
||||
(('asdf', 100, []), Exception),
|
||||
(('browse', 0, []), Exception),
|
||||
(('asdf', 100, []), Exception)
|
||||
]
|
||||
for inp, out in succeed:
|
||||
path = pirate.torrent.build_request_path(*inp)
|
||||
|
Loading…
Reference in New Issue
Block a user