Skip to content

Commit 34f6626

Browse files
authored
Add print "search_url" (#272)
* [API] Add print "search_url"
1 parent e4f0080 commit 34f6626

File tree

7 files changed

+59
-39
lines changed

7 files changed

+59
-39
lines changed

.github/workflows/build.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ on:
1313
- 'false'
1414
push:
1515
tags:
16-
- "*"
16+
- "v*.*"
1717

1818
jobs:
1919
publish:
20-
if: github.event.inputs.publish_pypi == 'true'
20+
if: startsWith(github.ref_name, 'v') && github.event.inputs.publish_pypi == 'true'
2121
runs-on: ubuntu-latest
2222

2323
steps:
@@ -39,6 +39,7 @@ jobs:
3939
run: |
4040
python -m pip install --upgrade pip
4141
python -m pip install setuptools wheel twine
42+
4243
- name: Build package
4344
run: python setup.py sdist bdist_wheel
4445

@@ -49,7 +50,7 @@ jobs:
4950
run: twine upload dist/*
5051

5152
build:
52-
if: github.event.inputs.publish_pypi == 'false'
53+
if: startsWith(github.ref_name, 'v') && github.event.inputs.publish_pypi == 'false'
5354
strategy:
5455
matrix:
5556
os: [windows-latest, ubuntu-latest, macos-latest]

StreamingCommunity/Api/Site/1337xx/site.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ def title_search(word_to_search: str) -> int:
5151
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
5252
sys.exit(1)
5353

54-
# Construct the full site URL and load the search page
54+
search_url = f"{site_constant.FULL_URL}/search/{word_to_search}/1/"
55+
console.print(f"[cyan]Search url: [yellow]{search_url}")
56+
5557
try:
5658
response = httpx.get(
57-
url=f"{site_constant.FULL_URL}/search/{word_to_search}/1/",
59+
url=search_url,
5860
headers={'user-agent': get_userAgent()},
5961
follow_redirects=True,
6062
timeout=max_timeout

StreamingCommunity/Api/Site/cb01new/site.py

+13-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,19 @@ def title_search(word_to_search: str) -> int:
5151
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
5252
sys.exit(1)
5353

54-
response = httpx.get(
55-
url=f"{site_constant.FULL_URL}/?s={word_to_search}",
56-
headers={'user-agent': get_userAgent()},
57-
timeout=max_timeout
58-
)
59-
response.raise_for_status()
54+
search_url = f"{site_constant.FULL_URL}/?s={word_to_search}"
55+
console.print(f"[cyan]Search url: [yellow]{search_url}")
56+
57+
try:
58+
response = httpx.get(
59+
url=search_url,
60+
headers={'user-agent': get_userAgent()},
61+
timeout=max_timeout
62+
)
63+
response.raise_for_status()
64+
65+
except Exception as e:
66+
console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
6067

6168
# Create soup and find table
6269
soup = BeautifulSoup(response.text, "html.parser")

StreamingCommunity/Api/Site/ddlstreamitaly/site.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ def title_search(word_to_search: str) -> int:
5353
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
5454
sys.exit(1)
5555

56-
# Send request to search for titles
56+
search_url = f"{site_constant.FULL_URL}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11"
57+
console.print(f"[cyan]Search url: [yellow]{search_url}")
58+
5759
try:
5860
response = httpx.get(
59-
url=f"{site_constant.FULL_URL}/search/?&q={word_to_search}&quick=1&type=videobox_video&nodes=11",
61+
url=search_url,
6062
headers={'user-agent': get_userAgent()},
6163
timeout=max_timeout
6264
)

StreamingCommunity/Api/Site/guardaserie/site.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ def title_search(word_to_search: str) -> int:
5151
console.print("[yellow]The service might be temporarily unavailable or the domain may have changed.[/yellow]")
5252
sys.exit(1)
5353

54-
# Send request to search for titles
55-
print(f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search")
54+
search_url = f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search"
55+
console.print(f"[cyan]Search url: [yellow]{search_url}")
56+
5657
try:
5758
response = httpx.get(
58-
url=f"{site_constant.FULL_URL}/?story={word_to_search}&do=search&subaction=search",
59+
url=search_url,
5960
headers={'user-agent': get_userAgent()},
6061
timeout=max_timeout
6162
)

StreamingCommunity/Api/Site/streamingcommunity/site.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,13 @@ def title_search(title_search: str) -> int:
5454

5555
media_search_manager.clear()
5656
table_show_manager.clear()
57-
57+
58+
search_url = f"{site_constant.FULL_URL}/api/search?q={title_search}",
59+
console.print(f"[cyan]Search url: [yellow]{search_url}")
60+
5861
try:
5962
response = httpx.get(
60-
url=f"{site_constant.FULL_URL}/api/search?q={title_search.replace(' ', '+')}",
63+
url=search_url,
6164
headers={'user-agent': get_userAgent()},
6265
timeout=max_timeout
6366
)

update.py

+25-21
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,37 @@ def move_content(source: str, destination: str):
4646

4747
def keep_specific_items(directory: str, keep_folder: str, keep_file: str):
4848
"""
49-
Delete all items in the directory except for the specified folder and file.
49+
Deletes all items in the given directory except for the specified folder,
50+
the specified file, and the '.git' directory.
5051
5152
Parameters:
5253
- directory (str): The path to the directory.
5354
- keep_folder (str): The name of the folder to keep.
5455
- keep_file (str): The name of the file to keep.
5556
"""
56-
try:
57-
if not os.path.exists(directory) or not os.path.isdir(directory):
58-
raise ValueError(f"Error: '{directory}' is not a valid directory.")
59-
60-
# Iterate through items in the directory
61-
for item in os.listdir(directory):
62-
item_path = os.path.join(directory, item)
63-
64-
# Check if the item is the specified folder or file
65-
if os.path.isdir(item_path) and item != keep_folder:
57+
if not os.path.exists(directory) or not os.path.isdir(directory):
58+
console.print(f"[red]Error: '{directory}' is not a valid directory.")
59+
return
60+
61+
# Define folders and files to skip
62+
skip_folders = {keep_folder, ".git"}
63+
skip_files = {keep_file}
64+
65+
# Iterate through items in the directory
66+
for item in os.listdir(directory):
67+
if item in skip_folders or item in skip_files:
68+
continue
69+
70+
item_path = os.path.join(directory, item)
71+
try:
72+
if os.path.isdir(item_path):
6673
shutil.rmtree(item_path)
67-
68-
elif os.path.isfile(item_path) and item != keep_file:
74+
console.log(f"[green]Removed directory: {item_path}")
75+
elif os.path.isfile(item_path):
6976
os.remove(item_path)
70-
71-
except PermissionError as pe:
72-
console.print(f"[red]PermissionError: {pe}. Check permissions and try again.")
73-
74-
except Exception as e:
75-
console.print(f"[red]Error: {e}")
77+
console.log(f"[green]Removed file: {item_path}")
78+
except Exception as e:
79+
console.log(f"[yellow]Skipping {item_path} due to error: {e}")
7680

7781

7882
def print_commit_info(commit_info: dict):
@@ -177,14 +181,14 @@ def main_upload():
177181
Main function to upload the latest commit of a GitHub repository.
178182
"""
179183
cmd_insert = Prompt.ask(
180-
"[bold red]Are you sure you want to delete all files? (Only 'Video' folder and 'update_version.py' will remain)",
184+
"[bold red]Are you sure you want to delete all files? (Only 'Video' folder and 'update.py' will remain)",
181185
choices=['y', 'n'],
182186
default='y',
183187
show_choices=True
184188
)
185189

186190
if cmd_insert.lower().strip() == 'y' or cmd_insert.lower().strip() == 'yes':
187-
console.print("[red]Deleting all files except 'Video' folder and 'update_version.py'...")
191+
console.print("[red]Deleting all files except 'Video' folder and 'update.py'...")
188192
keep_specific_items(".", "Video", "upload.py")
189193
download_and_extract_latest_commit()
190194
else:

0 commit comments

Comments
 (0)