StreamingCommunity 2.9.4__py3-none-any.whl → 2.9.5__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 (32) hide show
  1. StreamingCommunity/Api/Site/1337xx/__init__.py +26 -12
  2. StreamingCommunity/Api/Site/1337xx/site.py +2 -1
  3. StreamingCommunity/Api/Site/altadefinizione/__init__.py +64 -17
  4. StreamingCommunity/Api/Site/altadefinizione/film.py +31 -1
  5. StreamingCommunity/Api/Site/altadefinizione/series.py +53 -8
  6. StreamingCommunity/Api/Site/altadefinizione/site.py +22 -4
  7. StreamingCommunity/Api/Site/altadefinizione/util/ScrapeSerie.py +2 -2
  8. StreamingCommunity/Api/Site/animeunity/__init__.py +53 -32
  9. StreamingCommunity/Api/Site/animeunity/film_serie.py +5 -1
  10. StreamingCommunity/Api/Site/animeunity/site.py +0 -2
  11. StreamingCommunity/Api/Site/cb01new/__init__.py +26 -14
  12. StreamingCommunity/Api/Site/cb01new/site.py +7 -5
  13. StreamingCommunity/Api/Site/ddlstreamitaly/__init__.py +26 -15
  14. StreamingCommunity/Api/Site/guardaserie/__init__.py +23 -11
  15. StreamingCommunity/Api/Site/guardaserie/site.py +2 -1
  16. StreamingCommunity/Api/Site/mostraguarda/__init__.py +27 -7
  17. StreamingCommunity/Api/Site/streamingcommunity/__init__.py +50 -27
  18. StreamingCommunity/Api/Site/streamingcommunity/series.py +5 -1
  19. StreamingCommunity/Api/Site/streamingcommunity/site.py +4 -0
  20. StreamingCommunity/Lib/Downloader/HLS/segments.py +1 -1
  21. StreamingCommunity/Lib/Downloader/MP4/downloader.py +7 -6
  22. StreamingCommunity/Upload/version.py +1 -1
  23. StreamingCommunity/Util/config_json.py +2 -8
  24. StreamingCommunity/Util/table.py +12 -2
  25. StreamingCommunity/global_search.py +315 -0
  26. StreamingCommunity/run.py +27 -3
  27. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/METADATA +39 -10
  28. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/RECORD +32 -31
  29. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/LICENSE +0 -0
  30. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/WHEEL +0 -0
  31. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/entry_points.txt +0 -0
  32. {streamingcommunity-2.9.4.dist-info → streamingcommunity-2.9.5.dist-info}/top_level.txt +0 -0
@@ -10,10 +10,11 @@ from rich.prompt import Prompt
10
10
 
11
11
  # Internal utilities
12
12
  from StreamingCommunity.Api.Template import get_select_title
13
+ from StreamingCommunity.Api.Template.config_loader import site_constant
14
+ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
13
15
 
14
16
 
15
17
  # Logic class
16
- from StreamingCommunity.Api.Template.config_loader import site_constant
17
18
  from .site import title_search, media_search_manager, table_show_manager
18
19
  from .title import download_title
19
20
 
@@ -29,30 +30,43 @@ console = Console()
29
30
  msg = Prompt()
30
31
 
31
32
 
32
- def search(string_to_search: str = None, get_onylDatabase: bool = False):
33
+
34
+ def process_search_result(select_title):
35
+ """
36
+ Handles the search result and initiates the download for either a film or series.
37
+ """
38
+ download_title(select_title)
39
+
40
+ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None):
33
41
  """
34
- Main function of the application for film and series.
42
+ Main function of the application for search film, series and anime.
43
+
44
+ Parameters:
45
+ string_to_search (str, optional): String to search for
46
+ get_onylDatabase (bool, optional): If True, return only the database object
47
+ direct_item (dict, optional): Direct item to process (bypass search)
35
48
  """
49
+ if direct_item:
50
+ select_title = MediaItem(**direct_item)
51
+ process_search_result(select_title)
52
+ return
53
+
36
54
  if string_to_search is None:
37
55
  string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
38
56
 
39
- # Search on database
57
+ # Perform the database search
40
58
  len_database = title_search(quote_plus(string_to_search))
