Skip to content

Commit 6fdaf8d

Browse files
Merge pull request #4 from jokogendeng77/version/4.1.3
[fix] unused menu
2 parents 6a21149 + 75bdf5b commit 6fdaf8d

8 files changed

+5436
-265
lines changed

SHPBOT-linux.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,24 @@
1-
npm install && node SHPBOT.js
1+
# Check if Git is installed
2+
if ! command -v git &> /dev/null; then
3+
echo "Git is not installed. Attempting to run install-linux.sh again..."
4+
./install-linux.sh
5+
exit 1
6+
fi
7+
8+
# Check if the current version is the same as the git version
9+
git fetch
10+
localRev=$(git rev-parse HEAD)
11+
remoteRev=$(git rev-parse @{u})
12+
13+
echo "Local revision: $localRev"
14+
echo "Remote revision: $remoteRev"
15+
16+
if [ "$localRev" != "$remoteRev" ]; then
17+
echo "Updating to the latest version..."
18+
git stash
19+
git pull
20+
git stash apply
21+
fi
22+
23+
npm install
24+
node SHPBOT.js

SHPBOT-win.bat

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
@echo off
22
cd /d "%~dp0"
3+
4+
REM Check if Git is installed
5+
where git >nul 2>&1
6+
if %errorlevel% neq 0 (
7+
echo Git is not installed. Attempting to run install-win.bat again...
8+
call install-win.bat
9+
exit /b 1
10+
)
11+
12+
REM Check if the current version is the same as the git version
13+
git fetch
14+
set "localRev="
15+
set "remoteRev="
16+
for /f "tokens=*" %%a in ('git rev-parse HEAD') do set localRev=%%a
17+
for /f "tokens=*" %%a in ('git rev-parse @{u}') do set remoteRev=%%a
18+
19+
echo "%localRev%"
20+
echo "%remoteRev%"
21+
22+
if not "%localRev%"=="%remoteRev%" (
23+
echo Updating to the latest version...
24+
git stash
25+
git pull
26+
git stash apply
27+
)
28+
329
call npm install
430
call node SHPBOT
531
pause

SHPBOT.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install-linux.sh

+23-10
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,42 @@ if [[ $EUID -ne 0 ]]; then
66
exit 1
77
fi
88

9-
# Install Node.js if not already installed
9+
echo "=============== SHPxBOT Installer ====================="
10+
11+
# Install Node.js and Python if not already installed
12+
echo "Checking NodeJS and Python installation...."
1013
if ! command -v node &> /dev/null; then
11-
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
12-
sudo apt-get install -y nodejs
14+
echo "NodeJS is not installed. Attempting to install NodeJS and Python..."
15+
sudo apt-get update
16+
sudo apt-get install nodejs python3 -y
17+
sleep 2
1318
else
14-
echo "Node.js is already installed."
19+
echo "Nodejs and Python are already installed."
1520
fi
1621

17-
# Install Volta if not already installed
18-
if ! command -v volta &> /dev/null; then
19-
curl https://get.volta.sh | bash
22+
echo "Checking Git installation...."
23+
# Install Git if not already installed
24+
if ! command -v git &> /dev/null; then
25+
echo "Git is not installed. Attempting to install Git..."
26+
sudo apt-get install git -y
27+
sleep 2
2028
else
21-
echo "Volta is already installed."
29+
echo "Git is already installed."
2230
fi
2331

32+
echo "Checking FFMPEG installation...."
2433
# Install FFmpeg if not already installed
2534
if ! command -v ffmpeg &> /dev/null; then
26-
sudo apt-get update
35+
echo "FFMPEG is not installed. Installing FFMPEG..."
2736
sudo apt-get install ffmpeg -y
37+
sleep 2
2838
else
29-
echo "FFmpeg is already installed."
39+
echo "FFMPEG is already installed."
3040
fi
3141

42+
echo "=============== SHPxBOT Installation Success ====================="
43+
44+
echo "Installing Dependencies & Running BOT...."
3245
# Run npm install
3346
npm install
3447

install-win.bat

