Skip to content

Commit d480fce

Browse files
authored
Fix search parsing for mediasetinfinity.
1 parent 29a8305 commit d480fce

File tree

17 files changed

+522
-326
lines changed

17 files changed

+522
-326
lines changed

StreamingCommunity/Api/Site/altadefinizione/__init__.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ def process_search_result(select_title, selections=None):
101101
episode_selection = selections.get('episode')
102102

103103
download_series(select_title, season_selection, episode_selection)
104+
media_search_manager.clear()
105+
table_show_manager.clear()
104106
return True
105107

106108
else:
107109
download_film(select_title)
110+
table_show_manager.clear()
108111
return True
109112

110113
# search("Game of Thrones", selections={"season": "1", "episode": "1-3"})
@@ -122,40 +125,37 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
122125
bot = None
123126
if site_constant.TELEGRAM_BOT:
124127
bot = get_bot_instance()
125-
128+
126129
if direct_item:
127130
select_title = MediaItem(**direct_item)
128-
process_search_result(select_title, selections)
129-
return True
130-
131+
result = process_search_result(select_title, selections)
132+
return result
133+
131134
# Get the user input for the search term
132135
actual_search_query = get_user_input(string_to_search)
133136

134-
# Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
137+
# Handle empty input
135138
if not actual_search_query:
136139
if bot:
137-
if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
140+
if actual_search_query is None:
138141
bot.send_message("Search term not provided or operation cancelled. Returning.", None)
139-
return
140-
141-
# Perform the database search
142-
len_database = title_search(quote_plus(actual_search_query))
142+
return False
143+
144+
# Search on database
145+
len_database = title_search(actual_search_query)
143146

144147
# If only the database is needed, return the manager
145148
if get_onlyDatabase:
146149
return media_search_manager
147-
150+
148151
if len_database > 0:
149152
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
150-
process_search_result(select_title, selections)
151-
return True
153+
result = process_search_result(select_title, selections)
154+
return result
152155

153156
else:
154157
if bot:
155158
bot.send_message(f"No results found for: '{actual_search_query}'", None)
156159
else:
157160
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
158-
159-
# Do not call search() recursively here to avoid infinite loops on no results.
160-
# The flow should return to the caller (e.g., main menu in run.py).
161-
return
161+
return False

StreamingCommunity/Api/Site/animeunity/__init__.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ def process_search_result(select_title, selections=None):
104104
episode_selection = selections.get('episode')
105105

106106
download_series(select_title, season_selection, episode_selection)
107+
media_search_manager.clear()
108+
table_show_manager.clear()
107109
return True
108110

109111
def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
@@ -120,40 +122,37 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
120122
bot = None
121123
if site_constant.TELEGRAM_BOT:
122124
bot = get_bot_instance()
123-
125+
124126
if direct_item:
125127
select_title = MediaItem(**direct_item)
126-
process_search_result(select_title, selections)
127-
return True
128+
result = process_search_result(select_title, selections)
129+
return result
128130

129131
# Get the user input for the search term
130132
actual_search_query = get_user_input(string_to_search)
131133

132-
# Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
134+
# Handle empty input
133135
if not actual_search_query:
134136
if bot:
135-
if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
137+
if actual_search_query is None:
136138
bot.send_message("Search term not provided or operation cancelled. Returning.", None)
137-
return
138-
139-
# Perform the database search
139+
return False
140+
141+
# Search on database
140142
len_database = title_search(actual_search_query)
141143

142144
# If only the database is needed, return the manager
143145
if get_onlyDatabase:
144146
return media_search_manager
145-
147+
146148
if len_database > 0:
147149
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
148-
process_search_result(select_title, selections)
149-
return True
150+
result = process_search_result(select_title, selections)
151+
return result
150152

151153
else:
152154
if bot:
153155
bot.send_message(f"No results found for: '{actual_search_query}'", None)
154156
else:
155157
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
156-
157-
# Do not call search() recursively here to avoid infinite loops on no results.
158-
# The flow should return to the caller (e.g., main menu in run.py).
159-
return
158+
return False

StreamingCommunity/Api/Site/animeworld/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ def process_search_result(select_title, selections=None):
9595
episode_selection = None
9696
if selections:
9797
episode_selection = selections.get('episode')
98+
9899
download_series(select_title, episode_selection)
100+
media_search_manager.clear()
101+
table_show_manager.clear()
99102
return True
100103

101104
else:
102105
download_film(select_title)
106+
table_show_manager.clear()
103107
return True
104108

105109
def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
@@ -119,36 +123,34 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
119123

120124
if direct_item:
121125
select_title = MediaItem(**direct_item)
122-
process_search_result(select_title, selections)
123-
return True
124-
126+
result = process_search_result(select_title, selections)
127+
return result
128+
125129
# Get the user input for the search term
126130
actual_search_query = get_user_input(string_to_search)
127131

128-
# Perform the database search
132+
# Handle empty input
129133
if not actual_search_query:
130134
if bot:
131135
if actual_search_query is None:
132136
bot.send_message("Search term not provided or operation cancelled. Returning.", None)
133-
return
137+
return False
134138

139+
# Search on database
135140
len_database = title_search(actual_search_query)
136141

137142
# If only the database is needed, return the manager
138143
if get_onlyDatabase:
139144
return media_search_manager
140-
145+
141146
if len_database > 0:
142147
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
143-
process_search_result(select_title, selections)
144-
return True
145-
148+
result = process_search_result(select_title, selections)
149+
return result
150+
146151
else:
147152
if bot:
148153
bot.send_message(f"No results found for: '{actual_search_query}'", None)
149154
else:
150155
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
151-
152-
# Do not call search() recursively here to avoid infinite loops on no results.
153-
# The flow should return to the caller (e.g., main menu in run.py).
154-
return
156+
return False

StreamingCommunity/Api/Site/crunchyroll/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,13 @@ def process_search_result(select_title, selections=None):
101101
episode_selection = selections.get('episode')
102102

103103
download_series(select_title, season_selection, episode_selection)
104+
media_search_manager.clear()
105+
table_show_manager.clear()
104106
return True
105107

106108
else:
107109
download_film(select_title)
110+
table_show_manager.clear()
108111
return True
109112

110113
# search("Game of Thrones", selections={"season": "1", "episode": "1-3"})
@@ -122,40 +125,37 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
122125
bot = None
123126
if site_constant.TELEGRAM_BOT:
124127
bot = get_bot_instance()
125-
128+
126129
if direct_item:
127130
select_title = MediaItem(**direct_item)
128-
process_search_result(select_title, selections)
129-
return True
131+
result = process_search_result(select_title, selections)
132+
return result
130133

131134
# Get the user input for the search term
132135
actual_search_query = get_user_input(string_to_search)
133136

134-
# Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
137+
# Handle empty input
135138
if not actual_search_query:
136139
if bot:
137-
if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
140+
if actual_search_query is None:
138141
bot.send_message("Search term not provided or operation cancelled. Returning.", None)
139-
return
140-
141-
# Perform the database search
142-
len_database = title_search(quote_plus(actual_search_query))
142+
return False
143+
144+
# Search on database
145+
len_database = title_search(actual_search_query)
143146

144147
# If only the database is needed, return the manager
145148
if get_onlyDatabase:
146149
return media_search_manager
147-
150+
148151
if len_database > 0:
149152
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
150-
process_search_result(select_title, selections)
151-
return True
153+
result = process_search_result(select_title, selections)
154+
return result
152155

153156
else:
154157
if bot:
155158
bot.send_message(f"No results found for: '{actual_search_query}'", None)
156159
else:
157160
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
158-
159-
# Do not call search() recursively here to avoid infinite loops on no results.
160-
# The flow should return to the caller (e.g., main menu in run.py).
161-
return
161+
return False

StreamingCommunity/Api/Site/guardaserie/__init__.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def process_search_result(select_title, selections=None):
9999
episode_selection = selections.get('episode')
100100

101101
download_series(select_title, season_selection, episode_selection)
102+
media_search_manager.clear()
103+
table_show_manager.clear()
102104
return True
103105

104106
def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
@@ -114,42 +116,38 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
114116
"""
115117
bot = None
116118
if site_constant.TELEGRAM_BOT:
117-
try:
118-
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
119-
bot = get_bot_instance()
120-
except Exception:
121-
bot = None
122-
119+
bot = get_bot_instance()
120+
123121
if direct_item:
124122
select_title = MediaItem(**direct_item)
125-
process_search_result(select_title, selections)
126-
return True
127-
123+
result = process_search_result(select_title, selections)
124+
return result
125+
128126
# Get the user input for the search term
129127
actual_search_query = get_user_input(string_to_search)
130-
128+
131129
# Handle empty input
132130
if not actual_search_query:
133131
if bot:
134132
if actual_search_query is None:
135133
bot.send_message("Search term not provided or operation cancelled. Returning.", None)
136-
return
137-
138-
# Search on database (preserve quote_plus usage)
134+
return False
135+
136+
# Search on database
139137
len_database = title_search(quote_plus(actual_search_query))
140-
138+
141139
# If only the database is needed, return the manager
142140
if get_onlyDatabase:
143141
return media_search_manager
144-
142+
145143
if len_database > 0:
146144
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
147-
process_search_result(select_title, selections)
148-
return True
149-
145+
result = process_search_result(select_title, selections)
146+
return result
147+
150148
else:
151149
if bot:
152150
bot.send_message(f"No results found for: '{actual_search_query}'", None)
153151
else:
154152
console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
155-
return
153+
return False

StreamingCommunity/Api/Site/guardaserie/site.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,12 @@ def title_search(query: str) -> int:
5959

6060
for serie_div in soup.find_all('div', class_='entry'):
6161
try:
62-
63-
title = serie_div.find('a').get("title")
64-
link = serie_div.find('a').get("href")
65-
6662
serie_info = {
67-
'name': title.replace("streaming guardaserie", ""),
68-
'url': link,
63+
'name': serie_div.find('a').get("title").replace("streaming guardaserie", ""),
64+
'url': serie_div.find('a').get("href"),
6965
'type': 'tv',
7066
'image': f"{site_constant.FULL_URL}/{serie_div.find('img').get('src')}",
7167
}
72-
7368
media_search_manager.add_media(serie_info)
7469

7570
except Exception as e:

0 commit comments

Comments
 (0)