41
59
 
42
- # Return list of elements
43
- if get_onylDatabase:
60
+ # If only the database is needed, return the manager
61
+ if get_onlyDatabase:
44
62
  return media_search_manager
45
63
 
46
64
  if len_database > 0:
47
-
48
- # Select title from list
49
65
  select_title = get_select_title(table_show_manager, media_search_manager)
50
-
51
- # Download title
52
66
  download_title(select_title)
53
67
 
54
68
  else:
55
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
56
69
 
57
- # Retry
70
+ # If no results are found, ask again
71
+ console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
58
72
  search()
@@ -62,7 +62,8 @@ def title_search(word_to_search: str) -> int:
62
62
  'seader': tr.find_all("td")[-5].get_text(strip=True),
63
63
  'leacher': tr.find_all("td")[-4].get_text(strip=True),
64
64
  'date': tr.find_all("td")[-3].get_text(strip=True).replace("'", ""),
65
- 'size': tr.find_all("td")[-2].get_text(strip=True)
65
+ 'size': tr.find_all("td")[-2].get_text(strip=True),
66
+ 'type': 'torrent'
66
67
  }
67
68
  media_search_manager.add_media(title_info)
68
69
 
@@ -1,5 +1,7 @@
1
- # 21.05.24
1
+ # 16.03.25
2
2
 
3
+ import sys
4
+ import subprocess
3
5
  from urllib.parse import quote_plus
4
6
 
5
7
 
@@ -10,15 +12,16 @@ from rich.prompt import Prompt
10
12
 
11
13
  # Internal utilities
12
14
  from StreamingCommunity.Api.Template import get_select_title
15
+ from StreamingCommunity.Api.Template.config_loader import site_constant
16
+ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
17
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
13
18
 
14
19
 
15
20
  # Logic class
16
- from StreamingCommunity.Api.Template.config_loader import site_constant
17
21
  from .site import title_search, table_show_manager, media_search_manager
18
22
  from .film import download_film
19
23
  from .series import download_series
20
24
 
21
-
22
25
  # Variable
23
26
  indice = 2
24
27
  _useFor = "film_serie"
@@ -30,32 +33,76 @@ msg = Prompt()
30
33
  console = Console()
31
34
 
32
35
 
33
- def search(string_to_search: str = None, get_onylDatabase: bool = False):
36
+ def get_user_input(string_to_search: str = None):
34
37
  """
35
- Main function of the application for film and series.
38
+ Asks the user to input a search term.
39
+ Handles both Telegram bot input and direct input.
36
40
  """
37
41
  if string_to_search is None:
38
- string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
42
+ if site_constant.TELEGRAM_BOT:
43
+ bot = get_bot_instance()
44
+ string_to_search = bot.ask(
45
+ "key_search",
46
+ f"Enter the search term\nor type 'back' to return to the menu: ",
47
+ None
48
+ )
49
+
50
+ if string_to_search == 'back':
51
+
52
+ # Restart the script
53
+ subprocess.Popen([sys.executable] + sys.argv)
54
+ 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
59
+
60
+ def process_search_result(select_title):
61
+ """
62
+ Handles the search result and initiates the download for either a film or series.
63
+ """
64
+ if select_title.type == 'tv':
65
+ download_series(select_title)
66
+ else:
67
+ download_film(select_title)
68
+
69
+ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None):
70
+ """
71
+ Main function of the application for search film, series and anime.
39
72
 
73
+ Parameters:
74
+ string_to_search (str, optional): String to search for
75
+ get_onylDatabase (bool, optional): If True, return only the database object
76
+ direct_item (dict, optional): Direct item to process (bypass search)
77
+ """
78
+ if direct_item:
79
+ select_title = MediaItem(**direct_item)
80
+ process_search_result(select_title)
81
+ return
82
+
83
+ # Get the user input for the search term
84
+ string_to_search = get_user_input(string_to_search)
85
+
86
+ # Perform the database search
40
87
  len_database = title_search(quote_plus(string_to_search))
41
88
 
42
- # Return list of elements
43
- if get_onylDatabase:
89
+ # If only the database is needed, return the manager
90
+ if get_onlyDatabase:
44
91
  return media_search_manager
45
92
 
