-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_watching.bat
More file actions
122 lines (107 loc) · 3.53 KB
/
start_watching.bat
File metadata and controls
122 lines (107 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
@echo off
setlocal enabledelayedexpansion
REM === Navigate to the script directory ===
cd /d "%~dp0SerienJunkie"
echo Starting Binge Watching...
REM === Required Python modules ===
set modules=selenium configparser
REM === Check Python installation ===
python --version >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo [X] Python is not installed or not added to PATH.
pause
exit /b 1
)
REM === Check and install missing modules ===
set "missing_modules="
for %%m in (%modules%) do (
python -c "import %%m" >nul 2>&1
if !ERRORLEVEL! NEQ 0 (
echo [-] Missing Python module: %%m
set "missing_modules=!missing_modules! %%m"
) else (
echo [+] Python module '%%m' already installed.
)
)
if not "!missing_modules!"=="" (
echo Installing missing modules:!missing_modules!
python -m pip install --upgrade pip >nul 2>&1
python -m pip install !missing_modules!
if !ERRORLEVEL! NEQ 0 (
echo [X] Failed to install modules. Please install manually.
pause
exit /b 1
)
) else (
echo [=] All dependencies satisfied.
)
REM === Check Tor setting from settings.json ===
set "USE_TOR=false"
for /f "usebackq delims=" %%a in (`powershell -NoProfile -Command "try { $json = Get-Content -Raw 'settings.json' | ConvertFrom-Json; $value = $json.useTorProxy; if ($value -is [string]) { $value = $value.Trim().ToLower() -eq 'true' } else { $value = [bool]$value }; if ($value) { 'true' } else { 'false' } } catch { 'false' }"`) do (
set "USE_TOR=%%a"
goto :tor_setting_done
)
:tor_setting_done
if /i "%USE_TOR%"=="true" (
echo [i] Tor DNS enabled in settings.json - starting Tor...
REM === Start Tor process (hidden window) ===
set TOR_PATH=%~dp0SerienJunkie\Browser\TorBrowser\Tor\tor.exe
REM Check if Tor is already running (Port 9050 in use)
netstat -an | find "9050" >nul
if %ERRORLEVEL% EQU 0 (
echo [?] Tor seems to be running already. Trying to Kill and restart the process...
taskkill /IM tor.exe /F >nul 2>&1
REM Wait until port 9050 is truly free
set /a waitcount=0
:waittorclose
timeout /t 1 >nul
netstat -an | find "9050" >nul
if %ERRORLEVEL% EQU 0 (
set /a waitcount+=1
if !waitcount! LSS 55 goto waittorclose
echo [X] Port 9050 did not become available after kill. Aborted execution.
pause
exit /b 1
)
)
REM Start Tor now
start "" /b "%TOR_PATH%" >nul 2>&1
REM Wait until port 9050 is open (Tor has started)
set /a waitcount=0
:waittorstart
timeout /t 1 >nul
netstat -an | find "9050" >nul
if %ERRORLEVEL% NEQ 0 (
set /a waitcount+=1
if !waitcount! LSS 30 goto waittorstart
echo [X] port 9050 was not opened!
pause
exit /b 1
)
echo [+] Tor started successfully.
)
REM === Start Python Script ===
set BW_DEBUG=1
python s.toBot.py
set EXITCODE=%ERRORLEVEL%
REM Immer pausieren, damit du die letzte Zeile siehst
echo.
echo [i] Python exit code: %EXITCODE%
pause
REM === Cleanup and exit depending on Python exit code ===
if %EXITCODE% EQU 0 (
echo [=] BingeWatcher exited normally.
if "%USE_TOR%"=="true" (
echo [i] Cleaning up Tor process...
taskkill /IM tor.exe /F >nul 2>&1
)
endlocal & exit /b 0
) else (
echo [X] BingeWatcher exited with code %EXITCODE%.
pause
if "%USE_TOR%"=="true" (
echo [i] Cleaning up Tor process...
taskkill /IM tor.exe /F >nul 2>&1
)
endlocal & exit /b %EXITCODE%
)