Add issue templates and CI workflows; remove obsolete files

- Created bug report and feature request templates for better issue tracking.
- Added a build workflow for automated package management and release.
- Removed outdated CodeQL analysis and Python publish workflows.
- Updated project metadata in pyproject.toml and README.md.
- Refactored torrent handling and site interaction modules.
This commit is contained in:
2025-05-23 16:42:27 +02:00
parent 38df01c21f
commit 8ddea25e5b
18 changed files with 349 additions and 249 deletions

View File

@@ -0,0 +1,97 @@
import requests
from komsuite_nyaapy.modules import torrent
from komsuite_nyaapy.modules.parser import parse_nyaa, parse_single, parse_nyaa_rss
class AnimeTorrentSite:
SITE = torrent.TorrentSite.NYAASI
URL = SITE
@classmethod
def last_uploads(self, number_of_results: int):
r = requests.get(self.URL)
# If anything up with nyaa servers let the user know.
r.raise_for_status()
json_data = parse_nyaa(
request_text=r.text, limit=number_of_results, site=self.SITE
)
return torrent.json_to_class(json_data)
@classmethod
def search(
self,
keyword: str,
category: int = 0,
subcategory: int = 0,
filters: int = 0,
page: int = 0,
sorting: str = "id",
order: str = "desc",
**kwargs,
):
base_url = self.URL
user = kwargs.get("user", None)
user_uri = f"user/{user}" if user else ""
if page > 0:
search_uri = "{}/{}?f={}&c={}_{}&q={}&p={}&s={}&o={}".format(
base_url,
user_uri,
filters,
category,
subcategory,
keyword,
page,
sorting,
order,
)
else:
search_uri = "{}/{}?f={}&c={}_{}&q={}&s={}&o={}".format(
base_url,
user_uri,
filters,
category,
subcategory,
keyword,
sorting,
order,
)
if not user:
search_uri += "&page=rss"
http_response = requests.get(search_uri)
http_response.raise_for_status()
if user:
json_data = parse_nyaa(
request_text=http_response.content, limit=None, site=self.SITE
)
else:
json_data = parse_nyaa_rss(
request_text=http_response.content, limit=None, site=self.SITE
)
# Convert JSON data to a class object
return torrent.json_to_class(json_data)
@classmethod
def get(self, view_id: int):
r = requests.get(f"{self.URL}/view/{view_id}")
r.raise_for_status()
json_data = parse_single(request_text=r.content, site=self.SITE)
return torrent.json_to_class(json_data)
@classmethod
def get_from_user(self, username):
r = requests.get(f"{self.URL}/user/{username}")
r.raise_for_status()
json_data = parse_nyaa(request_text=r.content, limit=None, site=self.SITE)
return torrent.json_to_class(json_data)