93
+ if site_constant.TELEGRAM_BOT:
94
+ bot = get_bot_instance()
95
+
46
96
  if len_database > 0:
47
-
48
- # Select title from list
49
97
  select_title = get_select_title(table_show_manager, media_search_manager)
50
-
51
- if select_title.type == 'tv':
52
- download_series(select_title)
53
-
54
- else:
55
- download_film(select_title)
98
+ process_search_result(select_title)
56
99
 
57
100
  else:
58
101
  console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
59
102
 
60
- # Retry
103
+ if site_constant.TELEGRAM_BOT:
104
+ bot.send_message(f"No results found, please try again", None)
105
+
106
+ # If no results are found, ask again
107
+ string_to_search = get_user_input()
61
108
  search()
@@ -1,4 +1,4 @@
1
- # 3.12.23
1
+ # 16.03.25
2
2
 
3
3
  import os
4
4
 
@@ -15,6 +15,7 @@ from StreamingCommunity.Util.message import start_message
15
15
  from StreamingCommunity.Util.headers import get_headers
16
16
  from StreamingCommunity.Util.config_json import config_manager
17
17
  from StreamingCommunity.Lib.Downloader import HLS_Downloader
18
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession
18
19
 
19
20
 
20
21
  # Logic class
@@ -41,6 +42,19 @@ def download_film(select_title: MediaItem) -> str:
41
42
  Return:
42
43
  - str: output path if successful, otherwise None
43
44
  """
45
+
46
+ if site_constant.TELEGRAM_BOT:
47
+ bot = get_bot_instance()
48
+ bot.send_message(f"Download in corso:\n{select_title.name}", None)
49
+
50
+ # Viene usato per lo screen
51
+ console.print(f"## Download: [red]{select_title.name} ##")
52
+
53
+ # Get script_id
54
+ script_id = TelegramSession.get_session()
55
+ if script_id != "unknown":
56
+ TelegramSession.updateScriptId(script_id, select_title.name)
57
+
44
58
  start_message()
45
59
  console.print(f"[yellow]Download: [red]{select_title.name} \n")
46
60
 
@@ -51,6 +65,9 @@ def download_film(select_title: MediaItem) -> str:
51
65
 
52
66
  except Exception as e:
53
67
  console.print(f"[red]Error fetching the page: {e}")
68
+
69
+ if site_constant.TELEGRAM_BOT:
70
+ bot.send_message(f"ERRORE\n\nErrore durante il recupero della pagina.\n\n{e}", None)
54
71
  return None
55
72
 
56
73
  # Create mostraguarda url
@@ -59,6 +76,8 @@ def download_film(select_title: MediaItem) -> str:
59
76
  url_mostraGuarda = iframe_tag[0].get('data-src')
60
77
  if not url_mostraGuarda:
61
78
  console.print("Error: data-src attribute not found in iframe.")
79
+ if site_constant.TELEGRAM_BOT:
80
+ bot.send_message(f"ERRORE\n\nErrore: attributo data-src non trovato nell'iframe", None)
62
81
 
63
82
  # Extract supervideo URL
64
83
  try:
@@ -67,6 +86,10 @@ def download_film(select_title: MediaItem) -> str:
67
86
 
68
87
  except Exception as e:
69
88
  console.print(f"[red]Error fetching mostraguarda link: {e}")
89
+ console.print("[yellow]Missing access credentials. This part of the code is still under development.")
90
+ if site_constant.TELEGRAM_BOT:
91
+ bot.send_message(f"ERRORE\n\nErrore durante il recupero del link mostra/guarda.\n\n{e}", None)
92
+ bot.send_message(f"ERRORE\n\nCredenziali di accesso mancanti.\nQuesta parte del codice è ancora in fase di sviluppo.", None)
70
93
  return None
71
94
 
72
95
  # Create supervio URL
@@ -91,6 +114,13 @@ def download_film(select_title: MediaItem) -> str:
91
114
  output_path=os.path.join(mp4_path, title_name)
92
115
  ).start()
93
116
 
117
+ if site_constant.TELEGRAM_BOT:
118
+
119
+ # Delete script_id
120
+ script_id = TelegramSession.get_session()
121
+ if script_id != "unknown":
122
+ TelegramSession.deleteScriptId(script_id)
123
+
94
124
  if r_proc['error'] is not None:
95
125
  try: os.remove(r_proc['path'])
96
126
  except: pass
@@ -1,4 +1,4 @@
1
- # 3.12.23
1
+ # 16.03.25
2
2
 
3
3
  import os
4
4
  from typing import Tuple
@@ -12,6 +12,8 @@ from rich.prompt import Prompt
12
12
  # Internal utilities
13
13
  from StreamingCommunity.Util.message import start_message
14
14
  from StreamingCommunity.Lib.Downloader import HLS_Downloader
15
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance, TelegramSession
16
+
15
17
 
16
18
  # Logic class
17
19
  from .util.ScrapeSerie import GetSerieInfo
@@ -56,9 +58,23 @@ def download_video(index_season_selected: int, index_episode_selected: int, scra
56
58
  console.print(f"[yellow]Download: [red]{index_season_selected}:{index_episode_selected} {obj_episode.name}")
57
59
  print()
58
60
 
61
+ if site_constant.TELEGRAM_BOT:
62
+ bot = get_bot_instance()
63
+
64
+ # Invio a telegram
65
+ bot.send_message(
66
+ f"Download in corso\nSerie: {scrape_serie.series_name}\nStagione: {index_season_selected}\nEpisodio: {index_episode_selected}\nTitolo: {obj_episode.name}",
67
+ None
68
+ )
69
+
70
+ # Get script_id and update it
71
+ script_id = TelegramSession.get_session()
72
+ if script_id != "unknown":
73
+ TelegramSession.updateScriptId(script_id, f"{scrape_serie.series_name} - S{index_season_selected} - E{index_episode_selected} - {obj_episode.name}")
74
+
59
75
  # Define filename and path for the downloaded video
60
- mp4_name = f"{map_episode_title(scrape_serie.serie_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
61
- mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.serie_name, f"S{index_season_selected}")
76
+ mp4_name = f"{map_episode_title(scrape_serie.series_name, index_season_selected, index_episode_selected, obj_episode.name)}.mp4"
77
+ mp4_path = os.path.join(site_constant.SERIES_FOLDER, scrape_serie.series_name, f"S{index_season_selected}")
62
78
 
63
79
  # Retrieve scws and if available master playlist
64
80
  video_source = VideoSource(obj_episode.url)
@@ -127,6 +143,9 @@ def download_series(select_season: MediaItem) -> None:
127
143
  Parameters:
128
144
  - select_season (MediaItem): Selected media item (TV series).
129
145
  """