+26-12
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,49 @@ if %errorlevel% neq 0 (
1313

1414
echo ================ SHPxBOT Installer =====================
1515

16-
17-
1816
echo Checking chocolatey installation....
1917
REM Check if Chocolatey is installed
2018
where choco >nul 2>&1
2119
if %errorlevel% neq 0 (
22-
echo Chocolatey is not installed. Installing Chocolatey...
20+
echo Chocolatey is not installed. Attempting to install Chocolatey...
2321
@powershell -NoProfile -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
22+
if %errorlevel% neq 0 (
23+
echo Failed to install Chocolatey automatically. Please install Chocolatey manually from https://chocolatey.org/install
24+
)
2425
) else (
2526
echo Chocolatey is already installed.
2627
)
2728

2829
REM Wait for Chocolatey to settle
2930
timeout /t 2 /nobreak >nul
3031

31-
echo Checking NodeJS installation....
32-
REM Install Node.js if not already installed
32+
echo Checking NodeJS, Python, and Visual Studio Build Tools installation....
33+
REM Install Node.js, Python, and Visual Studio Build Tools if not already installed
3334
where node >nul 2>&1
3435
if %errorlevel% neq 0 (
35-
echo NodeJS is not installed. Installing NodeJS...
36-
call :RunCommand start /wait cmd /c "choco install nodejs-lts -y && timeout /t 2 /nobreak >nul"
36+
echo NodeJS is not installed. Attempting to install NodeJS, Python, and Visual Studio Build Tools...
37+
call :RunCommand start /wait cmd /c "choco install nodejs-lts python3 visualstudio2019buildtools -y && timeout /t 2 /nobreak >nul"
38+
if %errorlevel% neq 0 (
39+
echo Failed to install NodeJS, Python, or Visual Studio Build Tools automatically. Please install them manually from https://nodejs.org, https://www.python.org, and https://visualstudio.microsoft.com/downloads/
40+
)
3741
) else (
38-
echo Nodejs is already installed.
42+
echo Nodejs, Python, and Visual Studio Build Tools are already installed.
3943
)
4044

45+
echo Checking Git installation....
46+
REM Install Git if not already installed
47+
where git >nul 2>&1
48+
if %errorlevel% neq 0 (
49+
echo Git is not installed. Attempting to install Git...
50+
call :RunCommand start /wait cmd /c "choco install git -y && timeout /t 2 /nobreak >nul"
51+
if %errorlevel% neq 0 (
52+
echo Failed to install Git automatically. Please install Git manually from https://git-scm.com/download/win
53+
pause
54+
exit /b 1
55+
)
56+
) else (
57+
echo Git is already installed.
58+
)
4159

4260
echo Checking Volta installation....
4361
REM Install Volta if not already installed
@@ -49,7 +67,6 @@ if %errorlevel% neq 0 (
4967
echo Volta is already installed.
5068
)
5169

52-
5370
echo Checking FFMPEG installation....
5471
REM Install FFmpeg if not already installed
5572
where ffmpeg >nul 2>&1
@@ -60,7 +77,6 @@ if %errorlevel% neq 0 (
6077
echo FFMPEG is already installed.
6178
)
6279

63-
6480
REM Get the path of the batch script
6581
set "script_path=%~dp0"
6682

@@ -87,8 +103,6 @@ if not exist ffmpeg.exe (
87103

88104
echo ================ SHPxBOT Installation Success =====================
89105

90-
91-
92106
echo "Installing Dependencies & Running BOT...."
93107
REM Open a new terminal for subsequent commands
94108
where node >nul 2>&1

library/streamer.cjs

+6-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ const videoProcessing = async ({liveUrl, rtmpServer = null, rtmpKey = null, isIn
100100
if (timeMatch) {
101101
currentTime = parseInt(timeMatch[1]) * 3600 + parseInt(timeMatch[2]) * 60 + parseInt(timeMatch[3]);
102102
const progress = (currentTime / totalSeconds * 100).toFixed(2);
103+
if(streamDuration && currentTime >= streamDuration){
104+
ffmpegGlobalProcess.kill('SIGINT');
105+
}
103106
process.stdout.clearLine(0);
104107
process.stdout.cursorTo(0);
105108
process.stdout.write(chalk.green(`Streaming Progress: [${progress}%] | Time Elapsed: ${currentTime} seconds`));
@@ -161,7 +164,8 @@ const reStreamShopee = async ({videoUrl, rtmpServer = null, rtmpKey = null, isIn
161164
mode = "restream";
162165
}
163166
const baseFilePath = `${__dirname}/../stream_output/${streamData?.room_id}-${streamData?.username}`;
164-
167+
168+
console.info(`\nCtrl+C to stop downloading and exit`)
165169
await videoProcessing({liveUrl, rtmpServer, rtmpKey, isInfiniteMode, streamDuration, baseFilePath, mode});
166170

167171
} catch (error) {
@@ -295,8 +299,8 @@ const tiktokDownload = async ({videoUrl, output="stream_output", format="mp4", d
295299
''
296300
)}/${tt_username}-${Date.now()}.${format}`
297301
mkdirSync(path.dirname(fileName), { recursive: true })
298-
await videoProcessing({liveUrl, rtmpServer, rtmpKey, isInfiniteMode, streamDuration: duration, baseFilePath:fileName, mode:"restream"});
299302
console.info(`\nCtrl+C to stop downloading and exit`)
303+
await videoProcessing({liveUrl, rtmpServer, rtmpKey, isInfiniteMode, streamDuration: duration, baseFilePath:fileName, mode:"restream"});
300304
}catch (error) {
301305
reject(error);
302306
}

0 commit comments

Comments
 (0)