Skip to content

Commit 1c89398

Browse files
Arrowarl1n00
andauthored
Fix telegram and proxy (#322)
* Add ENABLE_VIDEO * Fix proxy * Add error proxy * Update config.json * Fix telegram_bot (#312) * Update config.json * Fix telegram_bot * fix bug * Fix StreamingCommunity site * Delete console.log * fix doppio string_to_search * Update __init__.py * Update site.py * Update config.json * Update site.py * Update config.json * Update __init__.py * Update __init__.py * Fix proxy (#319) * Add ENABLE_VIDEO * Fix proxy * Add error proxy * Update config.json * Refactor user input handling and improve messaging in __init__.py --------- Co-authored-by: None <[email protected]> Co-authored-by: l1n00 <> * Fix proxy __init__ * Update os.py --------- Co-authored-by: l1n00 <[email protected]>
1 parent dfcc290 commit 1c89398

File tree

19 files changed

+302
-156
lines changed

19 files changed

+302
-156
lines changed

README.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,24 @@ The `run-container` command mounts also the `config.json` file, so any change to
748748
The bot was created to replace terminal commands and allow interaction via Telegram. Each download runs within a screen session, enabling multiple downloads to run simultaneously.
749749

750750
To run the bot in the background, simply start it inside a screen session and then press Ctrl + A, followed by D, to detach from the session without stopping the bot.
751-
</details>
752-
753-
<details>
754-
<summary>🤖 Bot Commands</summary>
755751

756752
Command Functions:
757753

758754
🔹 /start – Starts a new search for a download. This command performs the same operations as manually running the script in the terminal with test_run.py.
759755

760756
🔹 /list – Displays the status of active downloads, with options to:
761-
- Stop an incorrect download using /stop <ID>
762-
- View the real-time output of a download using /screen <ID>
757+
758+
Stop an incorrect download using /stop <ID>.
759+
760+
View the real-time output of a download using /screen <ID>.
763761

764762
⚠ Warning: If a download is interrupted, incomplete files may remain in the folder specified in config.json. These files must be deleted manually to avoid storage or management issues.
765-
</details>
766763

767-
<details>
768-
<summary>🔧 Environment Setup</summary>
764+
🛠 Configuration: Currently, the bot's settings are stored in the config.json file, which is located in the same directory as the telegram_bot.py script.
765+
766+
## .env Example:
769767

770-
Create an `.env` file with:
768+
You need to create an .env file and enter your Telegram token and user ID to authorize only one user to use it
771769

772770
```
773771
TOKEN_TELEGRAM=IlTuo2131TOKEN$12D3Telegram

StreamingCommunity/Api/Player/vixcloud.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 01.03.24
22

3-
import sys
3+
import time
44
import logging
55
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
66

@@ -24,7 +24,7 @@
2424

2525

2626
class VideoSource:
27-
def __init__(self, url: str, is_series: bool, media_id: int = None):
27+
def __init__(self, url: str, is_series: bool, media_id: int = None, proxy: str = None):
2828
"""
2929
Initialize video source for streaming site.
3030
@@ -35,6 +35,7 @@ def __init__(self, url: str, is_series: bool, media_id: int = None):
3535
"""
3636
self.headers = {'user-agent': get_userAgent()}
3737
self.url = url
38+
self.proxy = proxy
3839
self.is_series = is_series
3940
self.media_id = media_id
4041
self.iframe_src = None
@@ -55,7 +56,7 @@ def get_iframe(self, episode_id: int) -> None:
5556
}
5657

5758
try:
58-
response = httpx.get(f"{self.url}/iframe/{self.media_id}", params=params, timeout=MAX_TIMEOUT)
59+
response = httpx.get(f"{self.url}/iframe/{self.media_id}", headers=self.headers, params=params, timeout=MAX_TIMEOUT, proxy=self.proxy)
5960
response.raise_for_status()
6061

6162
# Parse response with BeautifulSoup to get iframe source
@@ -81,6 +82,7 @@ def parse_script(self, script_text: str) -> None:
8182
self.window_video = WindowVideo(converter.get('video'))
8283
self.window_streams = StreamsCollection(converter.get('streams'))
8384
self.window_parameter = WindowParameter(converter.get('masterPlaylist'))
85+
time.sleep(0.5)
8486

8587
except Exception as e:
8688
logging.error(f"Error parsing script: {e}")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
_useFor = "Torrent"
2525
_priority = 0
2626
_engineDownload = "Torrent"
27-
_deprecate = False
27+
_deprecate = True
2828

2929
console = Console()
3030
msg = Prompt()
@@ -62,7 +62,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
6262
return media_search_manager
6363

6464
if len_database > 0:
65-
select_title = get_select_title(table_show_manager, media_search_manager)
65+
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
6666
download_title(select_title)
6767

6868
else:

StreamingCommunity/Api/Site/altadefinizione/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
110110
bot = get_bot_instance()
111111

112112
if len_database > 0:
113-
select_title = get_select_title(table_show_manager, media_search_manager)
113+
select_title = get_select_title(table_show_manager, media_search_manager, len_database)
114114
process_search_result(select_title, selections)
115115

116116
else:

StreamingCommunity/Api/Site/animeunity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
109109
bot = get_bot_instance()
110110

111111
if len_database > 0:
112-
select_title = get_select_title(table_show_manager, media_search_manager)
112+
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
113113
process_search_result(select_title, selections)
114114

115115
else:

StreamingCommunity/Api/Site/animeunity/util/ScrapeSerie.py

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,40 +43,38 @@ def setup(self, version: str = None, media_id: int = None, series_name: str = No
4343
def get_count_episodes(self):
4444
"""
4545
Retrieve total number of episodes for the selected media.
46+
This includes partial episodes (like episode 6.5).
4647
4748
Returns:
48-
int: Total episode count
49+
int: Total episode count including partial episodes
4950
"""
50-
try:
51-
52-
response = httpx.get(
53-
url=f"{self.url}/info_api/{self.media_id}/",
54-
headers=self.headers,
55-
timeout=max_timeout
56-
)
57-
response.raise_for_status()
58-
59-
# Parse JSON response and return episode count
60-
return response.json()["episodes_count"]
61-
62-
except Exception as e:
63-
logging.error(f"Error fetching episode count: {e}")
64-
return None
51+
if self.episodes_cache is None:
52+
self._fetch_all_episodes()
53+
54+
if self.episodes_cache:
55+
return len(self.episodes_cache)
56+
return None
6557

6658
def _fetch_all_episodes(self):
6759
"""
6860
Fetch all episodes data at once and cache it
6961
"""
7062
try:
71-
all_episodes = []
72-
count = self.get_count_episodes()
73-
if not count:
74-
return
63+
# Get initial episode count
64+
response = httpx.get(
65+
url=f"{self.url}/info_api/{self.media_id}/",
66+
headers=self.headers,
67+
timeout=max_timeout
68+
)
69+
response.raise_for_status()
70+
initial_count = response.json()["episodes_count"]
7571

76-
# Fetch episodes
72+
all_episodes = []
7773
start_range = 1
78-
while start_range <= count:
79-
end_range = min(start_range + 119, count)
74+
75+
# Fetch episodes in chunks
76+
while start_range <= initial_count:
77+
end_range = min(start_range + 119, initial_count)
8078

8179
response = httpx.get(
8280
url=f"{self.url}/info_api/{self.media_id}/1",

StreamingCommunity/Api/Site/animeworld/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
7575
return media_search_manager
7676

7777
if len_database > 0:
78-
select_title = get_select_title(table_show_manager, media_search_manager)
78+
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
7979
process_search_result(select_title, selections)
8080

8181
else:

StreamingCommunity/Api/Site/cb01new/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
6262
return media_search_manager
6363

6464
if len_database > 0:
65-
select_title = get_select_title(table_show_manager, media_search_manager)
65+
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
6666
process_search_result(select_title)
6767

6868
else:

StreamingCommunity/Api/Site/guardaserie/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
7575
return media_search_manager
7676

7777
if len_database > 0:
78-
select_title = get_select_title(table_show_manager, media_search_manager)
78+
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
7979
process_search_result(select_title, selections)
8080

8181
else:

StreamingCommunity/Api/Site/raiplay/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def search(string_to_search: str = None, get_onlyDatabase: bool = False, direct_
8484
return media_search_manager
8585

8686
if len_database > 0:
87-
select_title = get_select_title(table_show_manager, media_search_manager)
87+
select_title = get_select_title(table_show_manager, media_search_manager,len_database)
8888
process_search_result(select_title, selections)
8989

9090
else:

0 commit comments

Comments
 (0)