146
+ if site_constant.TELEGRAM_BOT:
147
+ bot = get_bot_instance()
148
+
130
149
  start_message()
131
150
 
132
151
  # Init class
@@ -138,10 +157,28 @@ def download_series(select_season: MediaItem) -> None:
138
157
 
139
158
  # Prompt user for season selection and download episodes
140
159
  console.print(f"\n[green]Seasons found: [red]{seasons_count}")
141
- index_season_selected = msg.ask(
142
- "\n[cyan]Insert season number [yellow](e.g., 1), [red]* [cyan]to download all seasons, "
143
- "[yellow](e.g., 1-2) [cyan]for a range of seasons, or [yellow](e.g., 3-*) [cyan]to download from a specific season to the end"
144
- )
160
+
161
+ if site_constant.TELEGRAM_BOT:
162
+ console.print("\n[cyan]Insert season number [yellow](e.g., 1), [red]* [cyan]to download all seasons, "
163
+ "[yellow](e.g., 1-2) [cyan]for a range of seasons, or [yellow](e.g., 3-*) [cyan]to download from a specific season to the end")
164
+
165
+ bot.send_message(f"Stagioni trovate: {seasons_count}", None)
166
+
167
+ index_season_selected = bot.ask(
168
+ "select_title_episode",
169
+ "Menu di selezione delle stagioni\n\n"
170
+ "- Inserisci il numero della stagione (ad esempio, 1)\n"
171
+ "- Inserisci * per scaricare tutte le stagioni\n"
172
+ "- Inserisci un intervallo di stagioni (ad esempio, 1-2) per scaricare da una stagione all'altra\n"
173
+ "- Inserisci (ad esempio, 3-*) per scaricare dalla stagione specificata fino alla fine della serie",
174
+ None
175
+ )
176
+
177
+ else:
178
+ index_season_selected = msg.ask(
179
+ "\n[cyan]Insert season number [yellow](e.g., 1), [red]* [cyan]to download all seasons, "
180
+ "[yellow](e.g., 1-2) [cyan]for a range of seasons, or [yellow](e.g., 3-*) [cyan]to download from a specific season to the end"
181
+ )
145
182
 
