Skip to content
Merged

Dev #308

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ cmd.txt
bot_config.json
scripts.json
active_requests.json
domains.json
domains.json
working_proxies.json
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -797,13 +797,27 @@ Contributions are welcome! Steps:
4. Push to branch (`git push origin feature/AmazingFeature`)
5. Open Pull Request


# Disclaimer

This software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose, and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

## Useful Project

### 🎯 [Unit3Dup](https://github.com/31December99/Unit3Dup)
Bot in Python per la generazione e l'upload automatico di torrent su tracker basati su Unit3D.


### 🇮🇹 [MammaMia](https://github.com/UrloMythus/MammaMia)
Addon per Stremio che consente lo streaming HTTPS di film, serie, anime e TV in diretta in lingua italiana.

### 🧩 [streamingcommunity-unofficialapi](https://github.com/Blu-Tiger/streamingcommunity-unofficialapi)
API non ufficiale per accedere ai contenuti del sito italiano StreamingCommunity.

### 🎥 [stream-buddy](https://github.com/Bbalduzz/stream-buddy)
Tool per guardare o scaricare film dalla piattaforma StreamingCommunity.

## Contributors

<a href="https://github.com/Arrowar/StreamingCommunity/graphs/contributors" alt="View Contributors">
<img src="https://contrib.rocks/image?repo=Arrowar/StreamingCommunity&max=1000&columns=10" alt="Contributors" />
</a>
</a>
65 changes: 65 additions & 0 deletions StreamingCommunity/Api/Player/hdplayer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# 29.04.25

import re


# External library
import httpx
from bs4 import BeautifulSoup


# Internal utilities
from StreamingCommunity.Util.headers import get_headers
from StreamingCommunity.Util.config_json import config_manager


# Variable
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")


class VideoSource:
def __init__(self, proxy=None):
self.client = httpx.Client(headers=get_headers(), timeout=MAX_TIMEOUT, proxy=proxy)

def extractLinkHdPlayer(self, response):
"""Extract iframe source from the page."""
soup = BeautifulSoup(response.content, 'html.parser')
iframes = soup.find_all("iframe")
if iframes:
return iframes[0].get('data-lazy-src')
return None

def get_m3u8_url(self, page_url):
"""
Extract m3u8 URL from hdPlayer page.
"""
try:
# Get the page content
response = self.client.get(page_url)

# Extract HDPlayer iframe URL
iframe_url = self.extractLinkHdPlayer(response)
if not iframe_url:
return None

# Get HDPlayer page content
response_hdplayer = self.client.get(iframe_url)
if response_hdplayer.status_code != 200:
return None

soup = BeautifulSoup(response_hdplayer.text, 'html.parser')

# Find m3u8 URL in scripts
for script in soup.find_all("script"):
match = re.search(r'sources:\s*\[\{\s*file:\s*"([^"]+)"', script.text)
if match:
return match.group(1)

return None

except Exception as e:
print(f"Error in HDPlayer: {str(e)}")
return None

finally:
self.client.close()
140 changes: 0 additions & 140 deletions StreamingCommunity/Api/Player/maxstream.py

This file was deleted.

145 changes: 145 additions & 0 deletions StreamingCommunity/Api/Player/mixdrop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# 05.07.24

import re
import logging


# External libraries
import httpx
import jsbeautifier
from bs4 import BeautifulSoup


# Internal utilities
from StreamingCommunity.Util.config_json import config_manager
from StreamingCommunity.Util.headers import get_userAgent


# Variable
MAX_TIMEOUT = config_manager.get_int("REQUESTS", "timeout")


class VideoSource:
STAYONLINE_BASE_URL = "https://stayonline.pro"
MIXDROP_BASE_URL = "https://mixdrop.sb"

def __init__(self, url: str):
self.url = url
self.redirect_url: str | None = None
self._init_headers()

def _init_headers(self) -> None:
"""Initialize the base headers used for requests."""
self.headers = {
'origin': self.STAYONLINE_BASE_URL,
'user-agent': get_userAgent(),
}

def _get_mixdrop_headers(self) -> dict:
"""Get headers specifically for MixDrop requests."""
return {
'referer': 'https://mixdrop.club/',
'user-agent': get_userAgent()
}

def get_redirect_url(self) -> str:
"""Extract the stayonline redirect URL from the initial page."""
try:
response = httpx.get(self.url, headers=self.headers, follow_redirects=True, timeout=MAX_TIMEOUT)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")

for link in soup.find_all('a'):
href = link.get('href')
if href and 'stayonline' in href:
self.redirect_url = href
logging.info(f"Redirect URL: {self.redirect_url}")
return self.redirect_url

raise ValueError("Stayonline URL not found")

except Exception as e:
logging.error(f"Error getting redirect URL: {e}")
raise

def get_link_id(self) -> str:
"""Extract the link ID from the redirect page."""
if not self.redirect_url:
raise ValueError("Redirect URL not set. Call get_redirect_url first.")

try:
response = httpx.get(self.redirect_url, headers=self.headers, follow_redirects=True, timeout=MAX_TIMEOUT)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")

for script in soup.find_all('script'):
match = re.search(r'var\s+linkId\s*=\s*"([^"]+)"', script.text)
if match:
return match.group(1)

raise ValueError("LinkId not found")

except Exception as e:
logging.error(f"Error getting link ID: {e}")
raise

def get_final_url(self, link_id: str) -> str:
"""Get the final URL using the link ID."""
try:
self.headers['referer'] = f'{self.STAYONLINE_BASE_URL}/l/{link_id}/'
data = {'id': link_id, 'ref': ''}

response = httpx.post(f'{self.STAYONLINE_BASE_URL}/ajax/linkView.php', headers=self.headers, data=data, timeout=MAX_TIMEOUT)
response.raise_for_status()
return response.json()['data']['value']

except Exception as e:
logging.error(f"Error getting final URL: {e}")
raise

def _extract_video_id(self, final_url: str) -> str:
"""Extract video ID from the final URL."""
parts = final_url.split('/')
if len(parts) < 5:
raise ValueError("Invalid final URL format")
return parts[4]

def _extract_delivery_url(self, script_text: str) -> str:
"""Extract delivery URL from beautified JavaScript."""
beautified = jsbeautifier.beautify(script_text)
for line in beautified.splitlines():
if 'MDCore.wurl' in line:
url = line.split('= ')[1].strip('"').strip(';')
return f"https:{url}"
raise ValueError("Delivery URL not found in script")

def get_playlist(self) -> str:
"""
Execute the entire flow to obtain the final video URL.
Returns:
str: The final video delivery URL
"""
self.get_redirect_url()
link_id = self.get_link_id()

final_url = self.get_final_url(link_id)
video_id = self._extract_video_id(final_url)

response = httpx.get(
f'{self.MIXDROP_BASE_URL}/e/{video_id}',
headers=self._get_mixdrop_headers(),
timeout=MAX_TIMEOUT
)
response.raise_for_status()
soup = BeautifulSoup(response.text, "html.parser")

script_text = next(
(script.text for script in soup.find_all('script')
if "eval" in str(script.text)),
None
)

if not script_text:
raise ValueError("Required script not found")

return self._extract_delivery_url(script_text).replace('"', '')
Loading