Skip to content

Commit

Permalink
fix: search_provider.py
Browse files Browse the repository at this point in the history
  • Loading branch information
EstrellaXD committed Aug 28, 2023
1 parent 152aa20 commit e5f1b70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions backend/src/module/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .config import VERSION, settings
from .log import LOG_PATH, setup_logger
from .search_provider import SEARCH_CONFIG

TMDB_API = "32b19d6a05b512190a056fa4e747cbbc"
DATA_PATH = "sqlite:///data/data.db"
Expand Down
23 changes: 23 additions & 0 deletions backend/src/module/conf/search_provider.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pathlib import Path
from module.utils import json_config

DEFAULT_PROVIDER = {
"mikan": "https://mikanani.me/RSS/Search?searchstr=%s",
"nyaa": "https://nyaa.si/?page=rss&q=%s&c=0_0&f=0",
"dmhy": "http://dmhy.org/topics/rss/rss.xml?keyword=%s"
}

PROVIDER_PATH = Path("config/search_provider.json")


def load_provider():
if PROVIDER_PATH.exists():
return json_config.load(PROVIDER_PATH)
else:
json_config.save(PROVIDER_PATH, DEFAULT_PROVIDER)
return DEFAULT_PROVIDER


SEARCH_CONFIG = load_provider()


5 changes: 1 addition & 4 deletions backend/src/module/searcher/provider.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import re

from module.utils import json_config
from module.models import RSSItem


SEARCH_CONFIG = json_config.load("config/search_provider.json")
from module.conf import SEARCH_CONFIG


def search_url(site: str, keywords: list[str]) -> RSSItem:
Expand Down

0 comments on commit e5f1b70

Please sign in to comment.