146
183
  # Manage and validate the selection
147
184
  list_season_select = manage_selection(index_season_selected, seasons_count)
@@ -161,4 +198,12 @@ def download_series(select_season: MediaItem) -> None:
161
198
  else:
162
199
 
163
200
  # Otherwise, let the user select specific episodes for the single season
164
- download_episode(i_season, scrape_serie, download_all=False)
201
+ download_episode(i_season, scrape_serie, download_all=False)
202
+
203
+ if site_constant.TELEGRAM_BOT:
204
+ bot.send_message(f"Finito di scaricare tutte le serie e episodi", None)
205
+
206
+ # Get script_id
207
+ script_id = TelegramSession.get_session()
208
+ if script_id != "unknown":
209
+ TelegramSession.deleteScriptId(script_id)
@@ -1,4 +1,4 @@
1
- # 10.12.23
1
+ # 16.03.25
2
2
 
3
3
 
4
4
  # External libraries
@@ -11,6 +11,7 @@ from rich.console import Console
11
11
  from StreamingCommunity.Util.config_json import config_manager
12
12
  from StreamingCommunity.Util.headers import get_userAgent
13
13
  from StreamingCommunity.Util.table import TVShowManager
14
+ from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
14
15
 
15
16
 
16
17
  # Logic class
@@ -35,6 +36,9 @@ def title_search(title_search: str) -> int:
35
36
  Returns:
36
37
  int: The number of titles found.
37
38
  """
39
+ if site_constant.TELEGRAM_BOT:
40
+ bot = get_bot_instance()
41
+
38
42
  media_search_manager.clear()
39
43
  table_show_manager.clear()
40
44
 
@@ -47,14 +51,20 @@ def title_search(title_search: str) -> int:
47
51
 
48
52
  except Exception as e:
49
53
  console.print(f"Site: {site_constant.SITE_NAME}, request search error: {e}")
54
+ if site_constant.TELEGRAM_BOT:
55
+ bot.send_message(f"ERRORE\n\nErrore nella richiesta di ricerca:\n\n{e}", None)
50
56
  return 0
51
-
57
+
58
+ # Prepara le scelte per l'utente
59
+ if site_constant.TELEGRAM_BOT:
60
+ choices = []
61
+
52
62
  # Create soup istance
53
63
  soup = BeautifulSoup(response.text, "html.parser")
54
64
 
55
65
  # Collect data from soup
56
- for movie_div in soup.find_all("div", class_="movie"):
57
-
66
+ for i, movie_div in enumerate(soup.find_all("div", class_="movie")):
67
+
58
68
  title_tag = movie_div.find("h2", class_="movie-title")
59
69
  title = title_tag.find("a").get_text(strip=True)
60
70
  url = title_tag.find("a").get("href")
@@ -70,6 +80,14 @@ def title_search(title_search: str) -> int:
70
80
  'name': title,
71
81
  'type': tipo
72
82
  })
83
+
84
+ if site_constant.TELEGRAM_BOT:
85
+ choice_text = f"{i} - {title} ({tipo})"
86
+ choices.append(choice_text)
87
+
88
+ if site_constant.TELEGRAM_BOT:
89
+ if choices:
90
+ bot.send_message(f"Lista dei risultati:", choices)
73
91
 
74
92
  # Return the number of titles found
75
93
  return media_search_manager.get_length()
@@ -1,4 +1,4 @@
1
- # 01.03.24
1
+ # 16.03.25
2
2
 
3
3
  # External libraries
4
4
  import httpx
@@ -34,7 +34,7 @@ class GetSerieInfo:
34
34
  """
35
35
  response = httpx.get(self.url, headers=self.headers)
