feat: Refactor and reorganize project structure with new modules and files

- Deleted obsolete files including test scripts and configuration files to streamline the project.
- Introduced new modules for handling Douyin functionalities, including core operations, logging, and GUI components.
- Updated import paths to reflect the new module structure, enhancing code organization and maintainability.
- Added configuration files and documentation to support the new structure and improve user guidance.
This commit is contained in:
Your Name committed 2025-12-28 14:16:40 +08:00
1 parent ea7159355b
commit c67f22f76f
139 files changed
+7571 -7828

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
# 脚本目录
本目录包含项目的所有脚本文件。
## 脚本列表
- **auto_commit_push.bat** - 自动提交和推送(Windows批处理)
- **auto_commit_push.ps1** - 自动提交和推送(PowerShell)
- **setup_auto_commit.bat** - 设置自动提交(Windows批处理)
- **setup_auto_commit.ps1** - 设置自动提交(PowerShell)
- **一键启动WebGUI.bat** - 一键启动Web GUI
- **停止WebGUI服务.bat** - 停止Web GUI服务
## 使用方法
所有脚本都可以在项目根目录下直接运行。
+11
View File
@@ -0,0 +1,11 @@
@echo off
REM Git自动提交和推送批处理脚本
REM 每小时自动保存修改、提交并推送到GitHub
cd /d "C:\Users\12742\Desktop\douyin_guaji-main"
REM 运行PowerShell脚本
powershell.exe -ExecutionPolicy Bypass -File "%~dp0auto_commit_push.ps1"
pause
+52
View File
@@ -0,0 +1,52 @@
# Git Auto Commit and Push Script
# Auto save, commit and push to GitHub every hour
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$ErrorActionPreference = "Stop"
# Switch to project directory
$projectPath = "C:\Users\12742\Desktop\douyin_guaji-main"
Set-Location $projectPath
# Get current timestamp
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Auto Commit Script Running: $timestamp" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
try {
# Check for changes
$status = git status --porcelain
if ($status) {
Write-Host "Changes detected, starting commit..." -ForegroundColor Yellow
# Add all modified files
git add -A
# Create commit message with timestamp
$commitMessage = "Auto commit: $timestamp - Hourly auto save"
git commit -m $commitMessage
Write-Host "Commit successful: $commitMessage" -ForegroundColor Green
# Push to GitHub
Write-Host "Pushing to GitHub..." -ForegroundColor Yellow
git push origin main
Write-Host "Push successful!" -ForegroundColor Green
} else {
Write-Host "No changes detected, skipping commit." -ForegroundColor Gray
}
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Script execution completed" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
} catch {
Write-Host "Error: $_" -ForegroundColor Red
Write-Host "Stack trace: $($_.ScriptStackTrace)" -ForegroundColor Red
exit 1
}
+31
View File
@@ -0,0 +1,31 @@
@echo off
REM Git自动提交任务设置脚本
REM 以管理员权限运行此脚本来自动设置定时任务
echo ========================================
echo Git自动提交任务设置
echo ========================================
echo.
echo 正在检查管理员权限...
REM 检查管理员权限
net session >nul 2>&1
if %errorLevel% neq 0 (
echo 错误: 需要管理员权限!
echo.
echo 请右键点击此文件,选择"以管理员身份运行"
echo.
pause
exit /b 1
)
echo 管理员权限确认!
echo.
echo 正在运行设置脚本...
echo.
REM 使用Bypass执行策略运行PowerShell脚本
powershell.exe -ExecutionPolicy Bypass -File "%~dp0setup_auto_commit.ps1"
pause
+103
View File
@@ -0,0 +1,103 @@
# Setup Auto Commit Task Script
# This script will create a Windows scheduled task to run git auto commit every hour
# Check if running as administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "This script requires administrator privileges." -ForegroundColor Red
Write-Host "Please run PowerShell as Administrator and try again." -ForegroundColor Yellow
Write-Host ""
Write-Host "Right-click PowerShell -> Run as Administrator" -ForegroundColor Yellow
pause
exit 1
}
$taskName = "Git自动提交推送"
$scriptPath = "C:\Users\12742\Desktop\douyin_guaji-main\auto_commit_push.ps1"
$workingDir = "C:\Users\12742\Desktop\douyin_guaji-main"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host "Setting up Git Auto Commit Task" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Check if task already exists
$existingTask = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
if ($existingTask) {
Write-Host "Task '$taskName' already exists." -ForegroundColor Yellow
$response = Read-Host "Do you want to remove and recreate it? (Y/N)"
if ($response -eq "Y" -or $response -eq "y") {
Unregister-ScheduledTask -TaskName $taskName -Confirm:$false
Write-Host "Old task removed." -ForegroundColor Green
} else {
Write-Host "Cancelled." -ForegroundColor Yellow
exit 0
}
}
Write-Host "Creating scheduled task..." -ForegroundColor Yellow
# Create action
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-ExecutionPolicy Bypass -File `"$scriptPath`"" `
-WorkingDirectory $workingDir
# Create trigger (start now, repeat every hour, duration 365 days)
$trigger = New-ScheduledTaskTrigger `
-Once `
-At (Get-Date) `
-RepetitionInterval (New-TimeSpan -Hours 1) `
-RepetitionDuration (New-TimeSpan -Days 365)
# Create principal (run with highest privileges)
$principal = New-ScheduledTaskPrincipal `
-UserId "$env:USERNAME" `
-RunLevel Highest
# Create settings
$settings = New-ScheduledTaskSettingsSet `
-AllowStartIfOnBatteries `
-DontStopIfGoingOnBatteries `
-StartWhenAvailable `
-MultipleInstances IgnoreNew
# Register the task
try {
Register-ScheduledTask `
-TaskName $taskName `
-Action $action `
-Trigger $trigger `
-Principal $principal `
-Settings $settings `
-Description "每小时自动保存修改、提交并推送到GitHub" | Out-Null
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host "Task created successfully!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
Write-Host ""
Write-Host "Task Name: $taskName" -ForegroundColor Cyan
Write-Host "Schedule: Every 1 hour" -ForegroundColor Cyan
Write-Host "Script: $scriptPath" -ForegroundColor Cyan
Write-Host ""
Write-Host "You can manage this task in Task Scheduler:" -ForegroundColor Yellow
Write-Host " Task Scheduler -> Task Scheduler Library -> $taskName" -ForegroundColor Yellow
Write-Host ""
Write-Host "To test the task, run:" -ForegroundColor Yellow
Write-Host " Start-ScheduledTask -TaskName '$taskName'" -ForegroundColor White
Write-Host ""
Write-Host "Or manually run: .\auto_commit_push.ps1" -ForegroundColor Yellow
Write-Host ""
} catch {
Write-Host ""
Write-Host "Error creating task: $_" -ForegroundColor Red
Write-Host "Please check the error message above." -ForegroundColor Yellow
exit 1
}
pause
+178
View File
@@ -0,0 +1,178 @@
@echo off
REM ==========================================
REM Douyin Web GUI Launcher (Stable Version)
REM ==========================================
REM Save original code page
for /f "tokens=2 delims=:" %%a in ('chcp') do set "_ORIG_CP=%%a"
set "_ORIG_CP=%_ORIG_CP: =%"
chcp 65001 >nul 2>&1
setlocal enabledelayedexpansion
REM Change to script directory
cd /d "%~dp0"
if errorlevel 1 (
echo [ERROR] Cannot change to script directory
pause
goto :cleanup
)
REM Save current directory to variable (for delayed expansion)
set "WORK_DIR=%~dp0"
set "WORK_DIR=!WORK_DIR:~0,-1!"
REM Create log file
set "LOG_FILE=%~dp0webgui_startup.log"
(
echo ========================================
echo Start time: %date% %time%
echo ========================================
) >> "%LOG_FILE%" 2>&1
echo.
echo ========================================
echo Douyin Web GUI Launcher
echo ========================================
echo.
REM [1/6] Check Python environment
echo [1/6] Checking Python environment...
python --version >> "%LOG_FILE%" 2>&1
if errorlevel 1 (
echo [ERROR] Python not detected, please install Python first
echo Download: https://www.python.org/downloads/
echo [ERROR] Python not installed >> "%LOG_FILE%"
pause
goto :cleanup
)
echo [1/6] Python environment check... OK
echo.
REM [2/6] Check required files
echo [2/6] Checking required files...
if not exist "web_gui.py" (
echo [ERROR] web_gui.py not found
echo Current directory: !WORK_DIR!
echo [ERROR] web_gui.py does not exist >> "%LOG_FILE%"
pause
goto :cleanup
)
echo [2/6] File check... OK
echo.
REM [3/6] Stop old processes
echo [3/6] Stopping old processes...
REM Silently stop old processes, redirect all output to nul to avoid garbled text
powershell -NoProfile -ExecutionPolicy Bypass -Command "$ErrorActionPreference='SilentlyContinue'; Get-CimInstance Win32_Process -ErrorAction SilentlyContinue | Where-Object {$_.CommandLine -like '*web_gui.py*' -and $_.Name -like 'python*'} | ForEach-Object {Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue}" >nul 2>&1
timeout /t 2 /nobreak >nul
echo [3/6] Stopping old processes... OK
echo.
REM [4/6] Port configuration
set "WEB_PORT=8000"
if defined PORT set "WEB_PORT=!PORT!"
if defined WEB_GUI_PORT set "WEB_PORT=!WEB_GUI_PORT!"
echo [4/6] Port configuration: !WEB_PORT!
echo.
REM [5/6] Start service
echo [5/6] Starting Web GUI service (Port: !WEB_PORT!)...
echo.
REM Set Python environment variables
set PYTHONIOENCODING=utf-8
set PYTHONUNBUFFERED=1
REM Determine Python executable path
set "PYTHON_EXE="
set "USE_VENV=0"
REM Prefer virtual environment Python
if exist ".venv\Scripts\python.exe" (
set "PYTHON_EXE=.venv\Scripts\python.exe"
set "USE_VENV=1"
echo Virtual environment detected, using venv Python
) else if exist ".venv\Scripts\activate.bat" (
REM If python.exe not found, try using activate.bat
set "USE_VENV=2"
echo Virtual environment detected, using activate.bat
) else (
set "PYTHON_EXE=python"
set "USE_VENV=0"
echo Using system Python
)
REM Start service (in new window, keep window open)
if !USE_VENV! equ 1 (
REM Use virtual environment python.exe directly (use full path)
set "PYTHON_CMD=!WORK_DIR!\.venv\Scripts\python.exe web_gui.py"
) else if !USE_VENV! equ 2 (
REM Use activate.bat
set "PYTHON_CMD=call !WORK_DIR!\.venv\Scripts\activate.bat && python web_gui.py"
) else (
REM Use system Python
set "PYTHON_CMD=python web_gui.py"
)
REM Start command with proper quoting
start "Douyin Web GUI" /D "!WORK_DIR!" cmd /k "cd /d !WORK_DIR! && echo Starting Web GUI service... && echo. && !PYTHON_CMD!"
REM Wait for service to start
echo Starting service, please wait...
set /a count=0
:wait_loop
timeout /t 2 /nobreak >nul
set /a count+=1
REM Check if port is listening (use temporary variable to pass port number)
set "CHECK_PORT=!WEB_PORT!"
powershell -NoProfile -Command "$listener = Get-NetTCPConnection -LocalPort %CHECK_PORT% -State Listen -ErrorAction SilentlyContinue; if ($listener) { exit 0 } else { exit 1 }" >nul 2>&1
if not errorlevel 1 (
echo [5/6] Web GUI service started
goto :open_browser
)
REM Timeout check (wait up to 30 seconds)
if !count! geq 15 (
echo [WARNING] Service startup timeout (waited 30 seconds)
echo Please check the error message in the new "Douyin Web GUI" window
echo Or check log file: %LOG_FILE%
goto :open_browser
)
goto :wait_loop
:open_browser
REM [6/6] Open browser
echo.
echo [6/6] Opening browser...
timeout /t 1 /nobreak >nul
start "" "http://127.0.0.1:!WEB_PORT!"
echo.
echo ========================================
echo Startup Complete!
echo ========================================
echo.
echo Web GUI URL: http://127.0.0.1:!WEB_PORT!
echo Log file: %LOG_FILE%
echo.
echo Notes:
echo - Web GUI service is running in a new window, do not close that window
echo - Closing this window will not stop the Web GUI service
echo - To stop the service, close the "Douyin Web GUI" window
echo - Or run "StopWebGUIService.bat"
echo.
REM Ask if view log
set /p view_log="View startup log? (Y/N): "
if /i "!view_log!"=="Y" (
if exist "%LOG_FILE%" (
notepad "%LOG_FILE%"
)
)
:cleanup
endlocal
if defined _ORIG_CP chcp %_ORIG_CP% >nul 2>&1
exit /b 0
+22
View File
@@ -0,0 +1,22 @@
@echo off
REM 保存原始代码页
for /f "tokens=2 delims=:" %%a in ('chcp') do set _ORIG_CP=%%a
set _ORIG_CP=%_ORIG_CP: =%
REM 设置为UTF-8编码
chcp 65001 >nul
echo ========================================
echo 停止抖音挂机 Web GUI 服务
echo ========================================
echo.
echo 正在查找Web GUI进程...
REM 查找并停止web_gui.py进程
powershell -NoProfile -Command "$ps = Get-CimInstance Win32_Process | Where-Object { ($_.CommandLine -like '*web_gui.py*') -and ($_.Name -like 'python*') }; if ($ps) { $ps | ForEach-Object { try { $pid = $_.ProcessId; Stop-Process -Id $pid -Force -ErrorAction SilentlyContinue; Write-Host \"[已停止] PID=$pid\" } catch { Write-Host \"[停止失败] PID=$($_.ProcessId): $_\" } } } else { Write-Host \"[未找到] 没有运行中的Web GUI进程\" }"
echo.
echo 操作完成!
echo.
pause
REM 恢复原始代码页
if defined _ORIG_CP chcp %_ORIG_CP% >nul