mirror of
https://github.com/vikstrous/pirate-get
synced 2025-01-10 10:04:21 +01:00
fix bugs with categories and sorts
This commit is contained in:
parent
a430fab14c
commit
4eb034e925
@ -13,7 +13,11 @@ from io import BytesIO
|
|||||||
|
|
||||||
|
|
||||||
def parse_category(category):
|
def parse_category(category):
|
||||||
if str(category) in pirate.data.categories.values():
|
try:
|
||||||
|
category = int(category)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if category in pirate.data.categories.values():
|
||||||
return category
|
return category
|
||||||
elif category in pirate.data.categories.keys():
|
elif category in pirate.data.categories.keys():
|
||||||
return pirate.data.categories[category]
|
return pirate.data.categories[category]
|
||||||
@ -23,7 +27,11 @@ def parse_category(category):
|
|||||||
|
|
||||||
|
|
||||||
def parse_sort(sort):
|
def parse_sort(sort):
|
||||||
if str(sort) in pirate.data.sorts.values():
|
try:
|
||||||
|
sort = int(sort)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if sort in pirate.data.sorts.values():
|
||||||
return sort
|
return sort
|
||||||
elif sort in pirate.data.sorts.keys():
|
elif sort in pirate.data.sorts.keys():
|
||||||
return pirate.data.sorts[sort]
|
return pirate.data.sorts[sort]
|
||||||
@ -32,7 +40,11 @@ def parse_sort(sort):
|
|||||||
return '99'
|
return '99'
|
||||||
|
|
||||||
|
|
||||||
#todo: redo this with html parser instead of regex
|
#TODO: redo this with html parser instead of regex
|
||||||
|
#TODO: warn users when using a sort in a mode that doesn't accept sorts
|
||||||
|
#TODO: warn users when using search terms in a mode that doesn't accept search terms
|
||||||
|
#TODO: same with page parameter for top and top48h
|
||||||
|
#TODO: warn the user if trying to use a minor category with top48h
|
||||||
def remote(pages, category, sort, mode, terms, mirror):
|
def remote(pages, category, sort, mode, terms, mirror):
|
||||||
res_l = []
|
res_l = []
|
||||||
pages = int(pages)
|
pages = int(pages)
|
||||||
@ -54,6 +66,7 @@ def remote(pages, category, sort, mode, terms, mirror):
|
|||||||
elif mode == 'recent':
|
elif mode == 'recent':
|
||||||
# This is not a typo. There is no / between 48h and the category.
|
# This is not a typo. There is no / between 48h and the category.
|
||||||
path = '/top/48h'
|
path = '/top/48h'
|
||||||
|
# only major categories can be used with this mode
|
||||||
if(category == 0):
|
if(category == 0):
|
||||||
path += 'all'
|
path += 'all'
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user