36
36
  soup = BeautifulSoup(response.text, "html.parser")
37
- self.serie_name = soup.find("title").get_text(strip=True).split(" - ")[0]
37
+ self.series_name = soup.find("title").get_text(strip=True).split(" - ")[0]
38
38
 
39
39
  # Process all seasons
40
40
  season_items = soup.find_all('div', class_='accordion-item')
@@ -11,11 +11,12 @@ from rich.prompt import Prompt
11
11
 
12
12
  # Internal utilities
13
13
  from StreamingCommunity.Api.Template import get_select_title
14
+ from StreamingCommunity.Api.Template.config_loader import site_constant
15
+ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
14
16
  from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
15
17
 
16
18
 
17
19
  # Logic class
18
- from StreamingCommunity.Api.Template.config_loader import site_constant
19
20
  from .site import title_search, media_search_manager, table_show_manager
20
21
  from .film_serie import download_film, download_series
21
22
 
@@ -31,53 +32,73 @@ msg = Prompt()
31
32
  console = Console()
32
33
 
33
34
 
34
- def search(string_to_search: str = None, get_onylDatabase: bool = False):
35
-
36
- if site_constant.TELEGRAM_BOT:
37
- bot = get_bot_instance()
38
-
39
- if string_to_search is None:
40
-
41
- # Chiedi la scelta all'utente con il bot Telegram
35
+ def get_user_input(string_to_search: str = None):
36
+ """
37
+ Asks the user to input a search term.
38
+ Handles both Telegram bot input and direct input.
39
+ """
40
+ if string_to_search is None:
41
+ if site_constant.TELEGRAM_BOT:
42
+ bot = get_bot_instance()
42
43
  string_to_search = bot.ask(
43
44
  "key_search",
44
- f"Inserisci la parola da cercare\noppure back per tornare alla scelta: ",
45
+ f"Enter the search term\nor type 'back' to return to the menu: ",
45
46
  None
46
47
  )
47
48
 
48
49
  if string_to_search == 'back':
49
- # Riavvia lo script
50
- # Chiude il processo attuale e avvia una nuova istanza dello script
50
+
51
+ # Restart the script
51
52
  subprocess.Popen([sys.executable] + sys.argv)
52
53
  sys.exit()
53
-
54
- else:
55
- if string_to_search is None:
56
- string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
57
-
58
- # Search on database
54
+ else:
55
+ string_to_search = msg.ask(f"\n[purple]Insert a word to search in [green]{site_constant.SITE_NAME}").strip()
56
+
57
+ return string_to_search
58
+
59
+ def process_search_result(select_title):
60
+ """
61
+ Handles the search result and initiates the download for either a film or series.
62
+ """
63
+ download_series(select_title)
64
+
65
+ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None):
66
+ """
67
+ Main function of the application for search film, series and anime.
68
+
69
+ Parameters:
70
+ string_to_search (str, optional): String to search for
71
+ get_onlyDatabase (bool, optional): If True, return only the database object
72
+ direct_item (dict, optional): Direct item to process (bypass search)
73
+ """
74
+ if direct_item:
75
+ select_title = MediaItem(**direct_item)
76
+ process_search_result(select_title)
77
+ return
78
+
79
+ # Get the user input for the search term
80
+ string_to_search = get_user_input(string_to_search)
81
+
82
+ # Perform the database search
59
83
  len_database = title_search(string_to_search)
60
84
 
61
- # Return list of elements
62
- if get_onylDatabase:
85
+ ##If only the database is needed, return the manager
86
+ if get_onlyDatabase:
63
87
  return media_search_manager
88
+
89
+ if site_constant.TELEGRAM_BOT:
90
+ bot = get_bot_instance()
64
91
 
65
92
  if len_database > 0:
66
-
67
- # Select title from list (type: TV \ Movie \ OVA)
68
93
  select_title = get_select_title(table_show_manager, media_search_manager)
94
+ process_search_result(select_title)
69
95
 
70
- if select_title.type == 'Movie' or select_title.type == 'OVA':
71
- download_film(select_title)
72
-
73
- else:
74
- download_series(select_title)
75
-
76
96
  else:
77
- if site_constant.TELEGRAM_BOT:
78
- bot.send_message(f"Nessun risultato trovato riprova", None)
79
-
80
97
  console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
