mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-05 02:55:25 +00:00
Final destination fix vixcloud
This commit is contained in:
parent
b467906432
commit
d093cdc750
@ -136,5 +136,8 @@ class JavaScriptParser:
|
||||
else:
|
||||
result[var_name] = cls.parse_value(value)
|
||||
|
||||
can_play_fhd_match = re.search(r'window\.canPlayFHD\s*=\s*(\w+);?', js_string)
|
||||
if can_play_fhd_match:
|
||||
result['canPlayFHD'] = cls.parse_value(can_play_fhd_match.group(1))
|
||||
|
||||
return result
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import sys
|
||||
import logging
|
||||
from urllib.parse import urlparse, urlencode, urlunparse
|
||||
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse
|
||||
|
||||
|
||||
# External libraries
|
||||
@ -89,6 +89,7 @@ class VideoSource:
|
||||
converter = JavaScriptParser.parse(js_string=str(script_text))
|
||||
|
||||
# Create window video, streams and parameter objects
|
||||
self.canPlayFHD = bool(converter.get('canPlayFHD'))
|
||||
self.window_video = WindowVideo(converter.get('video'))
|
||||
self.window_streams = StreamsCollection(converter.get('streams'))
|
||||
self.window_parameter = WindowParameter(converter.get('masterPlaylist'))
|
||||
@ -137,25 +138,36 @@ class VideoSource:
|
||||
def get_playlist(self) -> str:
|
||||
"""
|
||||
Generate authenticated playlist URL.
|
||||
|
||||
|
||||
Returns:
|
||||
str: Fully constructed playlist URL with authentication parameters
|
||||
"""
|
||||
# Initialize parameters dictionary
|
||||
params = {}
|
||||
|
||||
if self.window_video.quality == 1080:
|
||||
# Add 'h' parameter if video quality is 1080p
|
||||
if self.canPlayFHD:
|
||||
params['h'] = 1
|
||||
|
||||
if "b=1" in self.window_parameter.url:
|
||||
# Parse the original URL
|
||||
parsed_url = urlparse(self.window_parameter.url)
|
||||
query_params = parse_qs(parsed_url.query)
|
||||
|
||||
# Check specifically for 'b=1' in the query parameters
|
||||
if 'b' in query_params and query_params['b'] == ['1']:
|
||||
params['b'] = 1
|
||||
|
||||
# Add authentication parameters (token and expiration)
|
||||
params.update({
|
||||
"token": self.window_parameter.token,
|
||||
"expires": self.window_parameter.expires
|
||||
})
|
||||
|
||||
# Build the updated query string
|
||||
query_string = urlencode(params)
|
||||
return urlunparse(urlparse(self.window_parameter.url)._replace(query=query_string))
|
||||
|
||||
# Construct the new URL with updated query parameters
|
||||
return urlunparse(parsed_url._replace(query=query_string))
|
||||
|
||||
|
||||
class VideoSourceAnime(VideoSource):
|
||||
|
@ -6,7 +6,7 @@ sys.path.append(src_path)
|
||||
|
||||
|
||||
# Import
|
||||
from urllib.parse import urlparse, urlencode, urlunparse
|
||||
import json
|
||||
from StreamingCommunity.Src.Api.Player.Helper.Vixcloud.js_parser import JavaScriptParser
|
||||
from StreamingCommunity.Src.Api.Player.Helper.Vixcloud.util import WindowVideo, WindowParameter, StreamsCollection
|
||||
|
||||
@ -28,11 +28,13 @@ script_text = '''
|
||||
|
||||
# Test
|
||||
converter = JavaScriptParser.parse(js_string=str(script_text))
|
||||
json_string = json.dumps(converter, indent=2)
|
||||
print("Converted json: ", json_string, "\n")
|
||||
|
||||
window_video = WindowVideo(converter.get('video'))
|
||||
window_streams = StreamsCollection(converter.get('streams'))
|
||||
window_parameter = WindowParameter(converter.get('masterPlaylist'))
|
||||
|
||||
print(window_video, "\n")
|
||||
print(window_streams, "\n")
|
||||
print(window_parameter, "\n")
|
||||
print(window_video)
|
||||
print(window_streams)
|
||||
print(window_parameter)
|
200
unix_install.sh
Normal file
200
unix_install.sh
Normal file
@ -0,0 +1,200 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Function to check if a command exists
|
||||
command_exists() {
|
||||
command -v "$1" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Install on Debian/Ubuntu-based systems
|
||||
install_on_debian() {
|
||||
echo "Installing $1..."
|
||||
sudo apt update
|
||||
sudo apt install -y "$1"
|
||||
}
|
||||
|
||||
# Install on Red Hat/CentOS/Fedora-based systems
|
||||
install_on_redhat() {
|
||||
echo "Installing $1..."
|
||||
sudo yum install -y "$1"
|
||||
}
|
||||
|
||||
# Install on Arch-based systems
|
||||
install_on_arch() {
|
||||
echo "Installing $1..."
|
||||
sudo pacman -Sy --noconfirm "$1"
|
||||
}
|
||||
|
||||
# Install on BSD-based systems
|
||||
install_on_bsd() {
|
||||
echo "Installing $1..."
|
||||
env ASSUME_ALWAYS_YES=yes sudo pkg install -y "$1"
|
||||
}
|
||||
|
||||
# Install on macOS
|
||||
install_on_macos() {
|
||||
echo "Installing $1..."
|
||||
if command_exists brew; then
|
||||
brew install "$1"
|
||||
else
|
||||
echo "Homebrew is not installed. Installing Homebrew first..."
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
brew install "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
# Check and install Python3
|
||||
# if command_exists python3 > /dev/null 2>&1; then
|
||||
# echo "Checking Python..."
|
||||
# else
|
||||
# # Detect the platform and install Python3 accordingly
|
||||
# if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||
# # Detect the package manager
|
||||
# if command_exists apt; then
|
||||
# install_on_debian "python3"
|
||||
# elif command_exists yum; then
|
||||
# install_on_redhat "python3"
|
||||
# elif command_exists pacman; then
|
||||
# install_on_arch "python-pip"
|
||||
# else
|
||||
# echo "Unsupported Linux distribution."
|
||||
# exit 1
|
||||
# fi
|
||||
# elif [[ "$OSTYPE" == "bsd"* ]]; then
|
||||
# echo "Detected BSD-based system."
|
||||
# install_on_bsd "python39"
|
||||
# elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# install_on_macos "python"
|
||||
# else
|
||||
# echo "Unsupported operating system."
|
||||
# exit 1
|
||||
# fi
|
||||
# fi
|
||||
|
||||
# Get the Python version
|
||||
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
|
||||
|
||||
# Compare the Python version with 3.8
|
||||
REQUIRED_VERSION="3.8"
|
||||
|
||||
if [ "$(echo -e "$PYTHON_VERSION\n$REQUIRED_VERSION" | sort -V | head -n1)" = "$REQUIRED_VERSION" ]; then
|
||||
echo "Python version $PYTHON_VERSION is >= $REQUIRED_VERSION. Continuing..."
|
||||
else
|
||||
echo "ERROR: Python version $PYTHON_VERSION is < $REQUIRED_VERSION. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -d ".venv/" ]; then
|
||||
echo ".venv exists. Installing requirements.txt..."
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
else
|
||||
echo "Making .venv and installing requirements.txt..."
|
||||
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
# Detect the package manager for venv installation check.
|
||||
if command_exists apt; then
|
||||
echo "Detected Debian-based system. Checking python3-venv."
|
||||
if dpkg -l | grep -q "python3-venv"; then
|
||||
echo "python3-venv found."
|
||||
else
|
||||
echo "python3-venv not found, installing..."
|
||||
install_on_debian "python3-venv"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
python3 -m venv .venv
|
||||
.venv/bin/pip install -r requirements.txt
|
||||
|
||||
fi
|
||||
|
||||
if command_exists ffmpeg; then
|
||||
echo "ffmpeg exists."
|
||||
else
|
||||
echo "ffmpeg does not exist."
|
||||
|
||||
# Detect the platform and install ffmpeg accordingly.
|
||||
case "$(uname)" in
|
||||
Linux)
|
||||
if command_exists apt; then
|
||||
echo "Detected Debian-based system."
|
||||
install_on_debian "ffmpeg"
|
||||
elif command_exists yum; then
|
||||
echo "Detected Red Hat-based system."
|
||||
echo "Installing needed repos for ffmpeg..."
|
||||
sudo yum config-manager --set-enabled crb > /dev/null 2>&1 || true
|
||||
sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$(rpm -E %rhel).noarch.rpm https://dl.fedoraproject.org/pub/epel/epel-next-release-latest-$(rpm -E %rhel).noarch.rpm > /dev/null 2>&1 || true
|
||||
sudo yum install -y --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm > /dev/null 2>&1 || true
|
||||
install_on_redhat "ffmpeg"
|
||||
elif command_exists pacman; then
|
||||
echo "Detected Arch-based system."
|
||||
install_on_arch "ffmpeg"
|
||||
else
|
||||
echo "Unsupported Linux distribution."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
FreeBSD|NetBSD|OpenBSD)
|
||||
echo "Detected BSD-based system."
|
||||
install_on_bsd "ffmpeg"
|
||||
;;
|
||||
Darwin)
|
||||
echo "Detected macOS."
|
||||
install_on_macos "ffmpeg"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if command_exists openssl || .venv/bin/pip list | grep -q pycryptodome; then
|
||||
echo "openssl or pycryptodome exists."
|
||||
else
|
||||
echo "Please choose an option:"
|
||||
echo "1) openssl"
|
||||
echo "2) pycryptodome"
|
||||
read -p "Enter your choice (1): " choice
|
||||
|
||||
case "$choice" in
|
||||
2)
|
||||
echo "Installing pycryptodome."
|
||||
.venv/bin/pip install pycryptodome
|
||||
;;
|
||||
*)
|
||||
# Detect the platform and install OpenSSL accordingly.
|
||||
case "$(uname)" in
|
||||
Linux)
|
||||
if command_exists apt; then
|
||||
install_on_debian openssl
|
||||
elif command_exists yum; then
|
||||
install_on_redhat openssl
|
||||
elif command_exists pacman; then
|
||||
install_on_arch openssl
|
||||
else
|
||||
echo "Unsupported Linux distribution."
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
FreeBSD|NetBSD|OpenBSD)
|
||||
install_on_bsd openssl
|
||||
;;
|
||||
Darwin)
|
||||
install_on_macos openssl
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
sed -i.bak '1s|.*|#!.venv/bin/python3|' run.py
|
||||
sudo chmod +x run.py
|
||||
echo 'Everything is installed!'
|
||||
echo 'Run StreamingCommunity with "./run.py"'
|
134
win_install.bat
Normal file
134
win_install.bat
Normal file
@ -0,0 +1,134 @@
|
||||
@echo off
|
||||
:: Check if the script is running as administrator
|
||||
net session >nul 2>&1
|
||||
if %errorlevel% neq 0 (
|
||||
echo Running as administrator...
|
||||
:: Restart the script with administrator privileges
|
||||
powershell -Command "Start-Process '%~f0' -Verb RunAs"
|
||||
exit /b
|
||||
)
|
||||
|
||||
chcp 65001 > nul
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
echo Script starting...
|
||||
|
||||
:: Check if Chocolatey is already installed
|
||||
:check_choco
|
||||
echo Checking if Chocolatey is installed...
|
||||
choco --version >nul 2>&1
|
||||
IF %ERRORLEVEL% EQU 0 (
|
||||
echo Chocolatey is already installed. Skipping installation.
|
||||
goto install_python
|
||||
) ELSE (
|
||||
echo Installing Chocolatey...
|
||||
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" || (
|
||||
echo Error during Chocolatey installation.
|
||||
exit /b 1
|
||||
)
|
||||
echo Chocolatey installed successfully.
|
||||
call choco --version
|
||||
echo.
|
||||
)
|
||||
|
||||
:: Check if Python is already installed
|
||||
:install_python
|
||||
echo Checking if Python is installed...
|
||||
python -V >nul 2>&1
|
||||
IF %ERRORLEVEL% EQU 0 (
|
||||
echo Python is already installed. Skipping installation.
|
||||
goto install_openssl
|
||||
) ELSE (
|
||||
echo Installing Python...
|
||||
choco install python --confirm --params="'/NoStore'" --allow-downgrade || (
|
||||
echo Error during Python installation.
|
||||
exit /b 1
|
||||
)
|
||||
echo Python installed successfully.
|
||||
call python -V
|
||||
echo.
|
||||
)
|
||||
|
||||
:: Ask to restart the terminal
|
||||
echo Please restart the terminal to continue...
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:: Check if OpenSSL is already installed
|
||||
:install_openssl
|
||||
echo Checking if OpenSSL is installed...
|
||||
openssl version -a >nul 2>&1
|
||||
IF %ERRORLEVEL% EQU 0 (
|
||||
echo OpenSSL is already installed. Skipping installation.
|
||||
goto install_ffmpeg
|
||||
) ELSE (
|
||||
echo Installing OpenSSL...
|
||||
choco install openssl --confirm || (
|
||||
echo Error during OpenSSL installation.
|
||||
exit /b 1
|
||||
)
|
||||
echo OpenSSL installed successfully.
|
||||
call openssl version -a
|
||||
echo.
|
||||
)
|
||||
|
||||
:: Check if FFmpeg is already installed
|
||||
:install_ffmpeg
|
||||
echo Checking if FFmpeg is installed...
|
||||
ffmpeg -version >nul 2>&1
|
||||
IF %ERRORLEVEL% EQU 0 (
|
||||
echo FFmpeg is already installed. Skipping installation.
|
||||
goto create_venv
|
||||
) ELSE (
|
||||
echo Installing FFmpeg...
|
||||
choco install ffmpeg --confirm || (
|
||||
echo Error during FFmpeg installation.
|
||||
exit /b 1
|
||||
)
|
||||
echo FFmpeg installed successfully.
|
||||
call ffmpeg -version
|
||||
echo.
|
||||
)
|
||||
|
||||
:: Verify installations
|
||||
:verifica_installazioni
|
||||
echo Verifying installations...
|
||||
call choco --version
|
||||
call python -V
|
||||
call openssl version -a
|
||||
call ffmpeg -version
|
||||
|
||||
echo All programs have been successfully installed and verified.
|
||||
|
||||
:: Create a virtual environment .venv
|
||||
:create_venv
|
||||
echo Checking if the .venv virtual environment already exists...
|
||||
if exist .venv (
|
||||
echo The .venv virtual environment already exists. Skipping creation.
|
||||
) ELSE (
|
||||
echo Creating the .venv virtual environment...
|
||||
python -m venv .venv || (
|
||||
echo Error during virtual environment creation.
|
||||
exit /b 1
|
||||
)
|
||||
echo Virtual environment created successfully.
|
||||
)
|
||||
|
||||
:: Activate the virtual environment and install requirements
|
||||
echo Installing requirements...
|
||||
call .venv\Scripts\activate.bat
|
||||
pip install -r requirements.txt || (
|
||||
echo Error during requirements installation.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Run run.py
|
||||
echo Running run.py...
|
||||
call .venv\Scripts\python .\run.py || (
|
||||
echo Error during run.py execution.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo End of script.
|
||||
|
||||
ENDLOCAL
|
Loading…
x
Reference in New Issue
Block a user