From 477637ee5c848c5860a85939fbf6393b6cc2d3dd Mon Sep 17 00:00:00 2001 From: Lovi <62809003+Lovi-0@users.noreply.github.com> Date: Sun, 16 Mar 2025 09:48:08 +0100 Subject: [PATCH] api: From cb01blog to cb01new --- .gitignore | 3 ++- README.md | 3 +++ StreamingCommunity/Api/Site/cb01new/site.py | 9 +++++---- StreamingCommunity/Util/config_json.py | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 4f12a50..0f9804a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,5 @@ note.txt cmd.txt bot_config.json scripts.json -active_requests.json \ No newline at end of file +active_requests.json +domains.json \ No newline at end of file diff --git a/README.md b/README.md index 49ffe63..b3749cb 100644 --- a/README.md +++ b/README.md @@ -634,6 +634,9 @@ The API-based domain updates are currently deprecated. To use it anyway, set `us Note: If `use_api` is set to `false` and no `domains.json` file is found, the script will raise an error. +#### 💡 Adding a New Site to the Legacy API +If you want to add a new site to the legacy API, just message me on the Discord server, and I'll add it! + # COMMAND - Download a specific season by entering its number. diff --git a/StreamingCommunity/Api/Site/cb01new/site.py b/StreamingCommunity/Api/Site/cb01new/site.py index ea0c328..52aca12 100644 --- a/StreamingCommunity/Api/Site/cb01new/site.py +++ b/StreamingCommunity/Api/Site/cb01new/site.py @@ -40,7 +40,7 @@ def title_search(word_to_search: str) -> int: media_search_manager.clear() table_show_manager.clear() - search_url = f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search" + search_url = f"{site_constant.FULL_URL}/?s={word_to_search}" console.print(f"[cyan]Search url: [yellow]{search_url}") try: @@ -54,10 +54,11 @@ def title_search(word_to_search: str) -> int: # Create soup and find table soup = BeautifulSoup(response.text, "html.parser") - for div in soup.find_all("div", class_ = "short-main"): + for card in soup.find_all("div", class_=["card", "mp-post", "horizontal"]): try: - url = div.find("a").get("href") - title = div.find("a").get_text(strip=True) + title_tag = card.find("h3", class_="card-title").find("a") + url = title_tag.get("href") + title = title_tag.get_text(strip=True) title_info = { 'name': title, diff --git a/StreamingCommunity/Util/config_json.py b/StreamingCommunity/Util/config_json.py index b2bc7f5..cde8cc9 100644 --- a/StreamingCommunity/Util/config_json.py +++ b/StreamingCommunity/Util/config_json.py @@ -196,6 +196,7 @@ class ConfigManager: except Exception as e: logging.error(f"Error reading configuration file: {e}") console.print(f"[bold red]Failed to read configuration:[/bold red] {str(e)}") + sys.exit(0) def download_requirements(self, url: str, filename: str) -> None: """