81
98
 
82
- # Retry
99
+ if site_constant.TELEGRAM_BOT:
100
+ bot.send_message(f"No results found, please try again", None)
101
+
102
+ # If no results are found, ask again
103
+ string_to_search = get_user_input()
83
104
  search()
@@ -123,7 +123,11 @@ def download_series(select_title: MediaItem):
123
123
 
124
124
  last_command = bot.ask(
125
125
  "select_title",
126
- f"Inserisci l'indice del media o * per scaricare tutti i media, oppure 1-2 o 3-* per un intervallo di media.",
126
+ "Menu di selezione degli episodi: \n\n"
127
+ "- Inserisci il numero dell'episodio (ad esempio, 1)\n"
128
+ "- Inserisci * per scaricare tutti gli episodi\n"
129
+ "- Inserisci un intervallo di episodi (ad esempio, 1-2) per scaricare da un episodio all'altro\n"
130
+ "- Inserisci (ad esempio, 3-*) per scaricare dall'episodio specificato fino alla fine della serie",
127
131
  None
128
132
  )
129
133
 
@@ -77,10 +77,8 @@ def get_real_title(record):
77
77
  """
78
78
  if record['title_eng'] is not None:
79
79
  return record['title_eng']
80
-
81
80
  elif record['title'] is not None:
82
81
  return record['title']
83
-
84
82
  else:
85
83
  return record['title_it']
86
84
 
@@ -10,10 +10,11 @@ from rich.prompt import Prompt
10
10
 
11
11
  # Internal utilities
12
12
  from StreamingCommunity.Api.Template import get_select_title
13
+ from StreamingCommunity.Api.Template.config_loader import site_constant
14
+ from StreamingCommunity.Api.Template.Class.SearchType import MediaItem
13
15
 
14
16
 
15
17
  # Logic class
16
- from StreamingCommunity.Api.Template.config_loader import site_constant
17
18
  from .site import title_search, media_search_manager, table_show_manager
18
19
  from .film import download_film
19
20
 
@@ -29,10 +30,26 @@ msg = Prompt()
29
30
  console = Console()
30
31
 
31
32
 
32
- def search(string_to_search: str = None, get_onylDatabase: bool = False):
33
+ def process_search_result(select_title):
34
+ """
35
+ Handles the search result and initiates the download for either a film or series.
36
+ """
37
+ # !!! ADD TYPE DONT WORK FOR SERIE
38
+ download_film(select_title)
39
+
40
+ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_item: dict = None):
33
41
  """
34
- Main function of the application for film and series.
42
+ Main function of the application for search film, series and anime.
43
+
44
+ Parameters:
45
+ string_to_search (str, optional): String to search for
46
+ get_onylDatabase (bool, optional): If True, return only the database object
47
+ direct_item (dict, optional): Direct item to process (bypass search)
35
48
  """
49
+ if direct_item:
50
+ select_title = MediaItem(**direct_item)
51
+ process_search_result(select_title)
52
+ return
36
53
 
37
54
  if string_to_search is None:
38
55
  string_to_search = msg.ask(f"\n[purple]Insert word to search in [green]{site_constant.SITE_NAME}").strip()
@@ -40,21 +57,16 @@ def search(string_to_search: str = None, get_onylDatabase: bool = False):
40
57
  # Search on database
41
58
  len_database = title_search(quote_plus(string_to_search))
42
59
 
43
- # Return list of elements
44
- if get_onylDatabase:
60
+ ## If only the database is needed, return the manager
61
+ if get_onlyDatabase:
45
62
  return media_search_manager
46
63
 
47
64
  if len_database > 0:
48
-
49
- # Select title from list
50
65
  select_title = get_select_title(table_show_manager, media_search_manager)
51
-
52
- # !!! ADD TYPE DONT WORK FOR SERIE
53
- download_film(select_title)
54
-
55
-
66
+ process_search_result(select_title)
67
+
56
68
  else:
57
- console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
58
69
 
59
- # Retry
70
+ # If no results are found, ask again
71
+ console.print(f"\n[red]Nothing matching was found for[white]: [purple]{string_to_search}")
60
72
  search()