mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-05-11 18:45:58 +08:00
feat: add support for dmhy and nyaa.
This commit is contained in:
@@ -79,5 +79,9 @@ class Settings(Config):
|
||||
else:
|
||||
return os.environ[env]
|
||||
|
||||
@property
|
||||
def group_rules(self):
|
||||
return self.__dict__["group_rules"]
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
from .mikan import mikan_url
|
||||
from .nyaa import nyaa_url
|
||||
from .dmhy import dmhy_url
|
||||
|
||||
|
||||
def search_url(site: str, keywords: list[str]):
|
||||
if site == "mikan":
|
||||
return mikan_url(keywords)
|
||||
elif site == "nyaa":
|
||||
return nyaa_url(keywords)
|
||||
elif site == "dmhy":
|
||||
return dmhy_url(keywords)
|
||||
else:
|
||||
raise NotImplementedError(f"site {site} is not supported")
|
||||
|
||||
8
backend/src/module/searcher/plugin/dmhy.py
Normal file
8
backend/src/module/searcher/plugin/dmhy.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import re
|
||||
|
||||
|
||||
def dmhy_url(keywords: list[str]):
|
||||
keyword = "+".join(keywords)
|
||||
search_str = re.sub(r"[\W_ ]", "+", keyword)
|
||||
url = f"http://dmhy.org/topics/rss/rss.xml?keyword={search_str}"
|
||||
return url
|
||||
@@ -1,12 +1,8 @@
|
||||
import re
|
||||
|
||||
from module.conf import settings
|
||||
|
||||
|
||||
def mikan_url(keywords: list[str]):
|
||||
keyword = "+".join(keywords)
|
||||
search_str = re.sub(r"[\W_ ]", "+", keyword)
|
||||
url = f"{settings.rss_parser.custom_url}/RSS/Search?searchstr={search_str}"
|
||||
if "://" not in url:
|
||||
url = f"https://{url}"
|
||||
url = f"https://mikanani.me/RSS/Search?searchstr={search_str}"
|
||||
return url
|
||||
|
||||
8
backend/src/module/searcher/plugin/nyaa.py
Normal file
8
backend/src/module/searcher/plugin/nyaa.py
Normal file
@@ -0,0 +1,8 @@
|
||||
import re
|
||||
|
||||
|
||||
def nyaa_url(keywords: list[str]):
|
||||
keyword = "+".join(keywords)
|
||||
search_str = re.sub(r"[\W_ ]", "+", keyword)
|
||||
url = f"https://nyaa.si/?page=rss&q={search_str}&c=0_0&f=0"
|
||||
return url
|
||||
Reference in New Issue
Block a user