Skip to content

Instantly share code, notes, and snippets.

@bolshoytoster
Last active December 23, 2025 19:16
Show Gist options
  • Select an option

  • Save bolshoytoster/4562ef33104b2e4d54ad62ff0d9f13aa to your computer and use it in GitHub Desktop.

Select an option

Save bolshoytoster/4562ef33104b2e4d54ad62ff0d9f13aa to your computer and use it in GitHub Desktop.
# VERSION: 1.0
# AUTHORS: bolshoytoster (https://github.com/bolshoytoster)
import json
from datetime import datetime
from urllib.parse import unquote
from helpers import retrieve_url
class knaben(object):
url = 'https://knaben.org'
name = 'Knaben'
supported_categories = {
'all': '',
'anime': ',"categories":[6000000]',
'books': ',"categories":[9000000]',
# PC>Games, Console
# Doesn't include mobile games
'games': ',"categories":[4001000,7000000]',
'movies': ',"categories":[3000000]',
'music': ',"categories":[1001000,1002000]',
# Again, doesn't include mobile software
'software': ',"categories":[4002000,4003000,4004000]',
'tv': ',"categories":[2000000]'
}
def search(self, what: str, cat: str) -> None:
what = unquote(what).replace("\"", "\\\"")
cat = self.supported_categories[cat]
for hit in json.loads(
retrieve_url(
'https://api.knaben.org/v1',
{'content-type': '!/json'},
f'{{"order_by":"seeders","query":"{what}"{cat}}}'.encode('utf-8')
)
)['hits']:
print(
'|'.join([
hit['magnetUrl'] or hit['link'],
hit['title'].replace('|', ' '),
str(hit['bytes']),
str(hit['seeders']),
str(hit['peers']),
'https://knaben.org',
hit['details'],
str(int(datetime.fromisoformat(hit['date']).timestamp()))
])
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment