Add print "search_url" (#272)

* [API] Add print "search_url"
This commit is contained in:
Dark1291 2025-02-24 11:04:43 +01:00 committed by GitHub
parent e4f0080a4b
commit 34f6626a58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 57 additions and 37 deletions

View File

@ -13,11 +13,11 @@ on:
- 'false' - 'false'
push: push:
tags: tags:
- "*" - "v*.*"
jobs: jobs:
publish: publish:
if: github.event.inputs.publish_pypi == 'true' if: startsWith(github.ref_name, 'v') && github.event.inputs.publish_pypi == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@ -39,6 +39,7 @@ jobs:
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
python -m pip install setuptools wheel twine python -m pip install setuptools wheel twine
- name: Build package - name: Build package
run: python setup.py sdist bdist_wheel run: python setup.py sdist bdist_wheel
@ -49,7 +50,7 @@ jobs:
run: twine upload dist/* run: twine upload dist/*
build: build:
if: github.event.inputs.publish_pypi == 'false' if: startsWith(github.ref_name, 'v') && github.event.inputs.publish_pypi == 'false'
strategy: strategy:
matrix: matrix:
os: [windows-latest, ubuntu-latest, macos-latest] os: [windows-latest, ubuntu-latest, macos-latest]

View File

@ -51,10 +51,12 @@ def title_search(word_to_search: str) -> int:
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]") console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
sys.exit(1) sys.exit(1)
# Construct the full site URL and load the search page search_url = f"{site_constant.FULL_URL}/search/{word_to_search}/1/"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try: try:
response = httpx.get( response = httpx.get(
url=f"{site_constant.FULL_URL}/search/{word_to_search}/1/", url=search_url,
headers={'user-agent': get_userAgent()}, headers={'user-agent': get_userAgent()},
follow_redirects=True, follow_redirects=True,
timeout=max_timeout timeout=max_timeout

View File

@ -51,12 +51,19 @@ def title_search(word_to_search: str) -> int:
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]") console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
sys.exit(1) sys.exit(1)
response = httpx.get( search_url = f"{site_constant.FULL_URL}/?s={word_to_search}"
url=f"{site_constant.FULL_URL}/?s={word_to_search}", console.print(f"[cyan]Search url: [yellow]{search_url}")
headers={'user-agent': get_userAgent()},
timeout=max_timeout try:
) response = httpx.get(
response.raise_for_status() url=search_url,
headers={'user-agent': get_userAgent()},
timeout=max_timeout
)
response.raise_for_status()
except Exception as e:
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
# Create soup and find table # Create soup and find table
soup = BeautifulSoup(response.text, "html.parser") soup = BeautifulSoup(response.text, "html.parser")

View File

@ -53,10 +53,12 @@ def title_search(word_to_search: str) -> int:
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]") console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
sys.exit(1) sys.exit(1)
# Send request to search for titles search_url = f"{site_constant.FULL_URL}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11"
console.print(f"[cyan]Search url: [yellow]{search_url}")
try: try:
response = httpx.get( response = httpx.get(
url=f"{site_constant.FULL_URL}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11", url=search_url,
headers={'user-agent': get_userAgent()}, headers={'user-agent': get_userAgent()},
timeout=max_timeout timeout=max_timeout
) )

View File

@ -51,11 +51,12 @@ def title_search(word_to_search: str) -> int:
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]") console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
sys.exit(1) sys.exit(1)
# Send request to search for titles search_url = f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search"
print(f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search") console.print(f"[cyan]Search url: [yellow]{search_url}")
try: try:
response = httpx.get( response = httpx.get(
url=f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search", url=search_url,
headers={'user-agent': get_userAgent()}, headers={'user-agent': get_userAgent()},
timeout=max_timeout timeout=max_timeout
) )

View File

@ -54,10 +54,13 @@ def title_search(title_search: str) -> int:
media_search_manager.clear() media_search_manager.clear()
table_show_manager.clear() table_show_manager.clear()
search_url = f"{site_constant.FULL_URL}/api/search?q={title_search}",
console.print(f"[cyan]Search url: [yellow]{search_url}")
try: try:
response = httpx.get( response = httpx.get(
url=f"{site_constant.FULL_URL}/api/search?q={title_search.replace(' ', '+')}", url=search_url,
headers={'user-agent': get_userAgent()}, headers={'user-agent': get_userAgent()},
timeout=max_timeout timeout=max_timeout
) )

View File

@ -46,33 +46,37 @@ def move_content(source: str, destination: str):
def keep_specific_items(directory: str, keep_folder: str, keep_file: str): def keep_specific_items(directory: str, keep_folder: str, keep_file: str):
""" """
Delete all items in the directory except for the specified folder and file. Deletes all items in the given directory except for the specified folder,
the specified file, and the '.git' directory.
Parameters: Parameters:
- directory (str): The path to the directory. - directory (str): The path to the directory.
- keep_folder (str): The name of the folder to keep. - keep_folder (str): The name of the folder to keep.
- keep_file (str): The name of the file to keep. - keep_file (str): The name of the file to keep.
""" """
try: if not os.path.exists(directory) or not os.path.isdir(directory):
if not os.path.exists(directory) or not os.path.isdir(directory): console.print(f"[red]Error: '{directory}' is not a valid directory.")
raise ValueError(f"Error: '{directory}' is not a valid directory.") return
# Iterate through items in the directory # Define folders and files to skip
for item in os.listdir(directory): skip_folders = {keep_folder, ".git"}
item_path = os.path.join(directory, item) skip_files = {keep_file}
# Check if the item is the specified folder or file # Iterate through items in the directory
if os.path.isdir(item_path) and item != keep_folder: for item in os.listdir(directory):
if item in skip_folders or item in skip_files:
continue
item_path = os.path.join(directory, item)
try:
if os.path.isdir(item_path):
shutil.rmtree(item_path) shutil.rmtree(item_path)
console.log(f"[green]Removed directory: {item_path}")
elif os.path.isfile(item_path) and item != keep_file: elif os.path.isfile(item_path):
os.remove(item_path) os.remove(item_path)
console.log(f"[green]Removed file: {item_path}")
except PermissionError as pe: except Exception as e:
console.print(f"[red]PermissionError: {pe}. Check permissions and try again.") console.log(f"[yellow]Skipping {item_path} due to error: {e}")
except Exception as e:
console.print(f"[red]Error: {e}")
def print_commit_info(commit_info: dict): def print_commit_info(commit_info: dict):
@ -177,14 +181,14 @@ def main_upload():
Main function to upload the latest commit of a GitHub repository. Main function to upload the latest commit of a GitHub repository.
""" """
cmd_insert = Prompt.ask( cmd_insert = Prompt.ask(
"[bold red]Are you sure you want to delete all files? (Only 'Video' folder and 'update_version.py' will remain)", "[bold red]Are you sure you want to delete all files? (Only 'Video' folder and 'update.py' will remain)",
choices=['y', 'n'], choices=['y', 'n'],
default='y', default='y',
show_choices=True show_choices=True
) )
if cmd_insert.lower().strip() == 'y' or cmd_insert.lower().strip() == 'yes': if cmd_insert.lower().strip() == 'y' or cmd_insert.lower().strip() == 'yes':
console.print("[red]Deleting all files except 'Video' folder and 'update_version.py'...") console.print("[red]Deleting all files except 'Video' folder and 'update.py'...")
keep_specific_items(".", "Video", "upload.py") keep_specific_items(".", "Video", "upload.py")
download_and_extract_latest_commit() download_and_extract_latest_commit()
else: else: