StreamingCommunity 3.2.9__py3-none-any.whl → 3.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of StreamingCommunity might be problematic. Click here for more details.

Files changed (38) hide show
  1. StreamingCommunity/Api/Site/altadefinizione/__init__.py +67 -30
  2. StreamingCommunity/Api/Site/animeunity/__init__.py +65 -29
  3. StreamingCommunity/Api/Site/animeworld/__init__.py +80 -10
  4. StreamingCommunity/Api/Site/crunchyroll/__init__.py +75 -15
  5. StreamingCommunity/Api/Site/crunchyroll/site.py +7 -1
  6. StreamingCommunity/Api/Site/guardaserie/__init__.py +80 -10
  7. StreamingCommunity/Api/Site/mediasetinfinity/__init__.py +78 -15
  8. StreamingCommunity/Api/Site/mediasetinfinity/film.py +1 -1
  9. StreamingCommunity/Api/Site/mediasetinfinity/site.py +12 -2
  10. StreamingCommunity/Api/Site/mediasetinfinity/util/ScrapeSerie.py +6 -7
  11. StreamingCommunity/Api/Site/mediasetinfinity/util/get_license.py +162 -0
  12. StreamingCommunity/Api/Site/raiplay/__init__.py +78 -12
  13. StreamingCommunity/Api/Site/raiplay/film.py +2 -1
  14. StreamingCommunity/Api/Site/raiplay/series.py +21 -7
  15. StreamingCommunity/Api/Site/streamingcommunity/__init__.py +12 -9
  16. StreamingCommunity/Api/Site/streamingcommunity/site.py +4 -1
  17. StreamingCommunity/Api/Site/streamingcommunity/util/ScrapeSerie.py +5 -2
  18. StreamingCommunity/Api/Site/streamingwatch/__init__.py +76 -12
  19. StreamingCommunity/Lib/Downloader/DASH/cdm_helpher.py +8 -0
  20. StreamingCommunity/Lib/Downloader/DASH/downloader.py +109 -75
  21. StreamingCommunity/Lib/Downloader/HLS/downloader.py +18 -6
  22. StreamingCommunity/Lib/Downloader/HLS/segments.py +1 -1
  23. StreamingCommunity/Lib/Downloader/MP4/downloader.py +21 -3
  24. StreamingCommunity/Lib/FFmpeg/command.py +66 -7
  25. StreamingCommunity/Lib/FFmpeg/util.py +16 -13
  26. StreamingCommunity/Upload/update.py +2 -2
  27. StreamingCommunity/Upload/version.py +2 -2
  28. StreamingCommunity/Util/os.py +4 -1
  29. StreamingCommunity/run.py +4 -4
  30. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/METADATA +2 -7
  31. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/RECORD +35 -38
  32. StreamingCommunity/Api/Site/cb01new/__init__.py +0 -72
  33. StreamingCommunity/Api/Site/cb01new/film.py +0 -64
  34. StreamingCommunity/Api/Site/cb01new/site.py +0 -78
  35. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/WHEEL +0 -0
  36. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/entry_points.txt +0 -0
  37. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/licenses/LICENSE +0 -0
  38. {streamingcommunity-3.2.9.dist-info → streamingcommunity-3.3.1.dist-info}/top_level.txt +0 -0
@@ -22,6 +22,7 @@ from .site import title_search, table_show_manager, media_search_manager
22
22
  from .film import download_film
23
23
  from .series import download_series
24
24
 
25
+
25
26
  # Variable
26
27
  indice = 2
27
28
  _useFor = "Film_&_Serie"
@@ -37,25 +38,39 @@ def get_user_input(string_to_search: str = None):
37
38
  """
38
39
  Asks the user to input a search term.
39
40
  Handles both Telegram bot input and direct input.
41
+ If string_to_search is provided, it's returned directly (after stripping).
40
42
  """
41
- if string_to_search is None:
42
- if site_constant.TELEGRAM_BOT:
43
- bot = get_bot_instance()
44
- string_to_search = bot.ask(
45
- "key_search",
46
- "Enter the search term\nor type 'back' to return to the menu: ",
47
- None
48
- )
49
-
50
- if string_to_search == 'back':
43
+ if string_to_search is not None:
44
+ return string_to_search.strip()
51
45
 
46
+ if site_constant.TELEGRAM_BOT:
47
+ bot = get_bot_instance()
48
+ user_response = bot.ask(
49
+ "key_search", # Request type
50
+ "Enter the search term\nor type 'back' to return to the menu: ",
51
+ None
52
+ )
53
+
54
+ if user_response is None:
55
+ bot.send_message("Timeout: No search term entered.", None)
56
+ return None
57
+
58
+ if user_response.lower() == 'back':
59
+ bot.send_message("Returning to the main menu...", None)
60
+
61
+ try:
52
62
  # Restart the script
53
63
  subprocess.Popen([sys.executable] + sys.argv)
54
64
  sys.exit()
55
- else:
56
- string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
57
-
58
- return string_to_search
65
+
66
+ except Exception as e:
67
+ bot.send_message(f"Error during restart attempt: {e}", None)
68
+ return None # Return None if restart fails
69
+
70
+ return user_response.strip()
71
+
72
+ else:
73
+ return msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
59
74
 
60
75
  def process_search_result(select_title, selections=None):
61
76
  """
@@ -65,7 +80,18 @@ def process_search_result(select_title, selections=None):
65
80
  select_title (MediaItem): The selected media item
66
81
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
67
82
  {'season': season_selection, 'episode': episode_selection}
83
+
84
+ Returns:
85
+ bool: True if processing was successful, False otherwise
68
86
  """
87
+ if not select_title:
88
+ if site_constant.TELEGRAM_BOT:
89
+ bot = get_bot_instance()
90
+ bot.send_message("No title selected or selection cancelled.", None)
91
+ else:
92
+ console.print("[yellow]No title selected or selection cancelled.")
93
+ return False
94
+
69
95
  if select_title.type == 'tv':
70
96
  season_selection = None
71
97
  episode_selection = None
@@ -75,9 +101,11 @@ def process_search_result(select_title, selections=None):
75
101
  episode_selection = selections.get('episode')
76
102
 
77
103
  download_series(select_title, season_selection, episode_selection)
104
+ return True
78
105
 
79
106
  else:
80
107
  download_film(select_title)
108
+ return True
81
109
 
82
110
  # search("Game of Thrones", selections={"season": "1", "episode": "1-3"})
83
111
  def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
@@ -86,39 +114,48 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
86
114
 
87
115
  Parameters:
88
116
  string_to_search (str, optional): String to search for
89
- get_onylDatabase (bool, optional): If True, return only the database object
117
+ get_onlyDatabase (bool, optional): If True, return only the database object
90
118
  direct_item (dict, optional): Direct item to process (bypass search)
91
119
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
92
120
  {'season': season_selection, 'episode': episode_selection}
93
121
  """
122
+ bot = None
123
+ if site_constant.TELEGRAM_BOT:
124
+ bot = get_bot_instance()
125
+
94
126
  if direct_item:
95
127
  select_title = MediaItem(**direct_item)
96
128
  process_search_result(select_title, selections)
97
- return
98
-
129
+ return True
130
+
99
131
  # Get the user input for the search term
100
- string_to_search = get_user_input(string_to_search)
132
+ actual_search_query = get_user_input(string_to_search)
133
+
134
+ # Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
135
+ if not actual_search_query:
136
+ if bot:
137
+ if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
138
+ bot.send_message("Search term not provided or operation cancelled. Returning.", None)
139
+ return
101
140
 
102
141
  # Perform the database search
103
- len_database = title_search(quote_plus(string_to_search))
142
+ len_database = title_search(quote_plus(actual_search_query))
104
143
 
105
144
  # If only the database is needed, return the manager
106
145
  if get_onlyDatabase:
107
146
  return media_search_manager
108
-
109
- if site_constant.TELEGRAM_BOT:
110
- bot = get_bot_instance()
111
-
147
+
112
148
  if len_database > 0:
113
149
  select_title = get_select_title(table_show_manager, media_search_manager, len_database)
114
150
  process_search_result(select_title, selections)
151
+ return True
115
152
 
116
153
  else:
117
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
118
-
119
- if site_constant.TELEGRAM_BOT:
120
- bot.send_message("No results found, please try again", None)
154
+ if bot:
155
+ bot.send_message(f"No results found for: '{actual_search_query}'", None)
156
+ else:
157
+ console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
121
158
 
122
- # If no results are found, ask again
123
- string_to_search = get_user_input()
124
- search(string_to_search, get_onlyDatabase, None, selections)
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
@@ -37,25 +37,39 @@ def get_user_input(string_to_search: str = None):
37
37
  """
38
38
  Asks the user to input a search term.
39
39
  Handles both Telegram bot input and direct input.
40
+ If string_to_search is provided, it's returned directly (after stripping).
40
41
  """
41
- if string_to_search is None:
42
- if site_constant.TELEGRAM_BOT:
43
- bot = get_bot_instance()
44
- string_to_search = bot.ask(
45
- "key_search",
46
- "Enter the search term\nor type 'back' to return to the menu: ",
47
- None
48
- )
49
-
50
- if string_to_search == 'back':
42
+ if string_to_search is not None:
43
+ return string_to_search.strip()
51
44
 
45
+ if site_constant.TELEGRAM_BOT:
46
+ bot = get_bot_instance()
47
+ user_response = bot.ask(
48
+ "key_search", # Request type
49
+ "Enter the search term\nor type 'back' to return to the menu: ",
50
+ None
51
+ )
52
+
53
+ if user_response is None:
54
+ bot.send_message("Timeout: No search term entered.", None)
55
+ return None
56
+
57
+ if user_response.lower() == 'back':
58
+ bot.send_message("Returning to the main menu...", None)
59
+
60
+ try:
52
61
  # Restart the script
53
62
  subprocess.Popen([sys.executable] + sys.argv)
54
63
  sys.exit()
55
- else:
56
- string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
57
-
58
- return string_to_search
64
+
65
+ except Exception as e:
66
+ bot.send_message(f"Error during restart attempt: {e}", None)
67
+ return None # Return None if restart fails
68
+
69
+ return user_response.strip()
70
+
71
+ else:
72
+ return msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
59
73
 
60
74
  def process_search_result(select_title, selections=None):
61
75
  """
@@ -65,9 +79,21 @@ def process_search_result(select_title, selections=None):
65
79
  select_title (MediaItem): The selected media item
66
80
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
67
81
  {'season': season_selection, 'episode': episode_selection}
82
+
83
+ Returns:
84
+ bool: True if processing was successful, False otherwise
68
85
  """
86
+ if not select_title:
87
+ if site_constant.TELEGRAM_BOT:
88
+ bot = get_bot_instance()
89
+ bot.send_message("No title selected or selection cancelled.", None)
90
+ else:
91
+ console.print("[yellow]No title selected or selection cancelled.")
92
+ return False
93
+
69
94
  if select_title.type == 'Movie':
70
95
  download_film(select_title)
96
+ return True
71
97
 
72
98
  else:
73
99
  season_selection = None
@@ -78,6 +104,7 @@ def process_search_result(select_title, selections=None):
78
104
  episode_selection = selections.get('episode')
79
105
 
80
106
  download_series(select_title, season_selection, episode_selection)
107
+ return True
81
108
 
82
109
  def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
83
110
  """
@@ -90,34 +117,43 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
90
117
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
91
118
  {'season': season_selection, 'episode': episode_selection}
92
119
  """
120
+ bot = None
121
+ if site_constant.TELEGRAM_BOT:
122
+ bot = get_bot_instance()
123
+
93
124
  if direct_item:
94
125
  select_title = MediaItem(**direct_item)
95
126
  process_search_result(select_title, selections)
96
- return
97
-
127
+ return True
128
+
98
129
  # Get the user input for the search term
99
- string_to_search = get_user_input(string_to_search)
130
+ actual_search_query = get_user_input(string_to_search)
100
131
 
132
+ # Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
133
+ if not actual_search_query:
134
+ if bot:
135
+ if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
136
+ bot.send_message("Search term not provided or operation cancelled. Returning.", None)
137
+ return
138
+
101
139
  # Perform the database search
102
- len_database = title_search(string_to_search)
140
+ len_database = title_search(actual_search_query)
103
141
 
104
142
  # If only the database is needed, return the manager
105
143
  if get_onlyDatabase:
106
144
  return media_search_manager
107
-
108
- if site_constant.TELEGRAM_BOT:
109
- bot = get_bot_instance()
110
145
 
111
146
  if len_database > 0:
112
- select_title = get_select_title(table_show_manager, media_search_manager,len_database)
147
+ select_title = get_select_title(table_show_manager, media_search_manager, len_database)
113
148
  process_search_result(select_title, selections)
149
+ return True
114
150
 
115
151
  else:
116
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
117
-
118
- if site_constant.TELEGRAM_BOT:
119
- bot.send_message("No results found, please try again", None)
152
+ if bot:
153
+ bot.send_message(f"No results found for: '{actual_search_query}'", None)
154
+ else:
155
+ console.print(f"\n[red]Nothing matching was found for[white]: [purple]{actual_search_query}")
120
156
 
121
- # If no results are found, ask again
122
- string_to_search = get_user_input()
123
- search(string_to_search, get_onlyDatabase, None, selections)
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
@@ -1,5 +1,9 @@
1
1
  # 21.03.25
2
2
 
3
+ import sys
4
+ import subprocess
5
+
6
+
3
7
  # External library
4
8
  from rich.console import Console
5
9
  from rich.prompt import Prompt
@@ -9,6 +13,7 @@ from rich.prompt import Prompt
9
13
  from StreamingCommunity.Api.Template import get_select_title
10
14
  from StreamingCommunity.Api.Template.config_loader import site_constant
11
15
  from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
16
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
12
17
 
13
18
 
14
19
  # Logic class
@@ -28,7 +33,44 @@ msg = Prompt()
28
33
  console = Console()
29
34
 
30
35
 
31
-
36
+ def get_user_input(string_to_search: str = None):
37
+ """
38
+ Asks the user to input a search term.
39
+ Handles both Telegram bot input and direct input.
40
+ If string_to_search is provided, it's returned directly (after stripping).
41
+ """
42
+ if string_to_search is not None:
43
+ return string_to_search.strip()
44
+
45
+ if site_constant.TELEGRAM_BOT:
46
+ bot = get_bot_instance()
47
+ user_response = bot.ask(
48
+ "key_search", # Request type
49
+ "Enter the search term\nor type 'back' to return to the menu: ",
50
+ None
51
+ )
52
+
53
+ if user_response is None:
54
+ bot.send_message("Timeout: No search term entered.", None)
55
+ return None
56
+
57
+ if user_response.lower() == 'back':
58
+ bot.send_message("Returning to the main menu...", None)
59
+
60
+ try:
61
+ # Restart the script
62
+ subprocess.Popen([sys.executable] + sys.argv)
63
+ sys.exit()
64
+
65
+ except Exception as e:
66
+ bot.send_message(f"Error during restart attempt: {e}", None)
67
+ return None # Return None if restart fails
68
+
69
+ return user_response.strip()
70
+
71
+ else:
72
+ return msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
73
+
32
74
  def process_search_result(select_title, selections=None):
33
75
  """
34
76
  Handles the search result and initiates the download for either a film or series.
@@ -37,15 +79,28 @@ def process_search_result(select_title, selections=None):
37
79
  select_title (MediaItem): The selected media item
38
80
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
39
81
  {'season': season_selection, 'episode': episode_selection}
82
+
83
+ Returns:
84
+ bool: True if processing was successful, False otherwise
40
85
  """
86
+ if not select_title:
87
+ if site_constant.TELEGRAM_BOT:
88
+ bot = get_bot_instance()
89
+ bot.send_message("No title selected or selection cancelled.", None)
90
+ else:
91
+ console.print("[yellow]No title selected or selection cancelled.")
92
+ return False
93
+
41
94
  if select_title.type == "TV":
42
95
  episode_selection = None
43
96
  if selections:
44
97
  episode_selection = selections.get('episode')
45
98
  download_series(select_title, episode_selection)
99
+ return True
46
100
 
47
101
  else:
48
102
  download_film(select_title)
103
+ return True
49
104
 
50
105
  def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
51
106
  """
@@ -58,27 +113,42 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
58
113
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
59
114
  {'season': season_selection, 'episode': episode_selection}
60
115
  """
116
+ bot = None
117
+ if site_constant.TELEGRAM_BOT:
118
+ bot = get_bot_instance()
119
+
61
120
  if direct_item:
62
121
  select_title = MediaItem(**direct_item)
63
122
  process_search_result(select_title, selections)
64
- return
123
+ return True
65
124
 
66
125
  # Get the user input for the search term
67
- if string_to_search is None:
68
- string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
126
+ actual_search_query = get_user_input(string_to_search)
69
127
 
70
128
  # Perform the database search
71
- len_database = title_search(string_to_search)
129
+ if not actual_search_query:
130
+ if bot:
131
+ if actual_search_query is None:
132
+ bot.send_message("Search term not provided or operation cancelled. Returning.", None)
133
+ return
134
+
135
+ len_database = title_search(actual_search_query)
72
136
 
73
137
  # If only the database is needed, return the manager
74
138
  if get_onlyDatabase:
75
139
  return media_search_manager
76
140
 
77
141
  if len_database > 0:
78
- select_title = get_select_title(table_show_manager, media_search_manager,len_database)
142
+ select_title = get_select_title(table_show_manager, media_search_manager, len_database)
79
143
  process_search_result(select_title, selections)
80
-
144
+ return True
145
+
81
146
  else:
82
- # If no results are found, ask again
83
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
84
- search()
147
+ if bot:
148
+ bot.send_message(f"No results found for: '{actual_search_query}'", None)
149
+ else:
150
+ 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
@@ -1,5 +1,7 @@
1
1
  # 16.03.25
2
2
 
3
+ import sys
4
+ import subprocess
3
5
  from urllib.parse import quote_plus
4
6
 
5
7
 
@@ -12,6 +14,7 @@ from rich.prompt import Prompt
12
14
  from StreamingCommunity.Api.Template import get_select_title
13
15
  from StreamingCommunity.Api.Template.config_loader import site_constant
14
16
  from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
17
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
15
18
 
16
19
 
17
20
  # Logic class
@@ -19,6 +22,7 @@ from .site import title_search, table_show_manager, media_search_manager
19
22
  from .film import download_film
20
23
  from .series import download_series
21
24
 
25
+
22
26
  # Variable
23
27
  indice = 8
24
28
  _useFor = "Anime"
@@ -34,11 +38,39 @@ def get_user_input(string_to_search: str = None):
34
38
  """
35
39
  Asks the user to input a search term.
36
40
  Handles both Telegram bot input and direct input.
41
+ If string_to_search is provided, it's returned directly (after stripping).
37
42
  """
38
- if string_to_search is None:
39
- string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
40
-
41
- return string_to_search
43
+ if string_to_search is not None:
44
+ return string_to_search.strip()
45
+
46
+ if site_constant.TELEGRAM_BOT:
47
+ bot = get_bot_instance()
48
+ user_response = bot.ask(
49
+ "key_search", # Request type
50
+ "Enter the search term\nor type 'back' to return to the menu: ",
51
+ None
52
+ )
53
+
54
+ if user_response is None:
55
+ bot.send_message("Timeout: No search term entered.", None)
56
+ return None
57
+
58
+ if user_response.lower() == 'back':
59
+ bot.send_message("Returning to the main menu...", None)
60
+
61
+ try:
62
+ # Restart the script
63
+ subprocess.Popen([sys.executable] + sys.argv)
64
+ sys.exit()
65
+
66
+ except Exception as e:
67
+ bot.send_message(f"Error during restart attempt: {e}", None)
68
+ return None # Return None if restart fails
69
+
70
+ return user_response.strip()
71
+
72
+ else:
73
+ return msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
42
74
 
43
75
  def process_search_result(select_title, selections=None):
44
76
  """
@@ -48,7 +80,18 @@ def process_search_result(select_title, selections=None):
48
80
  select_title (MediaItem): The selected media item
49
81
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
50
82
  {'season': season_selection, 'episode': episode_selection}
83
+
84
+ Returns:
85
+ bool: True if processing was successful, False otherwise
51
86
  """
87
+ if not select_title:
88
+ if site_constant.TELEGRAM_BOT:
89
+ bot = get_bot_instance()
90
+ bot.send_message("No title selected or selection cancelled.", None)
91
+ else:
92
+ console.print("[yellow]No title selected or selection cancelled.")
93
+ return False
94
+
52
95
  if select_title.type == 'tv':
53
96
  season_selection = None
54
97
  episode_selection = None
@@ -58,10 +101,12 @@ def process_search_result(select_title, selections=None):
58
101
  episode_selection = selections.get('episode')
59
102
 
60
103
  download_series(select_title, season_selection, episode_selection)
104
+ return True
61
105
 
62
106
  else:
63
107
  download_film(select_title)
64
-
108
+ return True
109
+
65
110
  # search("Game of Thrones", selections={"season": "1", "episode": "1-3"})
66
111
  def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None, selections: dict = None):
67
112
  """
@@ -69,33 +114,48 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
69
114
 
70
115
  Parameters:
71
116
  string_to_search (str, optional): String to search for
72
- get_onylDatabase (bool, optional): If True, return only the database object
117
+ get_onlyDatabase (bool, optional): If True, return only the database object
73
118
  direct_item (dict, optional): Direct item to process (bypass search)
74
119
  selections (dict, optional): Dictionary containing selection inputs that bypass manual input
75
120
  {'season': season_selection, 'episode': episode_selection}
76
121
  """
122
+ bot = None
123
+ if site_constant.TELEGRAM_BOT:
124
+ bot = get_bot_instance()
125
+
77
126
  if direct_item:
78
127
  select_title = MediaItem(**direct_item)
79
128
  process_search_result(select_title, selections)
80
- return
129
+ return True
81
130
 
82
131
  # Get the user input for the search term
83
- string_to_search = get_user_input(string_to_search)
132
+ actual_search_query = get_user_input(string_to_search)
133
+
134
+ # Handle cases where user input is empty, or 'back' was handled (sys.exit or None return)
135
+ if not actual_search_query:
136
+ if bot:
137
+ if actual_search_query is None: # Specifically for timeout from bot.ask or failed restart
138
+ bot.send_message("Search term not provided or operation cancelled. Returning.", None)
139
+ return
84
140
 
85
141
  # Perform the database search
86
- len_database = title_search(quote_plus(string_to_search))
142
+ len_database = title_search(quote_plus(actual_search_query))
87
143
 
88
144
  # If only the database is needed, return the manager
89
145
  if get_onlyDatabase:
90
146
  return media_search_manager
91
-
147
+
92
148
  if len_database > 0:
93
149
  select_title = get_select_title(table_show_manager, media_search_manager, len_database)
94
150
  process_search_result(select_title, selections)
151
+ return True
95
152
 
96
153
  else:
97
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
98
-
99
- # If no results are found, ask again
100
- string_to_search = get_user_input()
101
- search(string_to_search, get_onlyDatabase, None, selections)
154
+ if bot:
155
+ bot.send_message(f"No results found for: '{actual_search_query}'", None)
156
+ else:
157
+ 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
@@ -1,6 +1,7 @@
1
1
  # 16.03.25
2
2
 
3
3
  import os
4
+ import sys
4
5
 
5
6
 
6
7
  # External libraries
@@ -45,7 +46,12 @@ def title_search(query: str) -> int:
45
46
  cdm_device_path = get_wvd_path()
46
47
  if not cdm_device_path or not isinstance(cdm_device_path, (str, bytes, os.PathLike)) or not os.path.isfile(cdm_device_path):
47
48
  console.print(f"[bold red] CDM file not found or invalid path: {cdm_device_path}[/bold red]")
48
- return None
49
+ sys.exit(0)
50
+
51
+ # Check if x_cr_tab_id or etp_rt is present
52
+ if config_manager.get_dict("SITE_LOGIN", "crunchyroll")['x_cr_tab_id'] is None or config_manager.get_dict("SITE_LOGIN", "crunchyroll")['x_cr_tab_id'] == "" or config_manager.get_dict("SITE_LOGIN", "crunchyroll")['etp_rt'] is None or config_manager.get_dict("SITE_LOGIN", "crunchyroll")['etp_rt'] == "":
53
+ console.print("[bold red] x_cr_tab_id or etp_rt is missing or empty.[/bold red]")
54
+ sys.exit(0)
49
55
 
50
56
  # Build new Crunchyroll API search URL
51
57
  api_url = "https://www.crunchyroll.com/content/v2/discover/search"