Compare commits
264 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ba4321b892 | |||
| a8f0186c2e | |||
| 1574ae594e | |||
| 2b45038a62 | |||
| 727d31fbcc | |||
| 710ef26151 | |||
| fdd8aa81ba | |||
| a4c6c3381a | |||
| 68a9e870cf | |||
| 02de32719d | |||
| c5a78a2da3 | |||
| 32f02d856d | |||
| 4edb1baa0b | |||
| 1ffa1cacb9 | |||
| 207eb70f11 | |||
| 64144e5ed7 | |||
| d05fae7e87 | |||
| 9abdec6c33 | |||
| fb5eb61d05 | |||
| eff2164ecc | |||
| d8aa206ea2 | |||
| 6de74303ff | |||
| 5eb6314cb2 | |||
| 179dd0af83 | |||
| 365700900f | |||
| babbccdc9a | |||
| 367ffab86a | |||
| 71bad60617 | |||
| 27758f794c | |||
| d82afe8577 | |||
| 8592b3058e | |||
| 7a82e948b9 | |||
| 782b0b6bc9 | |||
| 71cc0d9f1f | |||
| 675dead1d9 | |||
| 64ca3c76a2 | |||
| d378ee8258 | |||
| e9b01426f8 | |||
| 631f6592ac | |||
| 468faff16b | |||
| 6b45c40aad | |||
| d6302fc43f | |||
| e768c7518b | |||
| 49c390131a | |||
| 9bc0e22ff7 | |||
| 982be09f6e | |||
| d5582c5c38 | |||
| 392d2a6f03 | |||
| 7310049246 | |||
| 04aaff3b29 | |||
| f5809c466a | |||
| 8f19703314 | |||
| 7d1f249797 | |||
| c20dc32de5 | |||
| b2bc97a6af | |||
| 15a771fe9f | |||
| 976d610baf | |||
| 42616f996d | |||
| 8601a1ed50 | |||
| a885576d8a | |||
| a8de8461bd | |||
| c1e4f3a688 | |||
| ca4020970a | |||
| 0956317eb2 | |||
| eed4af7705 | |||
| 02bb77ea1e | |||
| 204ef0f233 | |||
| aeaaeb6917 | |||
| cb9e147f19 | |||
| 9501f0e158 | |||
| c7b49f079f | |||
| 478bf1c394 | |||
| e54b3362f9 | |||
| e0993ac5b7 | |||
| 9715043936 | |||
| 761158746f | |||
| 8d5b76e054 | |||
| 4eedf620bf | |||
| e016695f83 | |||
| 416920e660 | |||
| 39aad600ed | |||
| f051275659 | |||
| 14afc821b1 | |||
| b913a82aef | |||
| 38b03526e3 | |||
| a954609958 | |||
| 5bd3c94e87 | |||
| 7c456d4aef | |||
| 1f5e33f975 | |||
| 4203969051 | |||
| f4cde66748 | |||
| 040a8ad728 | |||
| bf97907600 | |||
| 82a2f2d4d7 | |||
| 8944ed3e37 | |||
| a4797c6fe5 | |||
| e52f9301d8 | |||
| 4f943759f4 | |||
| eb9d5d60d1 | |||
| 7aea5c882a | |||
| b4ba9ea4d1 | |||
| dcba60c695 | |||
| be1c9bfe45 | |||
| b3cd6e0e5a | |||
| 41e418b9a8 | |||
| c2122a9074 | |||
| 54bf6598ab | |||
| 810bed347b | |||
| 0be76550cf | |||
| 0e2054dbb9 | |||
| 8e2013326b | |||
| 21828e3a48 | |||
| d12b0dfbaa | |||
| 477d595db2 | |||
| d276a03949 | |||
| cf19fa1c3d | |||
| e3ac085b00 | |||
| 3d11447e22 | |||
| a84b29f1f6 | |||
| 2d292d4796 | |||
| ec36717c6a | |||
| 1f0404dd65 | |||
| 5a63131777 | |||
| ee8c770db2 | |||
| 49c89249c6 | |||
| 64953cb969 | |||
| 32bacd1211 | |||
| 87b5d63e1b | |||
| 9744777747 | |||
| 5a7f2e1501 | |||
| 3519985b83 | |||
| fd3a0390df | |||
| a31d9c10cc | |||
| 5486e75ced | |||
| 348c524453 | |||
| 6c148647d8 | |||
| 030ab8d51a | |||
| ea2470587d | |||
| d1df23f4e3 | |||
| df5ebc2bc6 | |||
| 2568c7307c | |||
| a6589df44d | |||
| 4c586477ab | |||
| a29f58c023 | |||
| 49ba699155 | |||
| cc51f57e18 | |||
| cf9185e9e7 | |||
| fc67ff11c9 | |||
| 6592cd4ec1 | |||
| 767955e008 | |||
| 75c649afda | |||
| 7526eb5d30 | |||
| 1f16a58f21 | |||
| 5b42d8d607 | |||
| dde4288a2d | |||
| ac0d64edd3 | |||
| 912d9d8c00 | |||
| ce2cd9cdd8 | |||
| 5e6e96a8cd | |||
| 8161e28d67 | |||
| 6253aa0eb0 | |||
| c063c226db | |||
| 929fdf69e5 | |||
| 48b9919b7a | |||
| c43fd006fd | |||
| 12506dd1df | |||
| 9e3d1cf90a | |||
| 2ad02435a1 | |||
| f11837217c | |||
| 1a7de70c0b | |||
| a3ff23147f | |||
| fa4e753861 | |||
| b0bbb98927 | |||
| fda45efcb5 | |||
| 3de2110a3e | |||
| cb7e74a224 | |||
| 5fe3502bd6 | |||
| b59768bcff | |||
| d4b7067484 | |||
| 77c2e9cd9e | |||
| 290388a7dc | |||
| 3b51552313 | |||
| 9e7607dd36 | |||
| 616552063d | |||
| 9eb70af1a1 | |||
| 4d4187ce63 | |||
| cac2ad3ab1 | |||
| cdbf9165d2 | |||
| 23e44cb128 | |||
| 0a591e1cda | |||
| c0f5060451 | |||
| c6940f0178 | |||
| 2afb3e7716 | |||
| 325eda54fa | |||
| 53d4a240a0 | |||
| a56969f19d | |||
| 2beabbb1ba | |||
| 5bb732072e | |||
| f50bfd0aa0 | |||
| 71adbfcd96 | |||
| 270ee027f7 | |||
| a443f64501 | |||
| 0e05f42741 | |||
| d33c01941e | |||
| 053ea7694d | |||
| c25802cb95 | |||
| 62b24c7111 | |||
| b0e4368e25 | |||
| 79f9155d76 | |||
| 7cc36fb3ed | |||
| 7de83ae6d0 | |||
| 0374cbf511 | |||
| 7df7d87928 | |||
| e97f9ffe8a | |||
| c4685dc2de | |||
| f34d02d3d0 | |||
| 91b5c12afa | |||
| b77867b111 | |||
| bf20625832 | |||
| 8d218443bf | |||
| a55a049583 | |||
| 4e7e08c136 | |||
| c3efa39b09 | |||
| d3d7a9d2ac | |||
| 74e7fcfd70 | |||
| adecc78aec | |||
| f6b852309b | |||
| 86ec6daca2 | |||
| 8d6d02a1af | |||
| 2e2e526d3a | |||
| 11b8f3f265 | |||
| 5369578194 | |||
| c5e6608ae2 | |||
| 214d9a0e23 | |||
| e0da811bfe | |||
| ef538fc83d | |||
| c5e72332dc | |||
| 39522a4068 | |||
| a9f229926b | |||
| ec950b751b | |||
| 56735c4344 | |||
| 8db9f3d9e2 | |||
| 80d3ad208d | |||
| 87886a5cf9 | |||
| 7cdae312ce | |||
| ffdd656b9c | |||
| d8fec74de1 | |||
| 75e4da33eb | |||
| 003dd0e3aa | |||
| c76d179daa | |||
| eba4c01fca | |||
| 577a1637e4 | |||
| 889c50e201 | |||
| e4d1c189b7 | |||
| 7d55af6ac0 | |||
| b9dc6cc18d | |||
| 29bac99359 | |||
| d6a388652b | |||
| 1c3fb95e40 | |||
| e354ef50cf | |||
| 2066c86001 | |||
| 7e2b4cb46b | |||
| bef019cf8c | |||
| 886ee8f0f0 |
@@ -0,0 +1,16 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Keeps your GitHub Actions (CI/CD) up to date daily
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
# Keeps your Python dependencies (requirements.txt / pyproject.toml) up to date daily
|
||||
- package-ecosystem: "pip"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
ignore:
|
||||
- dependency-name: "darkdetect"
|
||||
versions: [">=0.8.0"]
|
||||
@@ -0,0 +1,31 @@
|
||||
changelog:
|
||||
exclude:
|
||||
labels:
|
||||
- ignore-for-release
|
||||
authors:
|
||||
- dependabot[bot]
|
||||
- github-actions[bot]
|
||||
categories:
|
||||
- title: "New Features"
|
||||
labels:
|
||||
- enhancement
|
||||
- feature
|
||||
- title: "Bug Fixes"
|
||||
labels:
|
||||
- bug
|
||||
- fix
|
||||
- title: "Documentation"
|
||||
labels:
|
||||
- documentation
|
||||
- title: "Maintenance"
|
||||
labels:
|
||||
- chore
|
||||
- refactor
|
||||
- testing
|
||||
- build
|
||||
- title: "Dependencies"
|
||||
labels:
|
||||
- dependencies
|
||||
- title: "Other Changes"
|
||||
labels:
|
||||
- "*"
|
||||
@@ -0,0 +1,280 @@
|
||||
name: Create Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
env:
|
||||
PYTHON_VERSION: "3.12"
|
||||
APP_NAME: "SoftwareManager"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
artifact_name: SoftwareManager-stable-${{ github.sha }}-linux
|
||||
asset_name: SoftwareManager-stable-${{ github.sha }}-linux
|
||||
- os: windows-latest
|
||||
artifact_name: SoftwareManager-stable-${{ github.sha }}-windows
|
||||
asset_name: SoftwareManager-stable-${{ github.sha }}-windows
|
||||
- os: macos-latest
|
||||
artifact_name: SoftwareManager-stable-${{ github.sha }}-macos
|
||||
asset_name: SoftwareManager-stable-${{ github.sha }}-macos
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
short_sha: ${{ steps.version.outputs.short_sha }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
version: "0.9.7"
|
||||
enable-cache: true
|
||||
|
||||
- name: Install system dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libxcb-xinerama0 \
|
||||
libxkbcommon-x11-0 \
|
||||
libxcb-cursor0 \
|
||||
libxcb-keysyms1 \
|
||||
libxcb-render-util0 \
|
||||
libxcb-icccm4 \
|
||||
libxcb-image0 \
|
||||
libxcb-shape0 \
|
||||
libxcb-util1
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
uv pip install -r requirements.txt
|
||||
uv pip install Pillow
|
||||
env:
|
||||
UV_SYSTEM_PYTHON: 1
|
||||
|
||||
- name: Install Nuitka (Windows only)
|
||||
if: runner.os == 'Windows'
|
||||
run: uv pip install nuitka
|
||||
env:
|
||||
UV_SYSTEM_PYTHON: 1
|
||||
|
||||
- name: Generate version
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
COMMIT_SHA=${{ github.sha }}
|
||||
SHORT_SHA=${COMMIT_SHA:0:7}
|
||||
VERSION="${SHORT_SHA}-stable"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
||||
echo "Generated version: $VERSION"
|
||||
|
||||
- name: Inject commit hash into code
|
||||
shell: bash
|
||||
run: |
|
||||
cat > build_info.json << EOF
|
||||
{
|
||||
"version": "${{ env.VERSION }}"
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Install UPX (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
curl -sL https://github.com/upx/upx/releases/download/v5.1.0/upx-5.1.0-win64.zip -o upx.zip
|
||||
7z x upx.zip -oupx-dir
|
||||
UPX_DIR="$(pwd)/upx-dir/upx-5.1.0-win64"
|
||||
echo "$UPX_DIR" >> $GITHUB_PATH
|
||||
export PATH="$UPX_DIR:$PATH"
|
||||
echo "UPX_BINARY=$UPX_DIR/upx.exe" >> $GITHUB_ENV
|
||||
upx --version | head -1
|
||||
|
||||
- name: Convert icon for Windows
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
python -c "
|
||||
from PIL import Image
|
||||
img = Image.open('src/interface/assets/logo.png')
|
||||
img.save('app_icon.ico', format='ICO', sizes=[(256,256),(128,128),(64,64),(48,48),(32,32),(16,16)])
|
||||
print('Icon converted successfully')
|
||||
"
|
||||
|
||||
- name: Build with Nuitka (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
python -m nuitka \
|
||||
--standalone \
|
||||
--assume-yes-for-downloads \
|
||||
--windows-console-mode=disable \
|
||||
--windows-icon-from-ico=app_icon.ico \
|
||||
--enable-plugin=pyside6 \
|
||||
--enable-plugin=upx \
|
||||
--upx-binary="${{ env.UPX_BINARY }}" \
|
||||
--noinclude-qt-translations \
|
||||
--include-data-files=build_info.json=build_info.json \
|
||||
--output-filename=${{ env.APP_NAME }}.exe \
|
||||
--output-dir=nuitka-build \
|
||||
src/main.py
|
||||
|
||||
- name: Build with PyInstaller (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
pyinstaller --onefile --windowed \
|
||||
--add-data "build_info.json:." \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
--hidden-import=backports \
|
||||
--hidden-import=jaraco.context \
|
||||
--hidden-import=jaraco.text \
|
||||
--hidden-import=jaraco.functools \
|
||||
--name ${{ env.APP_NAME }} \
|
||||
src/main.py
|
||||
|
||||
- name: Build with PyInstaller (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
shell: bash
|
||||
run: |
|
||||
pyinstaller --windowed \
|
||||
--add-data "build_info.json:." \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
--hidden-import=backports \
|
||||
--hidden-import=jaraco.context \
|
||||
--hidden-import=jaraco.text \
|
||||
--hidden-import=jaraco.functools \
|
||||
--name ${{ env.APP_NAME }} \
|
||||
src/main.py
|
||||
|
||||
- name: Install create-dmg (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install create-dmg
|
||||
|
||||
- name: Rename artifact
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dist-final
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
mv nuitka-build/main.dist dist-final/${{ env.APP_NAME }}
|
||||
ls -la dist-final/${{ env.APP_NAME }}/
|
||||
elif [ "$RUNNER_OS" == "Linux" ]; then
|
||||
chmod +x dist/${{ env.APP_NAME }}
|
||||
mv dist/${{ env.APP_NAME }} dist-final/${{ matrix.artifact_name }}
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
create-dmg \
|
||||
--volname "${{ env.APP_NAME }}" \
|
||||
--window-pos 200 120 \
|
||||
--window-size 600 300 \
|
||||
--icon-size 100 \
|
||||
--icon "${{ env.APP_NAME }}.app" 150 150 \
|
||||
--hide-extension "${{ env.APP_NAME }}.app" \
|
||||
--app-drop-link 450 150 \
|
||||
"dist-final/${{ matrix.artifact_name }}.dmg" \
|
||||
"dist/"
|
||||
fi
|
||||
ls -la dist-final/
|
||||
|
||||
- name: Create ZIP (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
Compress-Archive -Path "dist-final/${{ env.APP_NAME }}/*" -DestinationPath "dist-final/${{ matrix.artifact_name }}.zip"
|
||||
Write-Host "Created ZIP: ${{ matrix.artifact_name }}.zip"
|
||||
|
||||
- name: Build Installer (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
SHORT_SHA="${{ github.sha }}"
|
||||
SHORT_SHA="${SHORT_SHA:0:7}"
|
||||
SETUP_NAME="SoftwareManager-stable-${SHORT_SHA}-windows-setup"
|
||||
iscc //DMyAppVersion="${{ env.VERSION }}" \
|
||||
//DMySourceDir="dist-final\\${{ env.APP_NAME }}" \
|
||||
//DMyOutputDir="dist-final" \
|
||||
//DMyOutputFilename="${SETUP_NAME}" \
|
||||
installer.iss
|
||||
echo "SETUP_NAME=${SETUP_NAME}" >> $GITHUB_ENV
|
||||
ls -la dist-final/
|
||||
|
||||
- name: Upload build artifact (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: |
|
||||
dist-final/${{ matrix.artifact_name }}.zip
|
||||
dist-final/${{ env.SETUP_NAME }}.exe
|
||||
retention-days: 1
|
||||
|
||||
- name: Upload build artifact (Linux/macOS)
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: dist-final/${{ matrix.artifact_name }}*
|
||||
retention-days: 1
|
||||
|
||||
release:
|
||||
name: Create Release
|
||||
needs: build
|
||||
runs-on: ubuntu-22.04
|
||||
if: success()
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Prepare release files
|
||||
run: |
|
||||
mkdir -p release
|
||||
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
||||
cp artifacts/ubuntu-22.04-build/SoftwareManager-stable-*-linux release/SoftwareManager-stable-${SHORT_SHA}-linux
|
||||
cp artifacts/windows-latest-build/SoftwareManager-stable-*-windows.zip release/SoftwareManager-stable-${SHORT_SHA}-windows.zip
|
||||
cp artifacts/windows-latest-build/SoftwareManager-stable-*-windows-setup.exe release/SoftwareManager-stable-${SHORT_SHA}-windows-setup.exe
|
||||
cp artifacts/macos-latest-build/SoftwareManager-stable-*-macos.dmg release/SoftwareManager-stable-${SHORT_SHA}-macos.dmg
|
||||
chmod +x release/SoftwareManager-stable-*-linux
|
||||
ls -la release/
|
||||
|
||||
- name: Generate checksums
|
||||
run: |
|
||||
cd release
|
||||
sha256sum * > SHA256SUMS.txt
|
||||
cat SHA256SUMS.txt
|
||||
|
||||
- name: Create Release (Public)
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
token: ${{ secrets.RELEASE_TOKEN }}
|
||||
tag_name: ${{ needs.build.outputs.version }}
|
||||
name: ${{ needs.build.outputs.version }}
|
||||
generate_release_notes: true
|
||||
files: |
|
||||
release/SoftwareManager-stable-${{ needs.build.outputs.short_sha }}-linux
|
||||
release/SoftwareManager-stable-${{ needs.build.outputs.short_sha }}-windows.zip
|
||||
release/SoftwareManager-stable-${{ needs.build.outputs.short_sha }}-windows-setup.exe
|
||||
release/SoftwareManager-stable-${{ needs.build.outputs.short_sha }}-macos.dmg
|
||||
release/SHA256SUMS.txt
|
||||
@@ -1,9 +1,6 @@
|
||||
name: Build Executables (Dev)
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
@@ -41,7 +38,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
@@ -54,6 +51,21 @@ jobs:
|
||||
version: "0.9.7"
|
||||
enable-cache: true
|
||||
|
||||
- name: Install system dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libxcb-xinerama0 \
|
||||
libxkbcommon-x11-0 \
|
||||
libxcb-cursor0 \
|
||||
libxcb-keysyms1 \
|
||||
libxcb-render-util0 \
|
||||
libxcb-icccm4 \
|
||||
libxcb-image0 \
|
||||
libxcb-shape0 \
|
||||
libxcb-util1
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
uv pip install -r requirements.txt
|
||||
@@ -61,6 +73,15 @@ jobs:
|
||||
env:
|
||||
UV_SYSTEM_PYTHON: 1
|
||||
|
||||
- name: Install dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libxcb-cursor0 libxcb-render-util0 libxcb-xkb1 \
|
||||
libxcb-icccm4 libxcb-keysyms1 libxcb-image0 \
|
||||
libxcb-shape0 libxcb-util1 libxkbcommon-x11-0
|
||||
|
||||
- name: Install Nuitka (Windows only)
|
||||
if: runner.os == 'Windows'
|
||||
run: uv pip install nuitka
|
||||
@@ -106,7 +127,7 @@ jobs:
|
||||
run: |
|
||||
python -c "
|
||||
from PIL import Image
|
||||
img = Image.open('src/core/interface/assets/logo.png')
|
||||
img = Image.open('src/interface/assets/logo.png')
|
||||
img.save('app_icon.ico', format='ICO', sizes=[(256,256),(128,128),(64,64),(48,48),(32,32),(16,16)])
|
||||
print('Icon converted successfully')
|
||||
"
|
||||
@@ -125,8 +146,6 @@ jobs:
|
||||
--upx-binary="${{ env.UPX_BINARY }}" \
|
||||
--noinclude-qt-translations \
|
||||
--include-data-files=build_info.json=build_info.json \
|
||||
--include-data-files=build_info.json=src/build_info.json \
|
||||
--include-data-files=build_info.json=src/core/interface/build_info.json \
|
||||
--output-filename=${{ env.APP_NAME }}.exe \
|
||||
--output-dir=nuitka-build \
|
||||
src/main.py
|
||||
@@ -137,8 +156,6 @@ jobs:
|
||||
run: |
|
||||
pyinstaller --onefile --windowed \
|
||||
--add-data "build_info.json:." \
|
||||
--add-data "build_info.json:src/core" \
|
||||
--add-data "build_info.json:src/core/interface" \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
@@ -155,8 +172,6 @@ jobs:
|
||||
run: |
|
||||
pyinstaller --onefile \
|
||||
--add-data "build_info.json:." \
|
||||
--add-data "build_info.json:src/core" \
|
||||
--add-data "build_info.json:src/core/interface" \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
@@ -204,7 +219,7 @@ jobs:
|
||||
|
||||
- name: Upload build artifact (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: |
|
||||
@@ -214,7 +229,7 @@ jobs:
|
||||
|
||||
- name: Upload build artifact (Linux/macOS)
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/upload-artifact@v4
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: dist-final/${{ matrix.artifact_name }}
|
||||
@@ -227,8 +242,8 @@ jobs:
|
||||
if: success()
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/download-artifact@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
@@ -275,7 +290,7 @@ jobs:
|
||||
cat release_notes.md
|
||||
|
||||
- name: Create Release (Public)
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ needs.build.outputs.version }}
|
||||
name: ${{ needs.build.outputs.version }}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
name: Sync README Dependencies
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- requirements.txt
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Update README dependencies
|
||||
run: python scripts/sync_readme_dependencies.py
|
||||
|
||||
- name: Create pull request
|
||||
uses: peter-evans/create-pull-request@v8
|
||||
with:
|
||||
commit-message: "Sync README dependencies"
|
||||
branch: auto/sync-readme-dependencies
|
||||
title: "Sync README dependencies"
|
||||
body: "Automated update of the Python Dependencies section in README.md to match `requirements.txt`."
|
||||
labels: documentation
|
||||
token: ${{ secrets.PR_TOKEN }}
|
||||
@@ -0,0 +1,224 @@
|
||||
name: Build Executables (Test)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
PYTHON_VERSION: "3.12"
|
||||
APP_NAME: "SoftwareManager"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-22.04
|
||||
artifact_paths: |
|
||||
dist-final/SoftwareManager-test-${{ github.sha }}-linux*
|
||||
dist-final/SoftwareManager-x86_64*
|
||||
- os: windows-latest
|
||||
artifact_paths: |
|
||||
dist-final/SoftwareManager-test-${{ github.sha }}-windows*
|
||||
- os: macos-latest
|
||||
artifact_paths: |
|
||||
dist-final/SoftwareManager-test-${{ github.sha }}-macos*
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: ${{ env.PYTHON_VERSION }}
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
version: "0.9.7"
|
||||
enable-cache: true
|
||||
|
||||
- name: Install system dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y \
|
||||
libxcb-xinerama0 \
|
||||
libxkbcommon-x11-0 \
|
||||
libxcb-cursor0 \
|
||||
libxcb-keysyms1 \
|
||||
libxcb-render-util0 \
|
||||
libxcb-icccm4 \
|
||||
libxcb-image0 \
|
||||
libxcb-shape0 \
|
||||
libxcb-util1
|
||||
|
||||
- name: Install Python dependencies
|
||||
run: |
|
||||
uv pip install -r requirements.txt
|
||||
uv pip install Pillow
|
||||
env:
|
||||
UV_SYSTEM_PYTHON: 1
|
||||
|
||||
- name: Install Nuitka (Windows only)
|
||||
if: runner.os == 'Windows'
|
||||
run: uv pip install nuitka
|
||||
env:
|
||||
UV_SYSTEM_PYTHON: 1
|
||||
|
||||
- name: Generate version
|
||||
id: version
|
||||
shell: bash
|
||||
run: |
|
||||
SHORT_SHA="${{ github.sha }}"
|
||||
SHORT_SHA="${SHORT_SHA:0:7}"
|
||||
BRANCH="${{ github.head_ref || github.ref_name }}"
|
||||
BRANCH_SLUG="${BRANCH//\//-}" # replace slashes with dashes
|
||||
VERSION="${BRANCH_SLUG}-${SHORT_SHA}-test"
|
||||
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
||||
echo "Generated version: $VERSION"
|
||||
|
||||
- name: Inject build info
|
||||
shell: bash
|
||||
run: |
|
||||
cat > build_info.json << EOF
|
||||
{
|
||||
"version": "${{ env.VERSION }}"
|
||||
}
|
||||
EOF
|
||||
|
||||
- name: Install UPX (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
curl -sL https://github.com/upx/upx/releases/download/v5.1.0/upx-5.1.0-win64.zip -o upx.zip
|
||||
7z x upx.zip -oupx-dir
|
||||
UPX_DIR="$(pwd)/upx-dir/upx-5.1.0-win64"
|
||||
echo "$UPX_DIR" >> $GITHUB_PATH
|
||||
export PATH="$UPX_DIR:$PATH"
|
||||
echo "UPX_BINARY=$UPX_DIR/upx.exe" >> $GITHUB_ENV
|
||||
upx --version | head -1
|
||||
|
||||
- name: Convert icon for Windows
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
python -c "
|
||||
from PIL import Image
|
||||
img = Image.open('src/interface/assets/logo.png')
|
||||
img.save('app_icon.ico', format='ICO', sizes=[(256,256),(128,128),(64,64),(48,48),(32,32),(16,16)])
|
||||
print('Icon converted successfully')
|
||||
"
|
||||
|
||||
- name: Build with Nuitka (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
python -m nuitka \
|
||||
--standalone \
|
||||
--assume-yes-for-downloads \
|
||||
--windows-console-mode=disable \
|
||||
--windows-icon-from-ico=app_icon.ico \
|
||||
--enable-plugin=pyside6 \
|
||||
--enable-plugin=upx \
|
||||
--upx-binary="${{ env.UPX_BINARY }}" \
|
||||
--noinclude-qt-translations \
|
||||
--include-data-files=build_info.json=build_info.json \
|
||||
--output-filename=${{ env.APP_NAME }}.exe \
|
||||
--output-dir=nuitka-build \
|
||||
src/main.py
|
||||
|
||||
- name: Build with PyInstaller (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: |
|
||||
pyinstaller --onefile --windowed \
|
||||
--add-data "build_info.json:." \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
--hidden-import=backports \
|
||||
--hidden-import=jaraco.context \
|
||||
--hidden-import=jaraco.text \
|
||||
--hidden-import=jaraco.functools \
|
||||
--name ${{ env.APP_NAME }} \
|
||||
src/main.py
|
||||
|
||||
- name: Build AppImage (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
shell: bash
|
||||
run: scripts/build_appimage.sh
|
||||
|
||||
- name: Build with PyInstaller (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
shell: bash
|
||||
run: |
|
||||
pyinstaller --windowed \
|
||||
--add-data "build_info.json:." \
|
||||
--exclude-module PyQt6 \
|
||||
--exclude-module PyQt5 \
|
||||
--hidden-import=backports.tarfile \
|
||||
--hidden-import=backports \
|
||||
--hidden-import=jaraco.context \
|
||||
--hidden-import=jaraco.text \
|
||||
--hidden-import=jaraco.functools \
|
||||
--name ${{ env.APP_NAME }} \
|
||||
src/main.py
|
||||
|
||||
- name: Install create-dmg (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install create-dmg
|
||||
|
||||
- name: Stage artifact
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dist-final
|
||||
if [ "$RUNNER_OS" == "Windows" ]; then
|
||||
mv nuitka-build/main.dist dist-final/${{ env.APP_NAME }}
|
||||
elif [ "$RUNNER_OS" == "Linux" ]; then
|
||||
chmod +x dist/${{ env.APP_NAME }}
|
||||
mv dist/${{ env.APP_NAME }} dist-final/${{ matrix.artifact_name }}
|
||||
elif [ "$RUNNER_OS" == "macOS" ]; then
|
||||
create-dmg \
|
||||
--volname "${{ env.APP_NAME }} Test" \
|
||||
--window-pos 200 120 \
|
||||
--window-size 600 300 \
|
||||
--icon-size 100 \
|
||||
--icon "${{ env.APP_NAME }}.app" 150 150 \
|
||||
--hide-extension "${{ env.APP_NAME }}.app" \
|
||||
--app-drop-link 450 150 \
|
||||
"dist-final/${{ matrix.artifact_name }}.dmg" \
|
||||
"dist/"
|
||||
fi
|
||||
ls -la dist-final/
|
||||
|
||||
- name: Create ZIP (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
run: |
|
||||
Compress-Archive -Path "dist-final/${{ env.APP_NAME }}/*" -DestinationPath "dist-final/${{ matrix.artifact_name }}.zip"
|
||||
|
||||
- name: Upload artifact (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: dist-final/${{ matrix.artifact_name }}.zip
|
||||
retention-days: 7
|
||||
|
||||
- name: Upload artifact (Linux/macOS)
|
||||
if: runner.os != 'Windows'
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: ${{ matrix.os }}-build
|
||||
path: ${{ matrix.artifact_paths }}
|
||||
retention-days: 7
|
||||
@@ -143,6 +143,7 @@ venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
.python-version
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
@@ -217,4 +218,7 @@ __marimo__/
|
||||
|
||||
# Local build files
|
||||
build-local.ps1
|
||||
build-local.bat
|
||||
build-local.bat
|
||||
|
||||
# UV
|
||||
uv.lock
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
# SoftwareManager
|
||||
SoftwareManager is a Python-based GUI tool that simplifies searching and downloading software from various sources, including Rutracker, Uztracker and the official M0nkrus Telegram channel.
|
||||
SoftwareManager is a Python-based GUI tool that simplifies searching and downloading software from various sources, including Rutracker, Uztracker, Steamrip and the official M0nkrus Telegram channel.
|
||||
|
||||
> [!NOTE]
|
||||
> Our Steamrip implementation is currently very experimental and potentially unstable.<br>
|
||||
> Downloads will fail if there's no BuzzHeavier download available. We're working on this.
|
||||
|
||||
## Features
|
||||
- Searching & Downloading Software from various pages
|
||||
@@ -35,23 +39,21 @@ SoftwareManager is a Python-based GUI tool that simplifies searching and downloa
|
||||
## Python Dependencies
|
||||
(also included in requirements.txt)
|
||||
|
||||
```bash
|
||||
requests (2.32.2)
|
||||
PySide6 (6.10.1)
|
||||
beautifulsoup (44.13.5)
|
||||
<!-- python-dependencies:start -->
|
||||
```text
|
||||
requests (2.34.2)
|
||||
PySide6-Essentials (6.11.1)
|
||||
beautifulsoup4 (4.14.3)
|
||||
darkdetect (0.7.1)
|
||||
pyinstaller (6.15.0)
|
||||
PyQtDarkTheme-fork (2.3.4)
|
||||
aiohttp (3.13.0)
|
||||
pyinstaller (6.20.0)
|
||||
PyQtDarkTheme-fork (2.3.6)
|
||||
plyer (2.1.0)
|
||||
psutil (7.1.0)
|
||||
psutil (7.2.2)
|
||||
libtorrent (2.0.11)
|
||||
libtorrent-windows-dll (0.0.3)
|
||||
send2trash (2.1.0)
|
||||
```
|
||||
|
||||
## Activity
|
||||
|
||||

|
||||
<!-- python-dependencies:end -->
|
||||
|
||||
## Star History
|
||||
|
||||
@@ -63,12 +65,5 @@ SoftwareManager is a Python-based GUI tool that simplifies searching and downloa
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## Contributors
|
||||
<a href="https://github.com/KeksPirates/SoftwareManager/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=KeksPirates/SoftwareManager" />
|
||||
</a>
|
||||
|
||||
---
|
||||
|
||||
**Disclaimer:** SoftwareManager is intended for legal and ethical use only. Ensure compliance with applicable laws and regulations when using this tool.
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Name=SoftwareManager
|
||||
Type=Application
|
||||
Exec=python3 -m SoftwareManager
|
||||
Icon=softwaremanager
|
||||
Terminal=false
|
||||
Categories=X-Software;X-Torrents;
|
||||
@@ -0,0 +1 @@
|
||||
/* /index.html 200
|
||||
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 387 B |
|
After Width: | Height: | Size: 874 B |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 5.3 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 354 B |
|
After Width: | Height: | Size: 328 B |
|
After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,164 @@
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="100%" viewBox="0 0 1080 1080" enable-background="new 0 0 1080 1080" xml:space="preserve">
|
||||
<path fill="#0F1011" opacity="1.000000" stroke="none"
|
||||
d="
|
||||
M521.000000,1081.000000
|
||||
C347.353302,1081.000000 174.206635,1081.000000 1.029974,1081.000000
|
||||
C1.029974,721.061523 1.029974,361.123047 1.029974,1.092287
|
||||
C360.896912,1.092287 720.793823,1.092287 1080.845459,1.092287
|
||||
C1080.845459,360.999939 1080.845459,720.999939 1080.845459,1081.000000
|
||||
C894.455872,1081.000000 707.977966,1081.000000 521.000000,1081.000000
|
||||
M771.071899,705.499756
|
||||
C771.071899,712.255066 771.071899,719.010376 771.071899,725.787720
|
||||
C805.189453,725.787720 838.433228,725.787720 871.982117,725.787720
|
||||
C871.982117,724.198059 871.977478,722.893738 871.982788,721.589417
|
||||
C872.346375,632.439392 872.695801,543.289307 873.087097,454.139404
|
||||
C873.170105,435.232727 871.615662,416.554352 865.875427,398.414978
|
||||
C858.416626,374.845428 844.322693,357.740814 819.539062,351.179382
|
||||
C805.065430,347.347504 790.354187,346.688232 775.438110,347.469025
|
||||
C750.713196,348.763275 732.227295,360.350342 718.676453,380.598389
|
||||
C718.278503,381.193024 717.723083,381.682220 716.937561,382.559540
|
||||
C709.229492,367.323395 697.124634,357.854065 681.894958,352.343658
|
||||
C665.384827,346.369873 648.342102,345.949188 631.127563,348.544525
|
||||
C609.201660,351.850128 593.294556,363.158142 584.295227,383.689392
|
||||
C584.085876,384.167084 583.666626,384.552765 582.629456,385.936188
|
||||
C582.629456,375.268921 582.432129,365.801147 582.718811,356.348022
|
||||
C582.848083,352.084778 581.346741,351.035767 577.272949,351.057037
|
||||
C547.943848,351.210297 518.613159,351.214417 489.284210,351.052094
|
||||
C485.226227,351.029633 484.222809,352.337158 484.225586,356.220917
|
||||
C484.313141,477.873199 484.316132,599.525513 484.215637,721.177795
|
||||
C484.212280,725.235718 485.524109,726.174438 489.373871,726.155457
|
||||
C518.869690,726.010193 548.366516,726.078369 577.863037,726.066772
|
||||
C579.177673,726.066284 580.492310,725.937317 582.294312,725.842590
|
||||
C582.411072,723.590027 582.615479,721.483276 582.615906,719.376587
|
||||
C582.632019,635.053223 582.624939,550.729797 582.642700,466.406403
|
||||
C582.643616,461.909119 582.601562,457.391998 582.984192,452.918732
|
||||
C583.783752,443.573364 585.594788,434.427887 590.720276,426.362396
|
||||
C595.334778,419.101013 603.568298,416.113373 612.510742,417.573242
|
||||
C621.158325,418.984924 623.718262,425.447479 624.800415,432.537415
|
||||
C625.976135,440.240509 626.601562,448.102905 626.612244,455.896973
|
||||
C626.732483,544.053101 626.723267,632.209473 626.589661,720.365601
|
||||
C626.582764,724.927246 627.708862,726.224487 632.373047,726.189392
|
||||
C662.034485,725.965820 691.698547,726.080139 721.361694,726.064453
|
||||
C723.113525,726.063538 724.865234,725.900635 726.957336,725.796082
|
||||
C726.957336,723.243530 726.957275,721.268250 726.957275,719.292969
|
||||
C726.957458,632.803162 726.968445,546.313354 726.944214,459.823578
|
||||
C726.941223,449.239441 728.039978,438.887451 732.563599,429.153198
|
||||
C736.859009,419.910126 744.395264,415.290436 753.561279,416.237335
|
||||
C761.562256,417.063873 766.880310,422.073700 768.930908,432.236359
|
||||
C770.302734,439.034576 770.973572,446.088562 770.984680,453.029663
|
||||
C771.119019,536.852905 771.071838,620.676392 771.071899,705.499756
|
||||
M449.075165,578.388550
|
||||
C444.612366,569.698914 440.983704,560.440002 435.519684,552.433716
|
||||
C422.667145,533.601379 405.276215,519.323669 386.430817,506.766174
|
||||
C366.624786,493.568573 346.812805,480.379791 326.987457,467.211212
|
||||
C314.718567,459.061859 309.375153,447.642090 310.893677,433.049744
|
||||
C311.652100,425.761383 316.614258,420.448883 323.722198,418.931366
|
||||
C336.829163,416.133026 345.032623,421.241791 347.777405,435.303497
|
||||
C349.323212,443.222870 349.245270,451.509369 349.353851,459.637756
|
||||
C349.407593,463.659760 350.698944,464.717834 354.566010,464.701935
|
||||
C385.891083,464.572968 417.217163,464.573364 448.542236,464.702332
|
||||
C452.329407,464.717926 453.572510,463.488739 453.266174,459.803009
|
||||
C452.384766,449.198700 452.532043,438.436707 450.768219,427.991089
|
||||
C444.826935,392.805817 425.563995,368.149658 391.467346,356.014587
|
||||
C368.493378,347.838104 344.665100,346.136963 320.550812,347.517151
|
||||
C298.078491,348.803314 276.322418,353.354095 256.360260,364.197845
|
||||
C234.918915,375.845093 218.772064,392.192810 212.586060,416.625000
|
||||
C208.628387,432.256226 209.851181,448.018677 211.980621,463.773712
|
||||
C214.293564,480.886322 220.373398,496.450378 232.494080,508.880341
|
||||
C240.825806,517.424622 249.784256,525.541809 259.346588,532.662842
|
||||
C277.899567,546.479004 297.228271,559.249084 315.920227,572.884949
|
||||
C323.821167,578.648682 331.598694,584.875366 338.252686,591.994324
|
||||
C352.762024,607.517578 353.500397,626.342834 348.726654,645.805786
|
||||
C347.404053,651.198242 343.621399,655.271973 337.821289,656.412048
|
||||
C326.377319,658.661499 313.006104,655.729919 310.746490,639.654663
|
||||
C310.376984,637.025940 310.029877,634.371582 309.983185,631.723572
|
||||
C309.739258,617.897644 309.606567,604.069824 309.398712,590.243225
|
||||
C309.379883,588.990479 309.101746,587.741699 308.962982,586.641174
|
||||
C275.449921,586.641174 242.367004,586.641174 209.156891,586.641174
|
||||
C208.767090,607.270203 207.222519,627.571594 211.066406,647.744202
|
||||
C218.104706,684.681030 238.296249,710.625732 274.680664,722.063477
|
||||
C311.032318,733.490845 347.949768,733.707153 384.363068,722.701538
|
||||
C417.519196,712.680542 441.096252,691.563110 450.703888,657.418823
|
||||
C458.037323,631.356812 457.330383,605.098694 449.075165,578.388550
|
||||
z"/>
|
||||
<path fill="#F7AAF8" opacity="1.000000" stroke="none"
|
||||
d="
|
||||
M771.071899,704.999817
|
||||
C771.071838,620.676392 771.119019,536.852905 770.984680,453.029663
|
||||
C770.973572,446.088562 770.302734,439.034576 768.930908,432.236359
|
||||
C766.880310,422.073700 761.562256,417.063873 753.561279,416.237335
|
||||
C744.395264,415.290436 736.859009,419.910126 732.563599,429.153198
|
||||
C728.039978,438.887451 726.941223,449.239441 726.944214,459.823578
|
||||
C726.968445,546.313354 726.957458,632.803162 726.957275,719.292969
|
||||
C726.957275,721.268250 726.957336,723.243530 726.957336,725.796082
|
||||
C724.865234,725.900635 723.113525,726.063538 721.361694,726.064453
|
||||
C691.698547,726.080139 662.034485,725.965820 632.373047,726.189392
|
||||
C627.708862,726.224487 626.582764,724.927246 626.589661,720.365601
|
||||
C626.723267,632.209473 626.732483,544.053101 626.612244,455.896973
|
||||
C626.601562,448.102905 625.976135,440.240509 624.800415,432.537415
|
||||
C623.718262,425.447479 621.158325,418.984924 612.510742,417.573242
|
||||
C603.568298,416.113373 595.334778,419.101013 590.720276,426.362396
|
||||
C585.594788,434.427887 583.783752,443.573364 582.984192,452.918732
|
||||
C582.601562,457.391998 582.643616,461.909119 582.642700,466.406403
|
||||
C582.624939,550.729797 582.632019,635.053223 582.615906,719.376587
|
||||
C582.615479,721.483276 582.411072,723.590027 582.294312,725.842590
|
||||
C580.492310,725.937317 579.177673,726.066284 577.863037,726.066772
|
||||
C548.366516,726.078369 518.869690,726.010193 489.373871,726.155457
|
||||
C485.524109,726.174438 484.212280,725.235718 484.215637,721.177795
|
||||
C484.316132,599.525513 484.313141,477.873199 484.225586,356.220917
|
||||
C484.222809,352.337158 485.226227,351.029633 489.284210,351.052094
|
||||
C518.613159,351.214417 547.943848,351.210297 577.272949,351.057037
|
||||
C581.346741,351.035767 582.848083,352.084778 582.718811,356.348022
|
||||
C582.432129,365.801147 582.629456,375.268921 582.629456,385.936188
|
||||
C583.666626,384.552765 584.085876,384.167084 584.295227,383.689392
|
||||
C593.294556,363.158142 609.201660,351.850128 631.127563,348.544525
|
||||
C648.342102,345.949188 665.384827,346.369873 681.894958,352.343658
|
||||
C697.124634,357.854065 709.229492,367.323395 716.937561,382.559540
|
||||
C717.723083,381.682220 718.278503,381.193024 718.676453,380.598389
|
||||
C732.227295,360.350342 750.713196,348.763275 775.438110,347.469025
|
||||
C790.354187,346.688232 805.065430,347.347504 819.539062,351.179382
|
||||
C844.322693,357.740814 858.416626,374.845428 865.875427,398.414978
|
||||
C871.615662,416.554352 873.170105,435.232727 873.087097,454.139404
|
||||
C872.695801,543.289307 872.346375,632.439392 871.982788,721.589417
|
||||
C871.977478,722.893738 871.982117,724.198059 871.982117,725.787720
|
||||
C838.433228,725.787720 805.189453,725.787720 771.071899,725.787720
|
||||
C771.071899,719.010376 771.071899,712.255066 771.071899,704.999817
|
||||
z"/>
|
||||
<path fill="#F7AAF8" opacity="1.000000" stroke="none"
|
||||
d="
|
||||
M449.203979,578.762207
|
||||
C457.330383,605.098694 458.037323,631.356812 450.703888,657.418823
|
||||
C441.096252,691.563110 417.519196,712.680542 384.363068,722.701538
|
||||
C347.949768,733.707153 311.032318,733.490845 274.680664,722.063477
|
||||
C238.296249,710.625732 218.104706,684.681030 211.066406,647.744202
|
||||
C207.222519,627.571594 208.767090,607.270203 209.156891,586.641174
|
||||
C242.367004,586.641174 275.449921,586.641174 308.962982,586.641174
|
||||
C309.101746,587.741699 309.379883,588.990479 309.398712,590.243225
|
||||
C309.606567,604.069824 309.739258,617.897644 309.983185,631.723572
|
||||
C310.029877,634.371582 310.376984,637.025940 310.746490,639.654663
|
||||
C313.006104,655.729919 326.377319,658.661499 337.821289,656.412048
|
||||
C343.621399,655.271973 347.404053,651.198242 348.726654,645.805786
|
||||
C353.500397,626.342834 352.762024,607.517578 338.252686,591.994324
|
||||
C331.598694,584.875366 323.821167,578.648682 315.920227,572.884949
|
||||
C297.228271,559.249084 277.899567,546.479004 259.346588,532.662842
|
||||
C249.784256,525.541809 240.825806,517.424622 232.494080,508.880341
|
||||
C220.373398,496.450378 214.293564,480.886322 211.980621,463.773712
|
||||
C209.851181,448.018677 208.628387,432.256226 212.586060,416.625000
|
||||
C218.772064,392.192810 234.918915,375.845093 256.360260,364.197845
|
||||
C276.322418,353.354095 298.078491,348.803314 320.550812,347.517151
|
||||
C344.665100,346.136963 368.493378,347.838104 391.467346,356.014587
|
||||
C425.563995,368.149658 444.826935,392.805817 450.768219,427.991089
|
||||
C452.532043,438.436707 452.384766,449.198700 453.266174,459.803009
|
||||
C453.572510,463.488739 452.329407,464.717926 448.542236,464.702332
|
||||
C417.217163,464.573364 385.891083,464.572968 354.566010,464.701935
|
||||
C350.698944,464.717834 349.407593,463.659760 349.353851,459.637756
|
||||
C349.245270,451.509369 349.323212,443.222870 347.777405,435.303497
|
||||
C345.032623,421.241791 336.829163,416.133026 323.722198,418.931366
|
||||
C316.614258,420.448883 311.652100,425.761383 310.893677,433.049744
|
||||
C309.375153,447.642090 314.718567,459.061859 326.987457,467.211212
|
||||
C346.812805,480.379791 366.624786,493.568573 386.430817,506.766174
|
||||
C405.276215,519.323669 422.667145,533.601379 435.519684,552.433716
|
||||
C440.983704,560.440002 444.612366,569.698914 449.203979,578.762207
|
||||
z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 57 KiB |
|
After Width: | Height: | Size: 57 KiB |
@@ -0,0 +1,324 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" style="background:#0f1011">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Simply search and download software and games from various sources. Developed with ❤︎ by KeksPirates.">
|
||||
<meta name="darkreader-lock">
|
||||
<link rel="stylesheet" href="main.css"/>
|
||||
<title>SoftwareManager - Simply search and download software from various sources</title>
|
||||
<!-- <link rel="icon" type="image/x-icon" href="/assets/icons/favicon.ico"> -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;700&display=swap" rel="stylesheet">
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicon/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="192x192" href="assets/favicon/android-chrome-192x192.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon/favicon-16x16.png">
|
||||
|
||||
<!-- Open Graph / Discord Embed -->
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:title" content="SoftwareManager">
|
||||
<meta property="og:description" content="Simply search and download software.">
|
||||
<meta property="og:image" content="https://softwaremanager.xyz/assets/logos/softwaremanager-logo-200px.png">
|
||||
<meta property="og:url" content="https://softwaremanager.xyz/">
|
||||
<meta property="og:site_name" content="KeksPirates">
|
||||
<meta name="theme-color" content="#db65d5">
|
||||
|
||||
<!-- Twitter Card -->
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="SoftwareManager">
|
||||
<meta name="twitter:description" content="Simply search and download software from various sources">
|
||||
<meta name="twitter:image" content="https://softwaremanager.xyz/assets/logos/softwaremanager-logo-200px.png">
|
||||
</head>
|
||||
|
||||
|
||||
|
||||
<body style="opacity:0">
|
||||
<header>
|
||||
<div class="logo-text">
|
||||
<h1>KeksPirates</h1>
|
||||
</div>
|
||||
<nav class="tab">
|
||||
<a class="tablinks" onclick="openTab(event, 'start')" id="navHome">Home</a>
|
||||
<a class="tablinks" onclick="openTab(event, 'api')" id="navApi">API</a>
|
||||
<a class="tablinks" onclick="openTab(event, 'docs')" id="navDocs">Docs</a>
|
||||
<a class="tablinks" id="navVst" href="https://vstsearch.softwaremanager.xyz">VST Search</a>
|
||||
<!-- <a class="tablinks" onclick="openTab(event, 'notfound')">404</a> -->
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
|
||||
|
||||
|
||||
<main>
|
||||
|
||||
<div id="start" class="tabcontent">
|
||||
<div class="introduction-frame">
|
||||
<div class="introduction-text inline-block">
|
||||
<h1 class="hometitle"><br><span style="color: #db65d5">SoftwareManager</span></h1>
|
||||
<p class="title_subtext">Simply search and download software from various sources</p>
|
||||
|
||||
<a href="https://github.com/KeksPirates/SoftwareManager" class="btn_big github"><img class="github-button" src="assets/icons/GitHub_Invertocat_White.png">GitHub</a>
|
||||
<a href="https://github.com/KeksPirates/SoftwareManager/releases/latest" class="btn_big download"><img class="download-button" src="assets/icons/download_icon_black.png">Download</a>
|
||||
</div>
|
||||
<div class="introduction-image inline-block">
|
||||
<div class="softwaremanager-scene">
|
||||
<img class="softwaremanager-image" src="assets/softwaremanager/search_tab_rounded.png">
|
||||
</div>
|
||||
|
||||
<img class="softwaremanager-image-2" src="assets/softwaremanager/search_tab_rounded.png">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="api" class="tabcontent">
|
||||
|
||||
<h1 class="title"><span class="json-string">API Documentation</span> </h1>
|
||||
<p>This API allows you to search for posts on rutracker.</p>
|
||||
|
||||
<div class="base-information-frame">
|
||||
<h3>API URL</h3>
|
||||
<p class="api-url">https://api.michijackson.xyz/</p>
|
||||
<br>
|
||||
<h3>Endpoint</h3>
|
||||
<p class="endpoint-url"><span class="request-type">GET</span><span class="endpoint-type-container">/search?q=<span class="endpoint-parameter">{query}</span></span></p>
|
||||
|
||||
<div class="endpoint-parameters-container">
|
||||
<div class="endpoint-parameters-header">
|
||||
<p>Parameter</p>
|
||||
<p>Type</p>
|
||||
<p>Required</p>
|
||||
<p>Description</p>
|
||||
</div>
|
||||
<div class="endpoint-parameters-content">
|
||||
<p class="endpoint-parameter">q</p>
|
||||
<p class="endpoint-type">String</p>
|
||||
<p class="endpoint-required">True</p>
|
||||
<p class="endpoint-description">Search query</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="request-frame">
|
||||
<h2>Example Request</h2>
|
||||
<div class="request-type-container">
|
||||
<p><span class="request-type">GET</span> <span class="request-type-subcontainer">api.michijackson.xyz/search?q=keks</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="api-response-frame">
|
||||
<h3>Response</h3>
|
||||
|
||||
<pre class="api-response"><span class="json-punctuation">{</span>
|
||||
"cached"<span class="json-punctuation">:</span> <span class="json-boolean">false</span><span class="json-punctuation">,</span>
|
||||
"count"<span class="json-punctuation">:</span> <span class="json-integer">1</span><span class="json-punctuation">,</span>
|
||||
"data"<span class="json-punctuation">:</span> <span class="json-punctuation">[</span>
|
||||
<span class="json-punctuation">{</span>
|
||||
"author"<span class="json-punctuation">:</span> <span class="json-string">"Viterrson"</span><span class="json-punctuation">,</span>
|
||||
"id"<span class="json-punctuation">:</span> <span class="json-integer">1</span><span class="json-punctuation">,</span>
|
||||
"leechers"<span class="json-punctuation">:</span> <span class="json-integer">0</span><span class="json-punctuation">,</span>
|
||||
"seeders"<span class="json-punctuation">:</span> <span class="json-integer">3</span><span class="json-punctuation">,</span>
|
||||
"title"<span class="json-punctuation">:</span> <span class="json-string">"(Hard - Rock) Keks - Keks - 1983, MP3, 320 kbps"</span><span class="json-punctuation">,</span>
|
||||
"url"<span class="json-punctuation">:</span> <span class="json-string">"https://rutracker.org/forum/viewtopic.php?t=3835559"</span>
|
||||
<span class="json-punctuation">}</span>
|
||||
<span class="json-punctuation">],</span>
|
||||
"query"<span class="json-punctuation">:</span> <span class="json-string">"keks"</span><span class="json-punctuation">,</span>
|
||||
"success"<span class="json-punctuation">:</span> <span class="json-boolean">true</span>
|
||||
<span class="json-punctuation">}</span></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="docs" class="tabcontent">
|
||||
<h1 class="title"><span style="color: #db65d5">Docs</span></h1>
|
||||
<p>SoftwareManager is a desktop app to search, browse, and download software & games from multiple sources in one place.</p>
|
||||
<div class="base-information-frame">
|
||||
<h2>Features</h2>
|
||||
<div class="endpoint-parameters-container docs-tips">
|
||||
<p class="sources-text">• Searching & Downloading Software from various pages</p>
|
||||
<p class="sources-text">• Network Interface Binding</p>
|
||||
<p class="sources-text">• Simple UI, Speed Limiting etc.</p>
|
||||
<p class="sources-text">• No Logins required</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="base-information-frame">
|
||||
<h2>General Information</h2>
|
||||
<div class="endpoint-parameters-container docs-tips">
|
||||
<p class="sources-text">• Rutracker is the default source since it is the largest index overall.</p>
|
||||
<p class="sources-text">• Use m0nkrus if you want Adobe software, it directly gets the posts from his Telegram channel.</p>
|
||||
<p class="sources-text">• Torrents start seeding after completion and start seeding on application start.</p>
|
||||
<p class="sources-text">• MacOS Builds haven't been properly tested - We're thankful to receive feedback.</p>
|
||||
<p class="sources-text">• If you want to host your own server, clone our <a href="https://github.com/KeksPirates/SoftwareManager-Server" style="color: #db65d5;">server repository</a>, enter your cookie for rutracker.org and run server.py. Detailed Instructions on how to get your rutracker cookie are in the README of the server repo.</p>
|
||||
<p class="sources-text">• SoftwareManager is still in development and most likely contains issues. Please report any bugs you find via GitHub. Contributions are also greatly appreciated.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="base-information-frame">
|
||||
<h2>Sources</h2>
|
||||
<br>
|
||||
<p>Use the dropdown menu in the top right to select your source.</p>
|
||||
<div class="endpoint-parameters-container docs-grid">
|
||||
<div class="endpoint-parameters-header">
|
||||
<p>Source</p>
|
||||
<p>Category</p>
|
||||
<p>Notes</p>
|
||||
</div>
|
||||
<div class="endpoint-parameters-content">
|
||||
<p class="sources-text">RuTracker</p>
|
||||
<p class="sources-text">Software & games</p>
|
||||
<p class="sources-text">Has an extremely large amount of Software. Relies on an API for searching.</p>
|
||||
</div>
|
||||
<div class="endpoint-parameters-content">
|
||||
<p class="sources-text">UzTracker</p>
|
||||
<p class="sources-text">Software & games</p>
|
||||
<p class="sources-text">Similar to RuTracker, smaller. Use this as fallback if RuTracker is down or there's API issues.</p>
|
||||
</div>
|
||||
<div class="endpoint-parameters-content">
|
||||
<p class="sources-text">m0nkrus</p>
|
||||
<p class="sources-text">Adobe Software</p>
|
||||
<p class="sources-text">Lots of curated releases. Focused on mainly professional Software.</p>
|
||||
</div>
|
||||
<div class="endpoint-parameters-content">
|
||||
<p class="sources-text">SteamRip</p>
|
||||
<p class="sources-text">Games</p>
|
||||
<p class="sources-text">Currently very experimental due to download link retrieval. May not always work as expected.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="vstsearch" class="tabcontent">
|
||||
<div class="cse-search">
|
||||
<h3 class="vst-logo"><span style="color: #db65d5">VST Search</span></h3>
|
||||
<div class="gcse-searchbox"></div>
|
||||
|
||||
<div class="gcse-searchresults"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="notfound" class="tabcontent">
|
||||
<div class="notfound-frame">
|
||||
<h1 class="notfound-title">404</h1>
|
||||
<br>
|
||||
<h1 class="notfound-subtext">(╯°□°)╯︵ ┻━┻</h1>
|
||||
<a class="btn_big download" onclick="openTab(event, 'start')" style="cursor: pointer;">Go Home</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<small>KeksPirates - SoftwareManager</small>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
const MAIN_ORIGIN = 'https://softwaremanager.xyz';
|
||||
const VST_ORIGIN = 'https://vstsearch.softwaremanager.xyz';
|
||||
const onVstDomain = window.location.hostname.startsWith('vstsearch.');
|
||||
|
||||
let cseLoaded = false;
|
||||
function loadCSE() {
|
||||
if (cseLoaded) return;
|
||||
cseLoaded = true;
|
||||
var s = document.createElement('script');
|
||||
s.async = true;
|
||||
s.src = 'https://cse.google.com/cse.js?cx=e7334cef72a8b42e7';
|
||||
document.head.appendChild(s);
|
||||
}
|
||||
|
||||
function openTab(evt, tabName, pushToHistory = true) {
|
||||
var i, tabcontent, tablinks;
|
||||
|
||||
tabcontent = document.getElementsByClassName("tabcontent");
|
||||
for (i = 0; i < tabcontent.length; i++) {
|
||||
tabcontent[i].style.display = "none";
|
||||
}
|
||||
|
||||
tablinks = document.getElementsByClassName("tablinks");
|
||||
for (i = 0; i < tablinks.length; i++) {
|
||||
tablinks[i].className = tablinks[i].className.replace(" active", "");
|
||||
}
|
||||
|
||||
var target = document.getElementById(tabName);
|
||||
target.style.display = "block";
|
||||
|
||||
if (tabName === 'vstsearch') loadCSE();
|
||||
// restart animation
|
||||
target.classList.remove('tab-animate');
|
||||
void target.offsetWidth;
|
||||
target.classList.add('tab-animate');
|
||||
|
||||
let activeButton = document.querySelector(`.tablinks[onclick*="${tabName}"]`);
|
||||
if (activeButton) {
|
||||
activeButton.className += " active";
|
||||
}
|
||||
|
||||
if (pushToHistory) {
|
||||
let path = "/";
|
||||
if (tabName === 'api') path = "/api";
|
||||
if (tabName === 'docs') path = "/docs";
|
||||
|
||||
history.pushState({ tab: tabName }, "", path);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('popstate', function(event) {
|
||||
if (event.state && event.state.tab) {
|
||||
openTab(null, event.state.tab, false);
|
||||
} else {
|
||||
openTab(null, 'start', false);
|
||||
}
|
||||
});
|
||||
|
||||
// Determine the correct tab immediately (before full load) to prevent flash
|
||||
(function() {
|
||||
if (onVstDomain) {
|
||||
document.getElementById('vstsearch').style.display = 'block';
|
||||
return;
|
||||
}
|
||||
let currentPath = window.location.pathname;
|
||||
let tabName = 'start';
|
||||
if (currentPath === '/api') tabName = 'api';
|
||||
else if (currentPath === '/docs') tabName = 'docs';
|
||||
else if (currentPath !== '/') tabName = 'notfound';
|
||||
// Show only the correct tab right away
|
||||
document.getElementById(tabName).style.display = 'block';
|
||||
})();
|
||||
|
||||
window.onload = function() {
|
||||
if (onVstDomain) {
|
||||
document.getElementById('navHome').href = MAIN_ORIGIN + '/';
|
||||
document.getElementById('navApi').href = MAIN_ORIGIN + '/api';
|
||||
document.getElementById('navDocs').href = MAIN_ORIGIN + '/docs';
|
||||
['navHome', 'navApi', 'navDocs'].forEach(function(id) {
|
||||
document.getElementById(id).removeAttribute('onclick');
|
||||
});
|
||||
openTab(null, 'vstsearch', false);
|
||||
document.getElementById('navVst').className += " active";
|
||||
return;
|
||||
}
|
||||
|
||||
let currentPath = window.location.pathname;
|
||||
|
||||
if (currentPath === '/vstsearch') {
|
||||
window.location.replace(VST_ORIGIN);
|
||||
} else if (currentPath === '/api') {
|
||||
openTab(null, 'api', false);
|
||||
} else if (currentPath === '/docs') {
|
||||
openTab(null, 'docs', false);
|
||||
} else if (currentPath === '/') {
|
||||
history.replaceState({ tab: 'start' }, "", "/");
|
||||
openTab(null, 'start', false);
|
||||
} else {
|
||||
openTab(null, 'notfound', false);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,576 @@
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
:root {
|
||||
--main-font: "Manrope", sans-serif;
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
font-family: system-ui, sans-serif;
|
||||
line-height: 1.5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
background: #0f1011;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
|
||||
header {
|
||||
height: 65px;
|
||||
background: #1a1c1d;
|
||||
color: #fff;
|
||||
padding: 1rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.tab a {
|
||||
display: inline-block;
|
||||
padding: 0.4rem 0.8rem;
|
||||
margin-left: 0.5rem;
|
||||
text-decoration: none;
|
||||
color: #fafafa;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 6px 1px #dd06cb00;
|
||||
font-family: var(--main-font);
|
||||
transition: background 0.5s, color 0.5s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
nav a:hover {
|
||||
background: #db65d517;
|
||||
color: #ffd1fd;
|
||||
}
|
||||
|
||||
nav a.active {
|
||||
background: #db65d55d;
|
||||
color: #fdd2fc;
|
||||
}
|
||||
|
||||
.logo-text h1 {
|
||||
font-family: var(--main-font);
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
background-image: linear-gradient(147deg, #da84d5, #db65d5);
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
main {
|
||||
font-family: var(--main-font);
|
||||
color: #fafafa;
|
||||
padding: 3rem;
|
||||
}
|
||||
|
||||
/* Hide all tabs by default to prevent flash on page load */
|
||||
.tabcontent {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Tab switch animation */
|
||||
@keyframes tabFadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(8px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.tabcontent.tab-animate {
|
||||
animation: tabFadeIn 0.3s ease-out forwards;
|
||||
}
|
||||
|
||||
main h1.hometitle {
|
||||
font-size: 4.0rem;
|
||||
line-height: 4rem;
|
||||
margin-top: 1.8rem;
|
||||
}
|
||||
|
||||
main p.title_subtext {
|
||||
margin-top: 0.5rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.softwaremanager-scene {
|
||||
perspective: 700px;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
main img.softwaremanager-image {
|
||||
margin-top: 0rem;
|
||||
user-select: none;
|
||||
transform: rotateX(8deg) rotateY(-12deg) rotateZ(2deg) scale(0.85) translateX(-1rem);
|
||||
box-shadow: 15px 20px 15px #0f0f0f;
|
||||
|
||||
/* transition: transform 0.4s ease-out; */
|
||||
}
|
||||
|
||||
/* main img.softwaremanager-image:hover {
|
||||
transform: rotateX(8deg) rotateY(-13deg) rotateZ(2deg) scale(0.86) translateX(-1rem);
|
||||
} */
|
||||
|
||||
/* transform: rotateX(8443deg) rotateY(-14234233deg) rotateZ(2deg) scale(4.863) translateX(-133rem); lmao */
|
||||
|
||||
main .introduction-text {
|
||||
position: relative;
|
||||
text-align: right;
|
||||
margin-right: -3rem;
|
||||
margin-top: 3rem;
|
||||
z-index: 2;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.introduction-image {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.inline-block {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
main .introduction-frame {
|
||||
text-align: center;
|
||||
position: relative;
|
||||
font-size: 0
|
||||
}
|
||||
|
||||
main .introduction-frame > * {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
main .btn_big {
|
||||
font-family: var(--main-font);
|
||||
background: #1a1c1d;
|
||||
padding: 0.7rem 1.4rem;
|
||||
margin-top: 1.5rem;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
color: #fafafa;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
main .btn_big img {
|
||||
height: 20px;
|
||||
width: auto;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
main .btn_big.github {
|
||||
margin-right: 1rem;
|
||||
transition: background 0.5s;
|
||||
}
|
||||
|
||||
main .btn_big.github:hover {
|
||||
background: #18191a;
|
||||
}
|
||||
|
||||
main .btn_big.download {
|
||||
background: #ca62c5;
|
||||
color: #0f1011;
|
||||
transition: background 0.5s;
|
||||
}
|
||||
|
||||
main .btn_big.download:hover {
|
||||
background: #b551b0;
|
||||
}
|
||||
|
||||
main .introduction-text h1,
|
||||
main .introduction-text p {
|
||||
user-select: text;
|
||||
}
|
||||
|
||||
|
||||
.softwaremanager-image-2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
footer {
|
||||
color: #585858;
|
||||
font-family: var(--main-font);
|
||||
align-self: center;
|
||||
padding: 1rem;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: #db65d528;
|
||||
}
|
||||
|
||||
.base-information-frame {
|
||||
background: #1a1c1d;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
.program-preview {
|
||||
box-sizing: inherit;
|
||||
background: #1a1c1d;
|
||||
width: auto;
|
||||
height: 20rem;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
pre.api-response {
|
||||
font-family: monospace;
|
||||
background: #151718;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.api-response-frame {
|
||||
background: #1a1c1d;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.request-type {
|
||||
color: #fdd2fc;
|
||||
padding: 1px 6px;
|
||||
background: #db65d55d;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.request-type-container {
|
||||
background: #1a1c1d;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.endpoint-type-container {
|
||||
background: #151718;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.request-type-subcontainer {
|
||||
background: #1a1c1d;
|
||||
padding: 0.5rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.api-url {
|
||||
background: #151718;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.endpoint-url {
|
||||
background: #151718;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
color: #8f8d8d
|
||||
}
|
||||
|
||||
.endpoint-parameters-container {
|
||||
background: #151718;
|
||||
padding: 1rem;
|
||||
border-radius: 10px;
|
||||
margin-top: 1rem;
|
||||
color: #8f8d8d;
|
||||
}
|
||||
|
||||
.endpoint-parameters-header {
|
||||
margin-top: -0.3rem;
|
||||
margin-bottom: 0.9rem;
|
||||
font-size: 0.9rem;
|
||||
grid-template-columns: 9rem 9rem 9rem 9rem;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.endpoint-parameters-content {
|
||||
font-size: 1rem;
|
||||
grid-template-columns: 9rem 9rem 9rem 9rem;
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.request-frame {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.endpoint-parameter { color: #ffab4a; }
|
||||
.endpoint-type { color: #db65d5 }
|
||||
.endpoint-required { color: #66ff80}
|
||||
.endpoint-description { color: #b1b0b0 }
|
||||
|
||||
.json-punctuation { color: #5c5c5c; }
|
||||
.json-string { color: #db65d5; }
|
||||
.json-boolean { color: #ffab4a; }
|
||||
.json-integer { color: #66ff80; }
|
||||
|
||||
.sources-text {
|
||||
color: #ffffff;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.docs-grid .endpoint-parameters-header,
|
||||
.docs-grid .endpoint-parameters-content {
|
||||
grid-template-columns: 10rem 14rem 1fr;
|
||||
}
|
||||
|
||||
.docs-grid .endpoint-parameters-header p {
|
||||
color: #8f8d8d;
|
||||
}
|
||||
|
||||
.docs-grid .endpoint-parameters-content {
|
||||
padding: 0.5rem 0;
|
||||
border-top: 1px solid #ffffff0a;
|
||||
}
|
||||
|
||||
.docs-grid .endpoint-parameters-content:first-of-type {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.docs-tips .sources-text {
|
||||
padding: 0.25rem 0;
|
||||
}
|
||||
|
||||
|
||||
.base-information-frame h2 {
|
||||
color: #db65d5;
|
||||
}
|
||||
|
||||
.notfound-frame {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 75vh;
|
||||
|
||||
text-align: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.notfound-title {
|
||||
font-size: 4.0rem;
|
||||
line-height: 4rem;
|
||||
margin-top: 1.8rem;
|
||||
background-image: linear-gradient(135deg, #c574c1, #b851b2);
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
.notfound-subtext {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.cse-search {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 70vh;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.cse-search .vst-logo {
|
||||
font-family: var(--main-font);
|
||||
font-size: 3.5rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
margin-bottom: 1.5rem;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.cse-search .gsc-control-cse,
|
||||
.cse-search .gsc-results-wrapper-overlay,
|
||||
.cse-search .gsc-results-wrapper-visible {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.cse-search .gsc-input-box,
|
||||
.cse-search .gsc-input-box.gsc-input-box-hover,
|
||||
.cse-search .gsc-input-box.gsc-input-box-focus {
|
||||
background: #1a1b1d !important;
|
||||
border-color: #1a1b1d !important;
|
||||
}
|
||||
|
||||
.cse-search .gsc-input,
|
||||
.cse-search input.gsc-input,
|
||||
.cse-search .gsib_a input.gsc-input {
|
||||
background: transparent !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.cse-search .gsib_a {
|
||||
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'><path fill-rule='evenodd' clip-rule='evenodd' d='M14.76 13.27L20.49 19L19 20.49L13.27 14.76C12.2 15.53 10.91 16 9.5 16C5.91 16 3 13.09 3 9.5C3 5.91 5.91 3 9.5 3C13.09 3 16 5.91 16 9.5C16 10.91 15.53 12.2 14.76 13.27ZM9.5 5C7.01 5 5 7.01 5 9.5C5 11.99 7.01 14 9.5 14C11.99 14 14 11.99 14 9.5C14 7.01 11.99 5 9.5 5Z' fill='%23ffffff'/></svg>") !important;
|
||||
}
|
||||
|
||||
.cse-search .gsc-search-button-v2 {
|
||||
background: #db65d5 !important;
|
||||
border-color: #db65d5 !important;
|
||||
}
|
||||
|
||||
.cse-search .gsc-search-button-v2:hover {
|
||||
background: #c94dc3 !important;
|
||||
border-color: #c94dc3 !important;
|
||||
}
|
||||
|
||||
.cse-search .gcsc-more-maybe-branding-root,
|
||||
.gcsc-find-more-on-google {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.gsc-completion-container,
|
||||
.gssb_c, .gssb_e,
|
||||
table.gssb_c, table.gssb_e {
|
||||
background: #1a1b1d !important;
|
||||
border-color: #333 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.gsc-completion-container td,
|
||||
.gsc-completion-container .gsc-completion-suggestion,
|
||||
.gssb_a, .gssb_a td, .gssb_i {
|
||||
background: #1a1b1d !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
.gsc-completion-container .gsc-completion-selected,
|
||||
.gsc-completion-container tr:hover td,
|
||||
.gssb_a:hover td, .gssb_e-hover {
|
||||
background: #2a2b2d !important;
|
||||
}
|
||||
|
||||
@media(max-width: 560px) {
|
||||
|
||||
header {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0rem;
|
||||
padding: 1rem;
|
||||
|
||||
}
|
||||
|
||||
main .introduction {
|
||||
display: block;
|
||||
margin-top: -1rem;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
main .introduction-text {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
margin-top: 0rem;
|
||||
z-index: 2;
|
||||
user-select: none;
|
||||
margin-right: 0rem;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
main h1.hometitle {
|
||||
font-size: 2rem;
|
||||
line-height: 2.2rem;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
main p.title_subtext {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.introduction-image {
|
||||
display: none;
|
||||
}
|
||||
|
||||
main .btn_big {
|
||||
display: block;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
|
||||
main .btn_big.github{
|
||||
margin-right: 0rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 561px) and (max-width: 1393px) {
|
||||
|
||||
header {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
main {
|
||||
margin: 0rem;
|
||||
padding: 1rem;
|
||||
|
||||
}
|
||||
|
||||
main .introduction {
|
||||
display: flex;
|
||||
margin-top: -1rem;
|
||||
padding: 1rem;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
main .introduction-text {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
margin-top: 0rem;
|
||||
z-index: 2;
|
||||
user-select: none;
|
||||
margin-left: 2rem;
|
||||
margin-right: 2rem;
|
||||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
main h1.hometitle {
|
||||
font-size: 2rem;
|
||||
line-height: 2.2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
main p.title_subtext {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.softwaremanager-image {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.softwaremanager-image-2 {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.introduction-image {
|
||||
width: 100%;
|
||||
max-width: 50rem;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
main .introduction .inline-block {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://softwaremanager.xyz/</loc>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>https://softwaremanager.xyz/api</loc>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
|
||||
<url>
|
||||
<loc>https://softwaremanager.xyz/docs</loc>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
</urlset>
|
||||
@@ -0,0 +1,55 @@
|
||||
// Cloudflare Pages middleware.
|
||||
//
|
||||
// Both softwaremanager.xyz and vstsearch.softwaremanager.xyz serve the same
|
||||
// index.html. Crawlers (Discord, Twitter, etc.) read the raw HTML and do NOT
|
||||
// run JavaScript, so we rewrite the <title> and Open Graph / Twitter meta tags
|
||||
// server-side when the request is for the VST Search subdomain. This gives the
|
||||
// subdomain its own link embed without a separate deploy.
|
||||
|
||||
const VST = {
|
||||
title: "VST Search - SoftwareManager",
|
||||
description: "Search for plugins easily",
|
||||
url: "https://vstsearch.softwaremanager.xyz/",
|
||||
};
|
||||
|
||||
class AttributeSetter {
|
||||
constructor(attribute, value) {
|
||||
this.attribute = attribute;
|
||||
this.value = value;
|
||||
}
|
||||
element(element) {
|
||||
element.setAttribute(this.attribute, this.value);
|
||||
}
|
||||
}
|
||||
|
||||
class ContentSetter {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
element(element) {
|
||||
element.setInnerContent(this.value);
|
||||
}
|
||||
}
|
||||
|
||||
export async function onRequest(context) {
|
||||
const { request, next } = context;
|
||||
const response = await next();
|
||||
|
||||
const onVstDomain = new URL(request.url).hostname.startsWith("vstsearch.");
|
||||
const contentType = response.headers.get("content-type") || "";
|
||||
|
||||
// Leave everything untouched on the main domain and for non-HTML responses.
|
||||
if (!onVstDomain || !contentType.includes("text/html")) {
|
||||
return response;
|
||||
}
|
||||
|
||||
return new HTMLRewriter()
|
||||
.on("title", new ContentSetter(VST.title))
|
||||
.on("meta[name='description']", new AttributeSetter("content", VST.description))
|
||||
.on("meta[property='og:title']", new AttributeSetter("content", VST.title))
|
||||
.on("meta[property='og:description']", new AttributeSetter("content", VST.description))
|
||||
.on("meta[property='og:url']", new AttributeSetter("content", VST.url))
|
||||
.on("meta[name='twitter:title']", new AttributeSetter("content", VST.title))
|
||||
.on("meta[name='twitter:description']", new AttributeSetter("content", VST.description))
|
||||
.transform(response);
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
; Version is passed via /D on the command line: iscc /DMyAppVersion=...
|
||||
#ifndef MyAppVersion
|
||||
#define MyAppVersion "dev"
|
||||
#define MyAppVersion "stable"
|
||||
#endif
|
||||
|
||||
; SourceDir is passed via /D on the command line
|
||||
@@ -66,6 +66,15 @@ Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
|
||||
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
|
||||
|
||||
[Code]
|
||||
function PrepareToInstall(var NeedsRestart: Boolean): String;
|
||||
var
|
||||
ResultCode: Integer;
|
||||
begin
|
||||
Exec('taskkill', '/F /IM {#MyAppExeName}', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||
Result := '';
|
||||
end;
|
||||
|
||||
[Run]
|
||||
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
|
||||
Filename: "{app}\{#MyAppExeName}"; Flags: nowait skipifnotsilent
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[build-system]
|
||||
requires = ["setuptools", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
@@ -1,11 +1,11 @@
|
||||
requests==2.32.2
|
||||
PySide6-Essentials==6.10.1
|
||||
beautifulsoup4==4.13.5
|
||||
requests==2.34.2
|
||||
PySide6-Essentials==6.11.1
|
||||
beautifulsoup4==4.14.3
|
||||
darkdetect==0.7.1
|
||||
pyinstaller==6.15.0
|
||||
PyQtDarkTheme-fork==2.3.4
|
||||
aiohttp==3.13.0
|
||||
pyinstaller==6.20.0
|
||||
PyQtDarkTheme-fork==2.3.6
|
||||
plyer==2.1.0
|
||||
psutil==7.1.0
|
||||
psutil==7.2.2
|
||||
libtorrent==2.0.11
|
||||
libtorrent-windows-dll==0.0.3
|
||||
send2trash==2.1.0
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "Installing Dependencies"
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
curl -L -o appimagetool-x86_64.AppImage https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
|
||||
chmod +x appimagetool-x86_64.AppImage
|
||||
|
||||
curl -L -o python.AppImage https://github.com/niess/python-appimage/releases/download/python3.13/python3.13.9-cp313-cp313-manylinux2014_x86_64.AppImage
|
||||
chmod +x python.AppImage
|
||||
|
||||
./python.AppImage --appimage-extract
|
||||
mv squashfs-root SoftwareManager.AppDir
|
||||
|
||||
echo "Build SoftwareManager.whl"
|
||||
cd ..
|
||||
build/SoftwareManager.AppDir/AppRun -m build
|
||||
|
||||
echo "Prepare SoftwareManager AppImage"
|
||||
cd build/SoftwareManager.AppDir
|
||||
./AppRun -m pip install -r ../../requirements.txt
|
||||
./AppRun -m pip install ../../dist/main-0.0.0-py3-none-any.whl
|
||||
|
||||
rm AppRun .DirIcon python.png python*.desktop usr/share/applications/python*.desktop
|
||||
|
||||
cp -t ./softwaremanager.png ../../src/interface/assets/logo.png
|
||||
cp -t . ../../SoftwareManager.desktop
|
||||
cp ../../SoftwareManager.desktop usr/share/applications/
|
||||
|
||||
echo '#! /bin/bash
|
||||
HERE="$(dirname "$(readlink -f "${0}")")"
|
||||
export PATH=$HERE/usr/bin:$PATH;
|
||||
export APPIMAGE_COMMAND=$(command -v -- "$ARGV0")
|
||||
"$HERE/opt/python3.13/bin/python3.13" "-m" "main" "$@"' > AppRun
|
||||
|
||||
chmod -R 0755 ../SoftwareManager.AppDir
|
||||
chmod +x AppRun
|
||||
|
||||
cp /usr/lib/x86_64-linux-gnu/libxcb-cursor.so* ../SoftwareManager.AppDir/usr/lib/
|
||||
cp /usr/lib/x86_64-linux-gnu/libxcb-xinerama.so* ../SoftwareManager.AppDir/usr/lib/
|
||||
cp /usr/lib/x86_64-linux-gnu/libxcb.so* ../SoftwareManager.AppDir/usr/lib/
|
||||
cp /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so* ../SoftwareManager.AppDir/usr/lib
|
||||
|
||||
echo " => Build SoftwareManager AppImage"
|
||||
cd ..
|
||||
./appimagetool-x86_64.AppImage --appimage-extract
|
||||
squashfs-root/AppRun SoftwareManager.AppDir
|
||||
|
||||
cd ..
|
||||
|
||||
echo " => Done "
|
||||
@@ -0,0 +1,79 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
|
||||
ROOT_DIR = Path(__file__).resolve().parent.parent
|
||||
README_PATH = ROOT_DIR / "README.md"
|
||||
REQUIREMENTS_PATH = ROOT_DIR / "requirements.txt"
|
||||
|
||||
START_MARKER = "<!-- python-dependencies:start -->"
|
||||
END_MARKER = "<!-- python-dependencies:end -->"
|
||||
REQUIREMENT_PATTERN = re.compile(
|
||||
r"^(?P<name>[A-Za-z0-9_.\-\[\]]+)\s*(?P<specifier>(==|~=|>=|<=|!=|>|<).+)?$"
|
||||
)
|
||||
|
||||
|
||||
def iter_requirements(requirements_text: str) -> list[str]:
|
||||
formatted_lines: list[str] = []
|
||||
|
||||
for raw_line in requirements_text.splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#"):
|
||||
continue
|
||||
|
||||
match = REQUIREMENT_PATTERN.match(line)
|
||||
if not match:
|
||||
formatted_lines.append(f" {line}")
|
||||
continue
|
||||
|
||||
name = match.group("name")
|
||||
specifier = (match.group("specifier") or "").strip()
|
||||
|
||||
if specifier.startswith("=="):
|
||||
formatted_lines.append(f" {name} ({specifier[2:]})")
|
||||
elif specifier:
|
||||
formatted_lines.append(f" {name} {specifier}")
|
||||
else:
|
||||
formatted_lines.append(f" {name}")
|
||||
|
||||
return formatted_lines
|
||||
|
||||
|
||||
def render_dependency_block(requirements_text: str) -> str:
|
||||
dependency_lines = iter_requirements(requirements_text)
|
||||
return "\n".join(
|
||||
[
|
||||
START_MARKER,
|
||||
" ```text",
|
||||
*dependency_lines,
|
||||
" ```",
|
||||
END_MARKER,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def replace_managed_block(readme_text: str, rendered_block: str) -> str:
|
||||
start_index = readme_text.find(START_MARKER)
|
||||
end_index = readme_text.find(END_MARKER)
|
||||
|
||||
if start_index == -1 or end_index == -1 or end_index < start_index:
|
||||
raise RuntimeError("README dependency markers are missing or invalid.")
|
||||
|
||||
end_index += len(END_MARKER)
|
||||
return readme_text[:start_index] + rendered_block + readme_text[end_index:]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
requirements_text = REQUIREMENTS_PATH.read_text(encoding="utf-8")
|
||||
readme_text = README_PATH.read_text(encoding="utf-8")
|
||||
rendered_block = render_dependency_block(requirements_text)
|
||||
updated_readme = replace_managed_block(readme_text, rendered_block)
|
||||
|
||||
if updated_readme != readme_text:
|
||||
README_PATH.write_text(updated_readme, encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,70 +0,0 @@
|
||||
from bs4 import BeautifulSoup
|
||||
import requests
|
||||
import time
|
||||
|
||||
cache = {
|
||||
"data": [],
|
||||
"last_fetched": 0
|
||||
}
|
||||
|
||||
cache_expiry = 300
|
||||
|
||||
def _get_telegram_posts():
|
||||
post = 100
|
||||
max_posts = 250
|
||||
posts = []
|
||||
added = set()
|
||||
|
||||
current_time = time.time()
|
||||
|
||||
if cache["data"] and (current_time - cache["last_fetched"] < cache_expiry):
|
||||
return cache["data"]
|
||||
|
||||
while post <= max_posts:
|
||||
url = f"https://t.me/s/real_monkrus/{post}"
|
||||
response = requests.get(url, timeout=10)
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
bubbles = soup.find_all("div", class_="tgme_widget_message_bubble")
|
||||
|
||||
if not bubbles:
|
||||
break
|
||||
|
||||
for bubble in bubbles:
|
||||
post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text")
|
||||
if not post_txt or not post_txt.b:
|
||||
continue
|
||||
|
||||
title = post_txt.b.text
|
||||
link = bubble.find("a", href=lambda x: x and x.startswith("https://uztracker.net"))
|
||||
|
||||
if link:
|
||||
post_url = link["href"]
|
||||
if post_url not in added:
|
||||
added.add(post_url)
|
||||
posts.append(dict(
|
||||
author="m0nkrus",
|
||||
id=len(posts) + 1,
|
||||
title=title,
|
||||
url=post_url
|
||||
))
|
||||
|
||||
post += 22
|
||||
|
||||
posts.reverse()
|
||||
|
||||
cache["data"] = posts
|
||||
cache["last_fetched"] = current_time
|
||||
|
||||
return(posts)
|
||||
|
||||
def scrape_m0nkrus(query):
|
||||
posts = _get_telegram_posts()
|
||||
filtered_posts = []
|
||||
|
||||
for post in posts:
|
||||
if query.lower() in post["title"].lower():
|
||||
filtered_post = post.copy()
|
||||
filtered_post["id"] = len(filtered_posts) + 1
|
||||
filtered_posts.append(filtered_post)
|
||||
|
||||
return filtered_posts
|
||||
@@ -1,19 +0,0 @@
|
||||
import requests
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
|
||||
def scrape_rutracker(query):
|
||||
search = requests.get(f"{state.api_url}/search?q={query}")
|
||||
consoleLog("Sent request to server")
|
||||
if search:
|
||||
try:
|
||||
return search.text
|
||||
except Exception:
|
||||
consoleLog("No results found / No response from server")
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
|
||||
# This function utilizes the SoftwareManager server - source code can be found under the SoftwareManager-Server repository.
|
||||
@@ -1,37 +0,0 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from urllib.parse import urljoin
|
||||
from core.utils.logging.logs import consoleLog
|
||||
|
||||
def scrape_uztracker(query):
|
||||
base_url="https://uztracker.net/"
|
||||
search_url = f"{base_url.rstrip('/')}/tracker.php?nm={query}"
|
||||
consoleLog(search_url)
|
||||
posts = []
|
||||
|
||||
try:
|
||||
response = requests.get(search_url)
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
links = soup.find_all('tr', class_="tCenter hl-tr", id=lambda x: x and x.startswith('tor_'))
|
||||
for link in links:
|
||||
|
||||
theme_link = link.find('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
||||
if not theme_link or not theme_link.b:
|
||||
continue
|
||||
url = urljoin(base_url, theme_link['href'])
|
||||
title = theme_link.b.text
|
||||
author_link = link.find('a', class_="med")
|
||||
author = author_link.text.strip() if author_link else "Unknown"
|
||||
|
||||
posts.append(dict(
|
||||
title=title,
|
||||
url=url,
|
||||
author=author
|
||||
))
|
||||
|
||||
return posts
|
||||
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Failed to fetch {search_url}: {e}")
|
||||
return None
|
||||
|
Before Width: | Height: | Size: 32 KiB |
@@ -1,265 +0,0 @@
|
||||
from core.utils.config.settings import save_settings
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.interface.utils.tabhelper import general_tab
|
||||
from core.interface.utils.tabhelper import paths_tab
|
||||
from core.interface.utils.tabhelper import network_tab
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QDialog,
|
||||
QLabel,
|
||||
QHBoxLayout,
|
||||
QSpinBox,
|
||||
QCheckBox,
|
||||
QFileDialog,
|
||||
QComboBox,
|
||||
QTabWidget,
|
||||
)
|
||||
import platform
|
||||
|
||||
|
||||
def settings_dialog(self):
|
||||
|
||||
consoleLog("Settings dialog opened")
|
||||
dialog = QDialog(self)
|
||||
dialog.setWindowTitle("Settings")
|
||||
dialog.setFixedSize(700, 450)
|
||||
|
||||
dialog.setLayout(QVBoxLayout())
|
||||
|
||||
if state.window_transparency and platform.system() != "Windows" and dialog:
|
||||
dialog.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
def close_settings():
|
||||
dialog.reject()
|
||||
|
||||
update_checkbox_container = QWidget()
|
||||
update_checkbox_layout = QHBoxLayout()
|
||||
|
||||
# ignore updates checkbox
|
||||
|
||||
if platform.system() == "Windows":
|
||||
update_checkbox = QCheckBox()
|
||||
update_checkbox_container.setLayout(update_checkbox_layout)
|
||||
update_checkbox_layout.addWidget(QLabel("Ignore Updates: "))
|
||||
update_checkbox_layout.addStretch()
|
||||
update_checkbox.setChecked(state.ignore_updates)
|
||||
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
|
||||
update_checkbox_layout.addWidget(update_checkbox)
|
||||
dialog.layout().addWidget(update_checkbox_container)
|
||||
|
||||
# auto-resume downloads checkbox
|
||||
|
||||
autoresume_container = QWidget()
|
||||
autoresume_layout = QHBoxLayout()
|
||||
|
||||
autoresume_checkbox = QCheckBox()
|
||||
autoresume_container.setLayout(autoresume_layout)
|
||||
autoresume_layout.addWidget(QLabel("Auto-Resume Downloads: "))
|
||||
|
||||
autoresume_layout.addStretch()
|
||||
autoresume_checkbox.setChecked(state.autoresume)
|
||||
autoresume_layout.addWidget(autoresume_checkbox)
|
||||
|
||||
|
||||
# transparent window checkbox
|
||||
transparent_window_container = QWidget()
|
||||
transparent_window_layout = QHBoxLayout()
|
||||
|
||||
transparent_window_checkbox = QCheckBox()
|
||||
transparent_window_container.setLayout(transparent_window_layout)
|
||||
transparent_window_layout.addWidget(QLabel("Window Transparency (requires restart) (Linux/MacOS only): "))
|
||||
|
||||
transparent_window_layout.addStretch()
|
||||
transparent_window_checkbox.setChecked(state.window_transparency)
|
||||
transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked))
|
||||
transparent_window_layout.addWidget(transparent_window_checkbox)
|
||||
|
||||
##################
|
||||
# SERVER SETTING #
|
||||
##################
|
||||
|
||||
api_url_container = QWidget()
|
||||
api_url_layout = QHBoxLayout()
|
||||
|
||||
api_url = QLineEdit()
|
||||
api_url_layout.addWidget(QLabel("API Server URL:"))
|
||||
api_url_layout.addWidget(api_url)
|
||||
api_url_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||
api_url_container.setLayout(api_url_layout)
|
||||
api_url.setText(state.api_url)
|
||||
|
||||
#################
|
||||
# DOWNLOAD PATH #
|
||||
#################
|
||||
|
||||
download_path_container = QWidget()
|
||||
download_path_layout = QHBoxLayout()
|
||||
|
||||
download_path = QLineEdit()
|
||||
download_path_layout.addWidget(QLabel("Download Path:"))
|
||||
download_path_layout.addWidget(download_path)
|
||||
download_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||
download_path_container.setLayout(download_path_layout)
|
||||
download_path.setText(state.download_path)
|
||||
|
||||
def browse_download_path():
|
||||
dir_path = QFileDialog.getExistingDirectory(dialog, "Select Download Directory", state.download_path)
|
||||
if dir_path:
|
||||
download_path.setText(dir_path)
|
||||
|
||||
browse_button = QPushButton("📁")
|
||||
download_path_layout.addWidget(browse_button)
|
||||
browse_button.clicked.connect(browse_download_path)
|
||||
|
||||
###############
|
||||
# IMAGE PATH #
|
||||
###############
|
||||
|
||||
# image_path_container = QWidget()
|
||||
# image_path_layout = QHBoxLayout()
|
||||
|
||||
# image_path = QLineEdit()
|
||||
# image_path_layout.addWidget(QLabel("Image Path (requires restart):"))
|
||||
# image_path_layout.addWidget(image_path)
|
||||
# image_path_container.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed)
|
||||
# image_path_container.setLayout(image_path_layout)
|
||||
# image_path.setText(state.image_path)
|
||||
|
||||
# def browse_image_path():
|
||||
# file_path = QFileDialog.getOpenFileName(dialog, "Select Image File", state.image_path, "Image Files (*.png *.jpg)")[0]
|
||||
# if file_path:
|
||||
# image_path.setText(file_path)
|
||||
|
||||
# browse_button = QPushButton("📁")
|
||||
# image_path_layout.addWidget(browse_button)
|
||||
# browse_button.clicked.connect(browse_image_path)
|
||||
|
||||
##################
|
||||
# SPEED LIMITING #
|
||||
##################
|
||||
|
||||
down_speed_limit_container = QWidget()
|
||||
down_speed_limit_layout = QHBoxLayout()
|
||||
|
||||
down_speed_limit_layout.addWidget(QLabel("Max Download Speed (KiB, 0 for unlimited): "))
|
||||
down_speed_limit = QSpinBox()
|
||||
down_speed_limit.setMinimum(0)
|
||||
down_speed_limit.setMaximum(10000000)
|
||||
down_speed_limit.setValue(state.down_speed_limit)
|
||||
down_speed_limit_container.setLayout(down_speed_limit_layout)
|
||||
down_speed_limit_layout.addWidget(down_speed_limit)
|
||||
down_speed_limit.setFixedWidth(180)
|
||||
down_speed_limit.setFixedHeight(30)
|
||||
|
||||
up_speed_limit_container = QWidget()
|
||||
up_speed_limit_layout = QHBoxLayout()
|
||||
|
||||
up_speed_limit_layout.addWidget(QLabel("Max Upload Speed (KiB, 0 for unlimited): "))
|
||||
up_speed_limit = QSpinBox()
|
||||
up_speed_limit.setMinimum(0)
|
||||
up_speed_limit.setMaximum(10000000)
|
||||
up_speed_limit.setValue(state.up_speed_limit)
|
||||
up_speed_limit_container.setLayout(up_speed_limit_layout)
|
||||
up_speed_limit_layout.addWidget(up_speed_limit)
|
||||
up_speed_limit.setFixedWidth(180)
|
||||
up_speed_limit.setFixedHeight(30)
|
||||
|
||||
######################
|
||||
# CONNECTION CONFIGS #
|
||||
######################
|
||||
|
||||
max_connections_container = QWidget()
|
||||
max_connections_layout = QHBoxLayout()
|
||||
|
||||
max_connections_layout.addWidget(QLabel("Max Connections: "))
|
||||
max_connections = QSpinBox()
|
||||
max_connections.setMinimum(0)
|
||||
max_connections.setMaximum(10000000)
|
||||
max_connections.setValue(state.max_connections)
|
||||
max_connections_container.setLayout(max_connections_layout)
|
||||
max_connections_layout.addWidget(max_connections)
|
||||
max_connections.setFixedWidth(180)
|
||||
max_connections.setFixedHeight(30)
|
||||
|
||||
####################
|
||||
# DOWNLOAD CONFIGS #
|
||||
####################
|
||||
|
||||
max_downloads_container = QWidget()
|
||||
max_downloads_layout = QHBoxLayout()
|
||||
|
||||
max_downloads_layout.addWidget(QLabel("Max Downloads: "))
|
||||
max_downloads = QSpinBox()
|
||||
max_downloads.setMinimum(0)
|
||||
max_downloads.setMaximum(10000000)
|
||||
max_downloads.setValue(state.max_downloads)
|
||||
max_downloads_container.setLayout(max_downloads_layout)
|
||||
max_downloads_layout.addWidget(max_downloads)
|
||||
max_downloads.setFixedWidth(180)
|
||||
max_downloads.setFixedHeight(30)
|
||||
|
||||
#####################
|
||||
# INTERFACE BINDING #
|
||||
#####################
|
||||
|
||||
interface_container = QWidget()
|
||||
interface_layout = QHBoxLayout()
|
||||
|
||||
interface_label = QLabel("Network Interface:")
|
||||
interface_layout.addWidget(interface_label)
|
||||
interface_select = QComboBox()
|
||||
interface_select.addItems(["None"] + state.interfaces)
|
||||
|
||||
target = state.bound_interface if state.bound_interface else "None"
|
||||
|
||||
index = interface_select.findText(target)
|
||||
if index >= 0:
|
||||
interface_select.setCurrentIndex(index)
|
||||
else:
|
||||
interface_select.setCurrentIndex(0)
|
||||
|
||||
interface_select.setFixedWidth(180)
|
||||
interface_select.setFixedHeight(30)
|
||||
interface_layout.addWidget(interface_select)
|
||||
interface_container.setLayout(interface_layout)
|
||||
|
||||
|
||||
###############
|
||||
# SAVE/CANCEL #
|
||||
###############
|
||||
|
||||
layout = QHBoxLayout()
|
||||
|
||||
save_btn = QPushButton("Save")
|
||||
cancel_btn = QPushButton("Cancel")
|
||||
save_btn.clicked.connect(lambda: save_settings(
|
||||
close_settings,
|
||||
api_url.text(),
|
||||
download_path.text(),
|
||||
down_speed_limit.value(),
|
||||
up_speed_limit.value(),
|
||||
None,
|
||||
autoresume_checkbox.isChecked(),
|
||||
max_connections.value(),
|
||||
max_downloads.value(),
|
||||
interface_select.currentText()))
|
||||
|
||||
cancel_btn.clicked.connect(dialog.reject)
|
||||
layout.addWidget(cancel_btn)
|
||||
layout.addWidget(save_btn)
|
||||
|
||||
self.tabs = QTabWidget()
|
||||
self.tab1 = general_tab("General", autoresume_container, update_checkbox_container, transparent_window_container, self.tabs)
|
||||
self.tab2 = paths_tab("Paths", download_path_container, self.tabs)
|
||||
self.tab3 = network_tab("Network", interface_container, max_connections_container, max_downloads_container, up_speed_limit_container, down_speed_limit_container, api_url_container, self.tabs)
|
||||
|
||||
dialog.layout().addWidget(self.tabs)
|
||||
dialog.layout().addLayout(layout)
|
||||
|
||||
dialog.exec()
|
||||
@@ -1,959 +0,0 @@
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import QPersistentModelIndex, Qt, QTimer, QModelIndex, QAbstractTableModel, Signal, QEvent, QSize, QByteArray
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QTableView,
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QListWidget,
|
||||
QLabel,
|
||||
QHBoxLayout,
|
||||
QComboBox,
|
||||
QTabWidget,
|
||||
QHeaderView,
|
||||
QMessageBox,
|
||||
QTableWidget,
|
||||
QTextEdit,
|
||||
QStyledItemDelegate,
|
||||
QStatusBar
|
||||
)
|
||||
|
||||
from PySide6.QtGui import QIcon, QCloseEvent, QImage, QPixmap, QContextMenuEvent, QGuiApplication, QColor, QBrush
|
||||
from PySide6.QtSvg import QSvgRenderer
|
||||
import darkdetect
|
||||
import threading
|
||||
import platform
|
||||
import requests as r
|
||||
import os
|
||||
import subprocess
|
||||
import libtorrent as lt
|
||||
import sys
|
||||
import json
|
||||
import base64
|
||||
from core.utils.logging.logs import consoleLog, remove_download_log, flush_log_buffer
|
||||
from core.utils.general.wrappers import run_thread
|
||||
from core.utils.data.state import state
|
||||
from core.utils.network.download import download_selected
|
||||
from core.utils.network.update_checker import check_for_updates
|
||||
from core.interface.utils.tabhelper import create_tab
|
||||
from core.interface.utils.searchhelper import return_pressed
|
||||
from core.interface.dialogs.settings import settings_dialog
|
||||
from core.interface.assets.base64_icons import settings_black_base64
|
||||
from core.interface.assets.base64_icons import settings_white_base64
|
||||
from core.interface.assets.base64_icons import logo_base64
|
||||
from core.utils.general.shutdown import closehelper
|
||||
|
||||
|
||||
def _is_dark_mode():
|
||||
return darkdetect.isDark()
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
dark = _is_dark_mode()
|
||||
if dark:
|
||||
return {
|
||||
"text": "rgba(255, 255, 255, 0.9)",
|
||||
"border": "rgba(255, 255, 255, 0.06)",
|
||||
"selected": "rgba(255, 255, 255, 0.04)",
|
||||
"header_text": "rgba(255, 255, 255, 0.5)",
|
||||
"header_border": "rgba(255, 255, 255, 0.1)",
|
||||
"hover": QColor(255, 255, 255, 15),
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"text": "rgba(0, 0, 0, 0.87)",
|
||||
"border": "rgba(0, 0, 0, 0.08)",
|
||||
"selected": "rgba(0, 0, 0, 0.06)",
|
||||
"header_text": "rgba(0, 0, 0, 0.6)",
|
||||
"header_border": "rgba(0, 0, 0, 0.12)",
|
||||
"hover": QColor(0, 0, 0, 15),
|
||||
}
|
||||
|
||||
|
||||
def _table_stylesheet(view_type="QTableWidget"):
|
||||
c = _theme_colors()
|
||||
dark = _is_dark_mode()
|
||||
color_rule = "" if dark else f"color: {c['text']};"
|
||||
return f"""
|
||||
{view_type} {{
|
||||
border: none;
|
||||
outline: 0;
|
||||
font-size: 13px;
|
||||
{color_rule}
|
||||
}}
|
||||
{view_type}::item {{
|
||||
border-bottom: 1px solid {c["border"]};
|
||||
padding: 6px 14px;
|
||||
outline: none;
|
||||
{color_rule}
|
||||
}}
|
||||
{view_type}::item:selected {{
|
||||
background: {c["selected"]};
|
||||
outline: none;
|
||||
}}
|
||||
{view_type}::item:focus {{
|
||||
outline: none;
|
||||
border: none;
|
||||
}}
|
||||
QHeaderView {{
|
||||
background: transparent;
|
||||
}}
|
||||
QHeaderView::section {{
|
||||
background: transparent;
|
||||
color: {c["header_text"]};
|
||||
font-weight: normal;
|
||||
border: none;
|
||||
border-bottom: 1px solid {c["header_border"]};
|
||||
padding: 6px 14px;
|
||||
}}
|
||||
QHeaderView::section:checked {{
|
||||
background: transparent;
|
||||
color: {c["header_text"]};
|
||||
font-weight: normal;
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
def _svg_icon(svg_str, size=20):
|
||||
app = QtWidgets.QApplication.instance()
|
||||
if app:
|
||||
if _is_dark_mode():
|
||||
color = "white"
|
||||
else:
|
||||
color = "#555555"
|
||||
else:
|
||||
color = "white"
|
||||
svg = svg_str.replace("{color}", color)
|
||||
renderer = QSvgRenderer(QByteArray(svg.encode()))
|
||||
pixmap = QPixmap(size, size)
|
||||
pixmap.fill(Qt.GlobalColor.transparent)
|
||||
from PySide6.QtGui import QPainter
|
||||
painter = QPainter(pixmap)
|
||||
renderer.render(painter)
|
||||
painter.end()
|
||||
return QIcon(pixmap)
|
||||
|
||||
|
||||
SVG_PLAY = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><polygon points="6,3 20,12 6,21" fill="{color}"/></svg>'
|
||||
SVG_PAUSE = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="5" y="3" width="4" height="18" rx="1" fill="{color}"/><rect x="15" y="3" width="4" height="18" rx="1" fill="{color}"/></svg>'
|
||||
SVG_FOLDER = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 6c0-1.1.9-2 2-2h5l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6z" fill="{color}"/></svg>'
|
||||
|
||||
|
||||
def download_update(latest_version):
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
new_filename = f"SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||
url = f"https://github.com/KeksPirates/SoftwareManager/releases/latest/download/SoftwareManager-dev-{latest_version.replace('-dev', '')}-windows-setup.exe"
|
||||
installer_path = os.path.join(tempfile.gettempdir(), new_filename)
|
||||
|
||||
progress = QtWidgets.QProgressDialog("Downloading installer...", None, 0, 0)
|
||||
progress.setWindowTitle("Updating")
|
||||
progress.setWindowModality(Qt.WindowModality.ApplicationModal)
|
||||
progress.setCancelButton(None)
|
||||
progress.setMinimumDuration(0)
|
||||
progress.setAutoClose(False)
|
||||
progress.setAutoReset(False)
|
||||
progress.setRange(0, 100)
|
||||
progress.setValue(0)
|
||||
progress.show()
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
response = r.get(url, allow_redirects=True, stream=True)
|
||||
total = int(response.headers.get("content-length", 0))
|
||||
downloaded = 0
|
||||
with open(installer_path, "wb") as f:
|
||||
for chunk in response.iter_content(chunk_size=65536):
|
||||
f.write(chunk)
|
||||
downloaded += len(chunk)
|
||||
if total > 0:
|
||||
progress.setValue(int(downloaded * 100 / total))
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
if not os.path.exists(installer_path):
|
||||
progress.close()
|
||||
raise FileNotFoundError("Executable not found")
|
||||
|
||||
progress.setLabelText("Installing update...")
|
||||
progress.setValue(100)
|
||||
QtWidgets.QApplication.processEvents()
|
||||
|
||||
subprocess.Popen([installer_path, "/VERYSILENT", "/SUPPRESSMSGBOXES", "/SP-", "/CLOSEAPPLICATIONS"])
|
||||
time.sleep(1)
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def windowCloseHelper():
|
||||
QGuiApplication.quit()
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
log_signal = Signal(str) # Thread-safe signal for logging
|
||||
search_finished_signal = Signal() # Thread-safe signal for search completion
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
MainWindow._instance = self
|
||||
self.log_signal.connect(self._on_log_signal)
|
||||
self.search_finished_signal.connect(self._on_search_finished)
|
||||
|
||||
pixmap = QPixmap()
|
||||
image_data = base64.b64decode(logo_base64)
|
||||
pixmap.loadFromData(image_data)
|
||||
self.setWindowIcon(QIcon(pixmap))
|
||||
|
||||
if platform.system() == "Windows":
|
||||
try:
|
||||
import ctypes
|
||||
appid = 'SoftwareManager'
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)
|
||||
except Exception as e:
|
||||
consoleLog(f"Could not set app ID: {e}")
|
||||
|
||||
build_info_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "build_info.json")
|
||||
if os.path.exists(build_info_path):
|
||||
with open(build_info_path, "r") as f:
|
||||
build_info = json.load(f)
|
||||
state.version = build_info.get("version")
|
||||
|
||||
# Check for updates on Windows
|
||||
if state.ignore_updates is False and platform.system() == "Windows":
|
||||
result = check_for_updates()
|
||||
if result != (None, None):
|
||||
assets, latest_version = result
|
||||
|
||||
if assets:
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Icon.Information)
|
||||
msg.setWindowTitle("Update Available")
|
||||
msg.setText("A new version is available.")
|
||||
msg.setInformativeText("Press Ok to download the update.")
|
||||
msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore)
|
||||
|
||||
response = msg.exec_()
|
||||
if response == QMessageBox.StandardButton.Ok:
|
||||
download_update(latest_version)
|
||||
|
||||
self.setWindowTitle("Software Manager")
|
||||
self.setGeometry(100, 100, 800, 600)
|
||||
|
||||
self.controls = QWidget()
|
||||
self.controlsLayout = QVBoxLayout()
|
||||
|
||||
# Widgets
|
||||
self.searchbar = QLineEdit()
|
||||
self.searchbar.setPlaceholderText("Search for software...")
|
||||
self.searchbar.setClearButtonEnabled(True)
|
||||
self.searchbar.setMinimumHeight(30)
|
||||
self.searchbar.returnPressed.connect(self._start_search)
|
||||
|
||||
self.dlbutton = QtWidgets.QPushButton("Download")
|
||||
self.dlbutton.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.libraryList = QListWidget()
|
||||
|
||||
self.emptyResults = QLabel("No Results")
|
||||
self.emptyResults.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.emptyResults.hide()
|
||||
|
||||
self.download_model = None
|
||||
self.downloadList = QTableView()
|
||||
self.downloadList.setMouseTracking(True)
|
||||
self._hovered_row = -1
|
||||
self._tracker_hovered_row = -1
|
||||
self._tracker_hovered_table = None
|
||||
self.downloadList.viewport().installEventFilter(self)
|
||||
self.emptyLibrary = QLabel("No items in library.")
|
||||
self.emptyDownload = QLabel("No items in downloads.")
|
||||
self.emptyDownload.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.consoleLog = QTextEdit()
|
||||
self.statusbar = QStatusBar()
|
||||
|
||||
flush_log_buffer()
|
||||
|
||||
class TrackerHoverDelegate(QStyledItemDelegate):
|
||||
def paint(self, painter, option, index):
|
||||
if index.row() == MainWindow._instance._tracker_hovered_row:
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, option, index)
|
||||
|
||||
self._tracker_hover_delegate = TrackerHoverDelegate(self)
|
||||
|
||||
def create_tracker_table(headers):
|
||||
table = QTableWidget()
|
||||
table.setColumnCount(len(headers))
|
||||
table.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
table.verticalHeader().setVisible(False)
|
||||
table.setHorizontalHeaderLabels(headers)
|
||||
table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
table.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
|
||||
header = table.horizontalHeader()
|
||||
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
||||
header.setSectionResizeMode(1, QHeaderView.ResizeMode.Fixed)
|
||||
header.resizeSection(1, 500)
|
||||
header.setStretchLastSection(False)
|
||||
header.setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
header.setHighlightSections(False)
|
||||
|
||||
table.setShowGrid(False)
|
||||
table.setStyleSheet(_table_stylesheet("QTableWidget"))
|
||||
|
||||
table.setMouseTracking(True)
|
||||
table.viewport().setMouseTracking(True)
|
||||
table.setItemDelegate(self._tracker_hover_delegate)
|
||||
|
||||
return table
|
||||
|
||||
|
||||
self.rutrackerlist = create_tracker_table(["Post Title", "Author", "Seeders", "Leechers"])
|
||||
self.uztrackerlist = create_tracker_table(["Post Title", "Author"])
|
||||
self.monkruslist = create_tracker_table(["Post Title", "Author"])
|
||||
|
||||
state.tracker_list.update({"rutracker": self.rutrackerlist, "uztracker": self.uztrackerlist, "m0nkrus": self.monkruslist})
|
||||
|
||||
self.rutrackerlist.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.rutrackerlist.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
self.uztrackerlist.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.uztrackerlist.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
self.monkruslist.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.monkruslist.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
for tbl in (self.rutrackerlist, self.uztrackerlist, self.monkruslist):
|
||||
tbl.viewport().installEventFilter(self)
|
||||
|
||||
container = QWidget()
|
||||
containerLayout = QVBoxLayout()
|
||||
|
||||
search_row = QHBoxLayout()
|
||||
search_row.addWidget(self.searchbar)
|
||||
containerLayout.addLayout(search_row)
|
||||
containerLayout.addWidget(state.tracker_list[state.tracker])
|
||||
|
||||
class DownloadModel(QAbstractTableModel):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.headers = ["Action", "Name", "Status", "Progress", "Speed", "Size", "Total Size"]
|
||||
|
||||
def rowCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()) -> int:
|
||||
return len(state.active_downloads)
|
||||
|
||||
def columnCount(self, parent: QModelIndex | QPersistentModelIndex = QModelIndex()):
|
||||
return len(self.headers)
|
||||
|
||||
def headerData(self, section, orientation, role: int = Qt.ItemDataRole.DisplayRole):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return self.headers[section]
|
||||
return None
|
||||
|
||||
def data(self, index: QModelIndex | QPersistentModelIndex, role: int = Qt.ItemDataRole.DisplayRole):
|
||||
if role == Qt.ItemDataRole.DisplayRole:
|
||||
col = index.column()
|
||||
|
||||
if index.row() >= len(state.active_downloads) or index.row() < 0:
|
||||
return None
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if col == 0:
|
||||
pass
|
||||
elif col == 1:
|
||||
return status.name if status.has_metadata else "Fetching metadata..."
|
||||
elif col == 2:
|
||||
if status.state == lt.torrent_status.downloading:
|
||||
return "Downloading"
|
||||
elif status.state == lt.torrent_status.seeding:
|
||||
return "Seeding"
|
||||
elif status.paused:
|
||||
is_auto = bool(magnetdl.flags() & lt.torrent_flags.auto_managed)
|
||||
return "Queued" if is_auto else "Paused"
|
||||
else:
|
||||
return "Queued"
|
||||
elif col == 3:
|
||||
return f"{status.progress * 100:.1f}%"
|
||||
elif col == 4:
|
||||
down_kb = status.download_rate / 1024
|
||||
up_kb = status.upload_rate / 1024
|
||||
down_text = f"{down_kb / 1024:.1f} MB/s" if down_kb > 1024 else f"{down_kb:.1f} kB/s"
|
||||
up_text = f"{up_kb / 1024:.1f} MB/s" if up_kb > 1024 else f"{up_kb:.1f} kB/s"
|
||||
return f"↓ {down_text} ↑ {up_text}"
|
||||
elif col == 5:
|
||||
downloaded_mb = status.total_wanted_done / (1024 * 1024)
|
||||
if downloaded_mb > 1024:
|
||||
return f"{downloaded_mb / 1024:.2f} GB"
|
||||
else:
|
||||
return f"{downloaded_mb:.1f} MB"
|
||||
elif col == 6:
|
||||
total_mb = status.total_wanted / (1024 * 1024)
|
||||
if total_mb > 1024:
|
||||
return f"{total_mb / 1024:.2f} GB"
|
||||
else:
|
||||
return f"{total_mb:.1f} MB"
|
||||
elif col == 7:
|
||||
if status.download_rate > 0:
|
||||
bytes_left = status.total_wanted - status.total_wanted_done
|
||||
eta_seconds = bytes_left / status.download_rate
|
||||
|
||||
if eta_seconds < 60:
|
||||
return f"{int(eta_seconds)}s"
|
||||
elif eta_seconds < 3600:
|
||||
minutes = int(eta_seconds / 60)
|
||||
seconds = int(eta_seconds % 60)
|
||||
return f"{minutes}m {seconds}s"
|
||||
else:
|
||||
hours = int(eta_seconds / 3600)
|
||||
minutes = int((eta_seconds % 3600) / 60)
|
||||
return f"{hours}h {minutes}m"
|
||||
else:
|
||||
return "∞" if status.paused else "Stalled"
|
||||
|
||||
if role == Qt.ItemDataRole.UserRole and index.column() == 0:
|
||||
magnet_link = list(state.active_downloads.keys())[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
return magnetdl.status().paused
|
||||
|
||||
return None
|
||||
|
||||
def toggle_pause_resume(self, row):
|
||||
|
||||
if row >= len(state.active_downloads) or row < 0:
|
||||
return
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
save_path = magnetdl.save_path()
|
||||
if save_path and os.path.exists(save_path):
|
||||
if platform.system() == "Windows":
|
||||
os.startfile(os.path.normpath(save_path))
|
||||
elif platform.system() == "Linux":
|
||||
subprocess.Popen(["xdg-open", save_path])
|
||||
elif platform.system() == "Darwin":
|
||||
subprocess.Popen(["open", save_path])
|
||||
return
|
||||
|
||||
is_paused = bool(magnetdl.flags() & lt.torrent_flags.paused)
|
||||
if is_paused:
|
||||
magnetdl.set_flags(lt.torrent_flags.auto_managed)
|
||||
magnetdl.resume()
|
||||
consoleLog(f"Resumed download: {status.name}", True)
|
||||
else:
|
||||
magnetdl.unset_flags(lt.torrent_flags.auto_managed)
|
||||
magnetdl.pause()
|
||||
consoleLog(f"Paused download: {status.name}", True)
|
||||
|
||||
idx = self.index(row, 0)
|
||||
self.dataChanged.emit(idx, idx, [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.UserRole])
|
||||
|
||||
class HoverRowDelegate(QStyledItemDelegate):
|
||||
def paint(self, painter, option, index):
|
||||
if index.row() == MainWindow._instance._hovered_row:
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, option, index)
|
||||
|
||||
class PauseResumeDelegate(QStyledItemDelegate):
|
||||
clicked = Signal(int)
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
if index.row() == MainWindow._instance._hovered_row:
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, option, index)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
button = editor.findChild(QtWidgets.QPushButton)
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
|
||||
if button:
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
button.setIcon(_svg_icon(SVG_FOLDER, 18))
|
||||
button.setText("")
|
||||
else:
|
||||
is_user_paused = status.paused and not bool(magnetdl.flags() & lt.torrent_flags.auto_managed)
|
||||
button.setIcon(_svg_icon(SVG_PLAY if is_user_paused else SVG_PAUSE, 18))
|
||||
button.setText("")
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
magnet_link = list(state.active_downloads.keys())[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
|
||||
widget = QWidget(parent)
|
||||
widget.setStyleSheet("border: none; background: transparent;")
|
||||
layout = QHBoxLayout(widget)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
btnPause = QtWidgets.QPushButton()
|
||||
btnPause.setIcon(_svg_icon(SVG_FOLDER, 18))
|
||||
else:
|
||||
btnPause = QtWidgets.QPushButton()
|
||||
is_user_paused = status.paused and not bool(magnetdl.flags() & lt.torrent_flags.auto_managed)
|
||||
btnPause.setIcon(_svg_icon(SVG_PLAY if is_user_paused else SVG_PAUSE, 18))
|
||||
btnPause.setIconSize(QSize(18, 18))
|
||||
btnPause.setFixedSize(30, 30)
|
||||
btnPause.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btnPause.setStyleSheet("""
|
||||
QPushButton {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0px;
|
||||
}
|
||||
""")
|
||||
btnPause.clicked.connect(lambda: self.clicked.emit(index.row()))
|
||||
layout.addStretch()
|
||||
layout.addWidget(btnPause)
|
||||
layout.addStretch()
|
||||
widget.setLayout(layout)
|
||||
return widget
|
||||
def editorEvent(self, event, model, option, index):
|
||||
return False
|
||||
|
||||
self.download_model = DownloadModel()
|
||||
self.downloadList.setModel(self.download_model)
|
||||
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
|
||||
self.downloadList.horizontalHeader().resizeSection(0, 70)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(4, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(5, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(6, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setMinimumSectionSize(60)
|
||||
self.downloadList.verticalHeader().setDefaultSectionSize(40)
|
||||
self.downloadList.setSelectionBehavior(QTableView.SelectionBehavior.SelectRows)
|
||||
self.downloadList.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
self.downloadList.verticalHeader().setVisible(False)
|
||||
self.downloadList.horizontalHeader().setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
self.downloadList.horizontalHeader().setHighlightSections(False)
|
||||
self.downloadList.setMouseTracking(True)
|
||||
self.downloadList.setShowGrid(False)
|
||||
self.downloadList.setStyleSheet(_table_stylesheet("QTableView"))
|
||||
self.downloadList.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.downloadList.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
download_model = self.download_model
|
||||
|
||||
def on_pause_resume_clicked(row):
|
||||
download_model.toggle_pause_resume(row)
|
||||
|
||||
self.downloadList.viewport().setMouseTracking(True)
|
||||
hover_delegate = HoverRowDelegate(self.downloadList)
|
||||
self.downloadList.setItemDelegate(hover_delegate)
|
||||
|
||||
delegate = PauseResumeDelegate(self.downloadList)
|
||||
self.downloadList.setItemDelegateForColumn(0, delegate)
|
||||
delegate.clicked.connect(on_pause_resume_clicked)
|
||||
|
||||
# download button triggers
|
||||
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.tracker_list[state.tracker].selectedItems(), state.posts, state.post_titles))))
|
||||
|
||||
container.setLayout(containerLayout)
|
||||
self.setCentralWidget(container)
|
||||
|
||||
# Tabs
|
||||
self.tabs = QTabWidget()
|
||||
self.tabs.setStyleSheet("""
|
||||
QTabBar::tab {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
height: 25px;
|
||||
}
|
||||
QTabWidget::pane {
|
||||
margin-top: -20px;
|
||||
}
|
||||
""")
|
||||
|
||||
self.horizontal_layout = QHBoxLayout()
|
||||
self.horizontal_layout.addWidget(self.emptyResults, stretch=3)
|
||||
self.tracker_widget = state.tracker_list[state.tracker]
|
||||
self.horizontal_layout.addWidget(self.tracker_widget)
|
||||
|
||||
self.tab1 = create_tab("Search", self.searchbar, state.tracker_list[state.tracker], self.tabs, self.dlbutton, self.horizontal_layout)
|
||||
# self.tab2 = create_tab("Library", self.emptyLibrary, self.libraryList, self.tabs, None, None)
|
||||
self.tab3 = create_tab("Downloads", self.emptyDownload, self.downloadList, self.tabs, None, None)
|
||||
|
||||
if state.image_path is not None and os.path.exists(state.image_path):
|
||||
self.image = QImage(state.image_path)
|
||||
self.image = self.image.scaledToWidth(300, Qt.TransformationMode.SmoothTransformation)
|
||||
self.pixmap = QPixmap.fromImage(self.image)
|
||||
self.overlay_label = QLabel(self)
|
||||
self.overlay_label.setPixmap(self.pixmap)
|
||||
self.overlay_label.adjustSize()
|
||||
self.overlay_label.raise_()
|
||||
|
||||
# offset_x = -1350
|
||||
# offset_y = -550
|
||||
x = self.width() - self.overlay_label.width() # - offset_x
|
||||
y = self.height() - self.overlay_label.height() # - offset_y
|
||||
self.overlay_label.move(x, y)
|
||||
|
||||
# temporarily disabled
|
||||
# state.image_changed.connect(self.update_image_overlay)
|
||||
|
||||
|
||||
self.corner_widget = QWidget()
|
||||
self.corner_layout = QHBoxLayout(self.corner_widget)
|
||||
self.corner_layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
|
||||
self.tracker_list = QComboBox()
|
||||
self.tracker_list.addItems(["rutracker", "uztracker", "m0nkrus"])
|
||||
self.tracker_list.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.tracker_list.activated.connect(self.set_tracker)
|
||||
self.corner_layout.addWidget(self.tracker_list)
|
||||
|
||||
self.settings_btn = QtWidgets.QToolButton()
|
||||
self.settings_btn.setIconSize(QSize(21, 21))
|
||||
self.settings_btn.setStyleSheet("background: transparent;")
|
||||
|
||||
if darkdetect.isDark():
|
||||
settings_white_pixmap = QPixmap()
|
||||
settings_white = base64.b64decode(settings_white_base64)
|
||||
settings_white_pixmap.loadFromData(settings_white)
|
||||
self.settings_btn.setIcon(QIcon(settings_white_pixmap))
|
||||
else:
|
||||
settings_black_pixmap = QPixmap()
|
||||
settings_black = base64.b64decode(settings_black_base64)
|
||||
settings_black_pixmap.loadFromData(settings_black)
|
||||
self.settings_btn.setIcon(QIcon(settings_black_pixmap))
|
||||
|
||||
self.settings_btn.setToolTip("Settings")
|
||||
self.settings_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.settings_btn.clicked.connect(lambda: settings_dialog(self))
|
||||
|
||||
self.corner_layout.addWidget(self.settings_btn)
|
||||
|
||||
self.tab_wrapper = QWidget()
|
||||
self.tab_layout = QVBoxLayout()
|
||||
self.tab_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.tab_layout.setSpacing(0)
|
||||
|
||||
|
||||
self.tab_bar_layout = QHBoxLayout()
|
||||
self.tab_bar_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.tab_bar_layout.setSpacing(0)
|
||||
|
||||
self.tab_bar_layout.addWidget(self.tabs.tabBar(), stretch=0)
|
||||
self.tab_bar_layout.addStretch()
|
||||
self.tab_bar_layout.addWidget(self.corner_widget, stretch=0)
|
||||
|
||||
self.tab_layout.addLayout(self.tab_bar_layout)
|
||||
self.tab_layout.addWidget(self.tabs)
|
||||
|
||||
|
||||
self.tab_wrapper.setLayout(self.tab_layout)
|
||||
|
||||
|
||||
containerLayout.addWidget(self.tab_wrapper)
|
||||
containerLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||
|
||||
self.consoleLog.setReadOnly(True)
|
||||
self.consoleLog.setFixedHeight(150)
|
||||
self.consoleLog.setStyleSheet("margin-bottom: 0px; background: transparent;")
|
||||
containerLayout.addWidget(self.consoleLog)
|
||||
|
||||
self.statusbar.show()
|
||||
self.statusbar.setStyleSheet("background: transparent; border: none; padding-right: 1px; padding-left: 6px; padding-bottom: 1px; margin-top: -8px")
|
||||
|
||||
self.version = QLabel(f"Version: {state.version}")
|
||||
self.statusbar.addPermanentWidget(self.version, Qt.AlignmentFlag.AlignLeft)
|
||||
|
||||
self.speed_label = QLabel("\u2193 0.0 kB/s \u2191 0.0 kB/s")
|
||||
self.speed_label.setStyleSheet("padding-right: 6px;")
|
||||
self.statusbar.addPermanentWidget(self.speed_label)
|
||||
|
||||
self.setStatusBar(self.statusbar)
|
||||
|
||||
self.download_timer = QTimer()
|
||||
self.download_timer.timeout.connect(self.download_list_update)
|
||||
self.download_timer.start(500)
|
||||
|
||||
self.active_timer = QTimer()
|
||||
self.active_timer.timeout.connect(self.show_empty_downloads)
|
||||
self.active_timer.start(500)
|
||||
|
||||
self.context_menu = QtWidgets.QMenu(self)
|
||||
self.context_menu.addAction("Open Containing Folder", self.openFolderAction)
|
||||
self.context_menu.addAction("Copy Magnet URI", self.copyMagnetURIAction)
|
||||
self.context_menu.addAction("Cancel Download", self.cancelDownloadAction)
|
||||
self.context_menu.addAction("Delete File", self.deleteFileAction)
|
||||
|
||||
def _start_search(self):
|
||||
self.searchbar.setEnabled(False)
|
||||
def _search_thread():
|
||||
try:
|
||||
return_pressed(self)
|
||||
finally:
|
||||
self.search_finished_signal.emit()
|
||||
run_thread(threading.Thread(target=_search_thread))
|
||||
|
||||
def _on_search_finished(self):
|
||||
self.searchbar.setEnabled(True)
|
||||
self.searchbar.setFocus()
|
||||
|
||||
@staticmethod
|
||||
def add_log(text):
|
||||
if MainWindow._instance:
|
||||
MainWindow._instance.log_signal.emit(text)
|
||||
|
||||
def _on_log_signal(self, text):
|
||||
if hasattr(self, 'consoleLog'):
|
||||
self.consoleLog.append(text)
|
||||
self.consoleLog.verticalScrollBar().setValue(
|
||||
self.consoleLog.verticalScrollBar().maximum()
|
||||
)
|
||||
|
||||
def update_image_overlay(self, new_image_path):
|
||||
self.image = QImage(new_image_path)
|
||||
self.pixmap = QPixmap.fromImage(self.image)
|
||||
|
||||
self.overlay_label.setPixmap(self.pixmap)
|
||||
self.overlay_label.adjustSize()
|
||||
|
||||
def download_list_update(self):
|
||||
if self.download_model:
|
||||
row_count = self.download_model.rowCount()
|
||||
if row_count > 0:
|
||||
top_left = self.download_model.index(0, 0)
|
||||
bottom_right = self.download_model.index(row_count - 1, self.download_model.columnCount() - 1)
|
||||
self.download_model.dataChanged.emit(top_left, bottom_right, [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.UserRole])
|
||||
|
||||
if not hasattr(self, '_last_dl_row_count'):
|
||||
self._last_dl_row_count = 0
|
||||
if row_count != self._last_dl_row_count:
|
||||
|
||||
for row in range(row_count, self._last_dl_row_count):
|
||||
idx = self.download_model.index(row, 0)
|
||||
self.downloadList.closePersistentEditor(idx)
|
||||
self._last_dl_row_count = row_count
|
||||
self.download_model.layoutAboutToBeChanged.emit()
|
||||
self.download_model.layoutChanged.emit()
|
||||
for row in range(row_count):
|
||||
idx = self.download_model.index(row, 0)
|
||||
self.downloadList.closePersistentEditor(idx)
|
||||
self.downloadList.openPersistentEditor(idx)
|
||||
else:
|
||||
|
||||
delegate = self.downloadList.itemDelegateForColumn(0)
|
||||
for row in range(row_count):
|
||||
idx = self.download_model.index(row, 0)
|
||||
editor = self.downloadList.indexWidget(idx)
|
||||
if editor and delegate:
|
||||
delegate.setEditorData(editor, idx)
|
||||
self._update_speed_label()
|
||||
|
||||
def _update_speed_label(self):
|
||||
total_down = 0
|
||||
total_up = 0
|
||||
for handle in state.active_downloads.values():
|
||||
try:
|
||||
s = handle.status()
|
||||
total_down += s.download_rate
|
||||
total_up += s.upload_rate
|
||||
except Exception:
|
||||
pass
|
||||
down_kb = total_down / 1024
|
||||
up_kb = total_up / 1024
|
||||
down_text = f"{down_kb / 1024:.1f} MB/s" if down_kb > 1024 else f"{down_kb:.1f} kB/s"
|
||||
up_text = f"{up_kb / 1024:.1f} MB/s" if up_kb > 1024 else f"{up_kb:.1f} kB/s"
|
||||
self.speed_label.setText(f"↓ {down_text} ↑ {up_text}")
|
||||
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
self.rutrackerlist.clearSelection()
|
||||
self.uztrackerlist.clearSelection()
|
||||
self.monkruslist.clearSelection()
|
||||
self.downloadList.clearSelection()
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def changeEvent(self, event):
|
||||
super().changeEvent(event)
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
closehelper()
|
||||
event.accept()
|
||||
from core.utils.general.shutdown import force_exit
|
||||
force_exit()
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
try:
|
||||
for tbl in (self.rutrackerlist, self.uztrackerlist, self.monkruslist):
|
||||
if obj == tbl.viewport():
|
||||
if event.type() == QEvent.Type.MouseMove:
|
||||
pos = event.position().toPoint() if hasattr(event, 'position') else event.pos()
|
||||
idx = tbl.indexAt(pos)
|
||||
new_row = idx.row() if idx.isValid() else -1
|
||||
if new_row != self._tracker_hovered_row or tbl is not self._tracker_hovered_table:
|
||||
self._tracker_hovered_row = new_row
|
||||
self._tracker_hovered_table = tbl
|
||||
tbl.viewport().update()
|
||||
elif event.type() == QEvent.Type.Leave:
|
||||
self._tracker_hovered_row = -1
|
||||
self._tracker_hovered_table = None
|
||||
tbl.viewport().update()
|
||||
break
|
||||
if obj == self.downloadList.viewport():
|
||||
if event.type() == QEvent.Type.MouseMove:
|
||||
pos = event.position().toPoint() if hasattr(event, 'position') else event.pos()
|
||||
idx = self.downloadList.indexAt(pos)
|
||||
new_row = idx.row() if idx.isValid() else -1
|
||||
if new_row != self._hovered_row:
|
||||
old_row = self._hovered_row
|
||||
self._hovered_row = new_row
|
||||
self._invalidate_hover_row(old_row)
|
||||
self._invalidate_hover_row(new_row)
|
||||
elif event.type() == QEvent.Type.Leave:
|
||||
old_row = self._hovered_row
|
||||
self._hovered_row = -1
|
||||
self._invalidate_hover_row(old_row)
|
||||
except RuntimeError:
|
||||
pass
|
||||
return super().eventFilter(obj, event)
|
||||
|
||||
def _invalidate_hover_row(self, row):
|
||||
if row >= 0 and self.download_model:
|
||||
self.downloadList.viewport().update()
|
||||
|
||||
def set_tracker(self, _):
|
||||
old_tracker = state.tracker
|
||||
state.tracker = self.tracker_list.currentText()
|
||||
|
||||
old_widget = state.tracker_list[old_tracker]
|
||||
self.horizontal_layout.removeWidget(old_widget)
|
||||
old_widget.setParent(None)
|
||||
|
||||
tracker_widget = state.tracker_list[state.tracker]
|
||||
self.horizontal_layout.addWidget(tracker_widget)
|
||||
|
||||
def show_empty_results(self, show: bool):
|
||||
if show:
|
||||
state.tracker_list[state.tracker].hide()
|
||||
self.emptyResults.show()
|
||||
else:
|
||||
state.tracker_list[state.tracker].show()
|
||||
self.emptyResults.hide()
|
||||
|
||||
def show_empty_downloads(self):
|
||||
if len(state.active_downloads) > 0:
|
||||
self.emptyDownload.hide()
|
||||
self.downloadList.show()
|
||||
else:
|
||||
self.emptyDownload.show()
|
||||
self.downloadList.hide()
|
||||
|
||||
# thank you claude
|
||||
def resizeEvent(self, event):
|
||||
super().resizeEvent(event)
|
||||
table_width = state.tracker_list[state.tracker].viewport().width()
|
||||
state.tracker_list[state.tracker].setColumnWidth(1, int(table_width * 0.3))
|
||||
|
||||
def contextMenuEvent(self, event: QContextMenuEvent):
|
||||
if self.downloadList.underMouse():
|
||||
pos = self.downloadList.viewport().mapFromGlobal(event.globalPos())
|
||||
index = self.downloadList.indexAt(pos)
|
||||
|
||||
if index.isValid():
|
||||
row = index.row()
|
||||
self._context_menu_row = row
|
||||
self.context_menu.exec(event.globalPos())
|
||||
else:
|
||||
super().contextMenuEvent(event)
|
||||
|
||||
def openFolderAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
|
||||
download_path = magnetdl.save_path()
|
||||
|
||||
if download_path and os.path.exists(download_path):
|
||||
if platform.system() == "Windows":
|
||||
os.startfile(os.path.normpath(download_path))
|
||||
elif platform.system() == "Linux":
|
||||
subprocess.Popen(["xdg-open", download_path])
|
||||
elif platform.system() == "Darwin":
|
||||
subprocess.Popen(["open", download_path])
|
||||
|
||||
def copyMagnetURIAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[row]
|
||||
|
||||
clipboard = QtWidgets.QApplication.clipboard()
|
||||
clipboard.setText(magnet_link)
|
||||
|
||||
def cancelDownloadAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
|
||||
confirm = QMessageBox.question(self, "Cancel Download", f"Are you sure you want to cancel the download of '{magnetdl.status().name}'?", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||
if confirm == QMessageBox.StandardButton.Yes:
|
||||
del state.active_downloads[magnet_link]
|
||||
remove_download_log(magnet_link)
|
||||
consoleLog(f"Cancelled download: {magnetdl.status().name}", True)
|
||||
|
||||
def deleteFileAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
|
||||
row = self._context_menu_row
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
|
||||
magnet_link = list(state.active_downloads.keys())[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
save_path = status.save_path
|
||||
torrent_name = status.name
|
||||
download_path = os.path.join(save_path, torrent_name)
|
||||
|
||||
confirm = QMessageBox.question(self, "Delete Files", f"Are you sure you want to delete the downloaded files of '{magnetdl.status().name}'? This action cannot be undone.", QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No)
|
||||
if confirm == QMessageBox.StandardButton.Yes:
|
||||
if download_path and os.path.exists(download_path):
|
||||
try:
|
||||
if os.path.isfile(download_path):
|
||||
remove_download_log(magnet_link)
|
||||
os.remove(download_path)
|
||||
del state.active_downloads[magnet_link]
|
||||
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
|
||||
else:
|
||||
import shutil
|
||||
del state.active_downloads[magnet_link]
|
||||
remove_download_log(magnet_link)
|
||||
shutil.rmtree(download_path)
|
||||
consoleLog(f"Deleted files for: {magnetdl.status().name}", True)
|
||||
except Exception as e:
|
||||
consoleLog(f"Error deleting files: {e}", True)
|
||||
@@ -1,66 +0,0 @@
|
||||
from PySide6.QtWidgets import QTableWidgetItem
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.data.scrapers.uztracker import scrape_uztracker
|
||||
from core.data.scrapers.rutracker import scrape_rutracker
|
||||
from core.data.scrapers.monkrus import scrape_m0nkrus
|
||||
from core.utils.network.jsonhandler import split_data, format_data, format_data_minimal
|
||||
from core.utils.data.state import state
|
||||
|
||||
scrapers = {
|
||||
"uztracker": scrape_uztracker,
|
||||
"rutracker": scrape_rutracker,
|
||||
"m0nkrus": scrape_m0nkrus
|
||||
}
|
||||
|
||||
def return_pressed(self):
|
||||
search_text = self.searchbar.text()
|
||||
if search_text == "":
|
||||
consoleLog("Error: Can't search for nothing")
|
||||
return
|
||||
consoleLog(f"User searched for: {search_text}")
|
||||
|
||||
if state.tracker == "rutracker":
|
||||
response = scrape_rutracker(search_text)
|
||||
if response:
|
||||
_, state.posts, _, _, cached = split_data(response)
|
||||
if state.posts == []:
|
||||
consoleLog(f"No Results for {search_text}")
|
||||
state.tracker_list[state.tracker].clear()
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
state.post_titles, _, state.post_author, state.post_seeders, state.post_leechers = format_data(state.posts)
|
||||
self.show_empty_results(False)
|
||||
state.tracker_list[state.tracker].clear()
|
||||
state.tracker_list[state.tracker].setHorizontalHeaderLabels(["Post Title", "Author", "Seeders", "Leechers"])
|
||||
state.tracker_list[state.tracker].setRowCount(len(state.post_titles))
|
||||
for i, author in enumerate(state.post_author):
|
||||
state.tracker_list[state.tracker].setItem(i, 1, QTableWidgetItem(author))
|
||||
for i, title in enumerate(state.post_titles):
|
||||
state.tracker_list[state.tracker].setItem(i, 0, QTableWidgetItem(title))
|
||||
for i, seeders in enumerate(state.post_seeders):
|
||||
state.tracker_list[state.tracker].setItem(i, 2, QTableWidgetItem(seeders))
|
||||
for i, leechers in enumerate(state.post_leechers):
|
||||
state.tracker_list[state.tracker].setItem(i, 3, QTableWidgetItem(leechers))
|
||||
if state.debug == True:
|
||||
consoleLog(f"Response Cached: {cached}")
|
||||
else:
|
||||
consoleLog(f"No response from rutracker")
|
||||
state.tracker_list[state.tracker].clear()
|
||||
self.show_empty_results(True)
|
||||
|
||||
elif state.tracker is not None:
|
||||
state.posts = scrapers[state.tracker](search_text)
|
||||
if not state.posts:
|
||||
consoleLog(f"No Results for {search_text}")
|
||||
state.tracker_list[state.tracker].clear()
|
||||
self.show_empty_results(True)
|
||||
else:
|
||||
state.post_author, state.post_titles, state.post_urls = format_data_minimal(state.posts)
|
||||
self.show_empty_results(False)
|
||||
state.tracker_list[state.tracker].clear()
|
||||
state.tracker_list[state.tracker].setHorizontalHeaderLabels(["Post Title", "Author"])
|
||||
state.tracker_list[state.tracker].setRowCount(len(state.post_titles))
|
||||
for i, author in enumerate(state.post_author):
|
||||
state.tracker_list[state.tracker].setItem(i, 1, QTableWidgetItem(author))
|
||||
for i, title in enumerate(state.post_titles):
|
||||
state.tracker_list[state.tracker].setItem(i, 0, QTableWidgetItem(title))
|
||||
@@ -1,56 +0,0 @@
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout
|
||||
|
||||
|
||||
def create_tab(title, searchbar, software_list, tabs, dlbutton, layout2):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
if searchbar:
|
||||
layout.addWidget(searchbar)
|
||||
if layout2:
|
||||
layout.addLayout(layout2)
|
||||
else:
|
||||
layout.addWidget(software_list)
|
||||
if dlbutton:
|
||||
layout.addWidget(dlbutton)
|
||||
tab.setLayout(layout)
|
||||
tabs.addTab(tab, title)
|
||||
return tab
|
||||
|
||||
#################
|
||||
# SETTINGS TABS #
|
||||
#################
|
||||
def general_tab(title, autoresume, update_checkbox, transparent_window, tabs):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(autoresume)
|
||||
layout.addWidget(update_checkbox)
|
||||
layout.addWidget(transparent_window)
|
||||
layout.addStretch()
|
||||
tab.setLayout(layout)
|
||||
tabs.addTab(tab, title)
|
||||
return tab
|
||||
|
||||
def paths_tab(title, download_path, tabs):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(download_path)
|
||||
# layout.addWidget(image_path)
|
||||
layout.addStretch()
|
||||
tab.setLayout(layout)
|
||||
tabs.addTab(tab, title)
|
||||
return tab
|
||||
|
||||
|
||||
def network_tab(title, network_interface, max_connections, max_downloads, up_speed_limit, down_speed_limit, api_url, tabs):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
layout.addWidget(network_interface)
|
||||
layout.addWidget(max_connections)
|
||||
layout.addWidget(max_downloads)
|
||||
layout.addWidget(up_speed_limit)
|
||||
layout.addWidget(down_speed_limit)
|
||||
layout.addWidget(api_url)
|
||||
layout.addStretch()
|
||||
tab.setLayout(layout)
|
||||
tabs.addTab(tab, title)
|
||||
return tab
|
||||
@@ -1,174 +0,0 @@
|
||||
import time
|
||||
import os
|
||||
from core.utils.general.wrappers import run_thread
|
||||
from core.network.interface import get_interface_ip
|
||||
import threading
|
||||
import libtorrent as lt
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.utils.general.shutdown import shutdown_event
|
||||
|
||||
|
||||
global loop_running
|
||||
loop_running = False
|
||||
|
||||
def init_session():
|
||||
if state.dl_session is not None:
|
||||
return
|
||||
|
||||
state.dl_session = lt.session()
|
||||
|
||||
|
||||
settings = {
|
||||
"upload_rate_limit": state.up_speed_limit,
|
||||
"download_rate_limit": state.down_speed_limit,
|
||||
"enable_dht": True,
|
||||
"enable_lsd": True,
|
||||
"enable_upnp": True,
|
||||
"enable_natpmp": True,
|
||||
"dht_bootstrap_nodes": "router.bittorrent.com:6881,dht.transmissionbt.com:6881",
|
||||
"connections_limit": state.max_connections,
|
||||
"active_downloads": state.max_downloads
|
||||
}
|
||||
|
||||
if state.bound_interface:
|
||||
interface_ip = get_interface_ip(state.bound_interface)
|
||||
if interface_ip:
|
||||
settings["outgoing_interfaces"] = interface_ip
|
||||
settings["listen_interfaces"] = f"{interface_ip}:6881"
|
||||
consoleLog(f"Binding to Interface IP: {interface_ip}")
|
||||
else:
|
||||
consoleLog(f"Skipping Binding, no Interface set. ({state.bound_interface})")
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
|
||||
consoleLog("Initialized Session")
|
||||
|
||||
|
||||
def add_download(magnet_uri, dl_path=state.download_path):
|
||||
|
||||
if state.active_downloads is None:
|
||||
state.active_downloads = {}
|
||||
|
||||
init_session()
|
||||
|
||||
if magnet_uri in state.active_downloads:
|
||||
try:
|
||||
handle = state.active_downloads[magnet_uri]
|
||||
status = handle.status()
|
||||
except RuntimeError as e:
|
||||
consoleLog(f"Error in LibTorrent Handle: {e}")
|
||||
|
||||
if status.has_metadata:
|
||||
filepath = os.path.join(status.save_path, status.name)
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
|
||||
consoleLog(f"File Deleted, redownloading: {status.name}")
|
||||
state.dl_session.remove_torrent(handle)
|
||||
del state.active_downloads[magnet_uri]
|
||||
else:
|
||||
consoleLog("Skipping Downloading, download already running...")
|
||||
return False
|
||||
else:
|
||||
consoleLog("Skipping Downloading, download already running... ")
|
||||
return False
|
||||
|
||||
try:
|
||||
magnetdl = lt.parse_magnet_uri(magnet_uri)
|
||||
magnetdl.save_path = dl_path
|
||||
download = state.dl_session.add_torrent(magnetdl)
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to add torrent: {e}")
|
||||
return False
|
||||
state.active_downloads[magnet_uri] = download
|
||||
consoleLog(f"Added {magnet_uri} to downloads")
|
||||
|
||||
run_thread(threading.Thread(target=dl_status_loop))
|
||||
return True
|
||||
|
||||
|
||||
def add_seed(magnet_uri, file_path):
|
||||
if state.active_downloads is None:
|
||||
state.active_downloads = {}
|
||||
|
||||
init_session()
|
||||
|
||||
if magnet_uri in state.active_downloads:
|
||||
consoleLog("Already seeding this torrent")
|
||||
return False
|
||||
|
||||
try:
|
||||
magnetdl = lt.parse_magnet_uri(magnet_uri)
|
||||
magnetdl.save_path = os.path.dirname(file_path)
|
||||
handle = state.dl_session.add_torrent(magnetdl)
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to add seed: {e}")
|
||||
return False
|
||||
state.active_downloads[magnet_uri] = handle
|
||||
state.seeded_magnets.add(magnet_uri)
|
||||
return True
|
||||
|
||||
|
||||
def dl_status_loop():
|
||||
global loop_running
|
||||
if loop_running == True:
|
||||
return
|
||||
|
||||
loop_running = True
|
||||
completed_set = set()
|
||||
|
||||
if not state.active_downloads:
|
||||
consoleLog("No active downloads")
|
||||
loop_running = False
|
||||
return
|
||||
|
||||
while state.active_downloads and not shutdown_event.is_set():
|
||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||
try:
|
||||
status = magnetdl.status()
|
||||
except RuntimeError:
|
||||
continue
|
||||
|
||||
if status.state == lt.torrent_status.seeding and magnet_uri not in completed_set:
|
||||
consoleLog(f"Download completed: {status.name}")
|
||||
|
||||
completed_set.add(magnet_uri)
|
||||
|
||||
if not state.active_downloads:
|
||||
loop_running = False
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
loop_running = False
|
||||
|
||||
def update_settings():
|
||||
|
||||
if state.dl_session is None:
|
||||
return
|
||||
|
||||
settings = {
|
||||
"upload_rate_limit": state.up_speed_limit,
|
||||
"download_rate_limit": state.down_speed_limit,
|
||||
"connections_limit": state.max_connections,
|
||||
"active_downloads": state.max_downloads
|
||||
}
|
||||
|
||||
if state.bound_interface:
|
||||
interface_ip = get_interface_ip(state.bound_interface)
|
||||
if interface_ip:
|
||||
settings["outgoing_interfaces"] = interface_ip
|
||||
settings["listen_interfaces"] = f"{interface_ip}:6881"
|
||||
consoleLog(f"Binding to Interface IP: {interface_ip}")
|
||||
else:
|
||||
consoleLog(f"Skipping Binding, no Interface set. ({state.bound_interface})")
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
|
||||
def update_bound_interface():
|
||||
|
||||
settings = { "outgoing_interfaces": state.bound_interface }
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import update_download_completed_by_hash
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from plyer import notification
|
||||
import libtorrent as lt
|
||||
import os
|
||||
import time
|
||||
|
||||
|
||||
def cleanup_session():
|
||||
if state.dl_session is not None:
|
||||
for magnetdl in state.active_downloads.values():
|
||||
if hasattr(magnetdl, 'pause'): # Check it's a handle
|
||||
magnetdl.pause()
|
||||
|
||||
del state.dl_session
|
||||
state.dl_session = None
|
||||
state.active_downloads.clear()
|
||||
|
||||
|
||||
|
||||
|
||||
def send_notification(shutdown_event):
|
||||
notified = set()
|
||||
while not shutdown_event.is_set():
|
||||
try:
|
||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||
if isinstance(magnetdl, dict):
|
||||
continue
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding and magnet_uri not in notified:
|
||||
notification.notify(
|
||||
title="Download finished",
|
||||
message=f"{status.name} has finished downloading.",
|
||||
timeout=4
|
||||
)
|
||||
notified.add(magnet_uri)
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(5)
|
||||
|
||||
def update_log(shutdown_event):
|
||||
updated = set()
|
||||
while not shutdown_event.is_set():
|
||||
try:
|
||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||
if isinstance(magnetdl, dict):
|
||||
continue
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding and magnet_uri not in updated and magnet_uri not in state.seeded_magnets:
|
||||
consoleLog(f"Marking {status.name} as completed")
|
||||
info_hash = str(status.info_hash)
|
||||
update_download_completed_by_hash(info_hash, True)
|
||||
updated.add(magnet_uri)
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(5)
|
||||
|
||||
def check_deleted_files(shutdown_event):
|
||||
while not shutdown_event.is_set():
|
||||
try:
|
||||
for magnet_uri, magnetdl in list(state.active_downloads.items()):
|
||||
if isinstance(magnetdl, dict):
|
||||
continue
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding and status.has_metadata:
|
||||
file_path = os.path.join(status.save_path, status.name)
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
consoleLog(f"Registered File Deletion: {status.name}")
|
||||
state.dl_session.remove_torrent(magnetdl)
|
||||
del state.active_downloads[magnet_uri]
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(5)
|
||||
@@ -1,77 +0,0 @@
|
||||
import os
|
||||
import platform
|
||||
import configparser
|
||||
from core.utils.data.state import state
|
||||
|
||||
def create_config():
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config["General"] = {
|
||||
"debug": True,
|
||||
"ignore_updates": f"{state.ignore_updates}",
|
||||
"autoresume": f"{state.autoresume}",
|
||||
"window_transparency": f"{state.window_transparency}"
|
||||
}
|
||||
|
||||
config["Network"] = {
|
||||
"api_url": f"{state.api_url}",
|
||||
"download_path": f"{state.download_path}",
|
||||
"download_speed_limit": f"{state.down_speed_limit}",
|
||||
"upload_speed_limit": f"{state.up_speed_limit}",
|
||||
"max_connections": f"{state.max_connections}",
|
||||
"max_downloads": f"{state.max_downloads}"
|
||||
}
|
||||
|
||||
config["Paths"] = {
|
||||
"bound_interface": f"{state.bound_interface}",
|
||||
"image_path": f"{state.image_path}"
|
||||
}
|
||||
|
||||
if platform.system() == "Windows":
|
||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||
else:
|
||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||
|
||||
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||
os.makedirs(state.settings_path, exist_ok=True)
|
||||
|
||||
with open(os.path.join(state.settings_path, "config.yml"), 'w') as cf:
|
||||
config.write(cf)
|
||||
|
||||
|
||||
def read_config():
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if platform.system() == "Windows":
|
||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||
else:
|
||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||
config_file = os.path.join(state.settings_path, "config.yml")
|
||||
|
||||
if not os.path.exists(config_file):
|
||||
create_config()
|
||||
return
|
||||
|
||||
config.read(config_file)
|
||||
|
||||
# General
|
||||
state.debug = config.getboolean("General", "debug", fallback=state.debug)
|
||||
state.ignore_updates = config.getboolean("General", "ignore_updates", fallback=state.ignore_updates)
|
||||
state.autoresume = config.getboolean("General", "autoresume", fallback=state.autoresume)
|
||||
state.window_transparency = config.getboolean("General", "window_transparency", fallback=state.window_transparency)
|
||||
|
||||
# Network
|
||||
state.api_url = config.get("Network", "api_url", fallback=state.api_url)
|
||||
state.download_path = config.get("Network", "download_path", fallback=state.download_path)
|
||||
state.down_speed_limit = config.getint("Network", "download_speed_limit", fallback=state.down_speed_limit)
|
||||
state.up_speed_limit = config.getint("Network", "upload_speed_limit", fallback=state.up_speed_limit)
|
||||
state.max_connections = config.getint("Network", "max_connections", fallback=state.max_connections)
|
||||
state.max_downloads = config.getint("Network", "max_downloads", fallback=state.max_downloads)
|
||||
|
||||
# Paths
|
||||
state.bound_interface = config.get("Paths", "bound_interface", fallback=state.bound_interface)
|
||||
state.image_path = config.get("Paths", "image_path", fallback=state.image_path)
|
||||
|
||||
create_config()
|
||||
@@ -1,31 +0,0 @@
|
||||
from core.network.libtorrent_int import update_settings
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from .config import create_config
|
||||
|
||||
|
||||
def save_settings(close=lambda: None, apiurl=None, download_path=None, down_speed_limit=None, up_speed_limit=None, image_path=None, autoresume=None, max_connections=None, max_downloads=None, bound_interface=None):
|
||||
if apiurl is not None:
|
||||
state.api_url = apiurl
|
||||
if download_path is not None:
|
||||
state.download_path = download_path
|
||||
if down_speed_limit is not None:
|
||||
state.down_speed_limit = down_speed_limit
|
||||
if up_speed_limit is not None:
|
||||
state.up_speed_limit = up_speed_limit
|
||||
if image_path is not None:
|
||||
state.image_path = image_path
|
||||
if autoresume is not None:
|
||||
state.autoresume = autoresume
|
||||
if max_connections is not None:
|
||||
state.max_connections = max_connections
|
||||
if max_downloads is not None:
|
||||
state.max_downloads = max_downloads
|
||||
if bound_interface is not None:
|
||||
state.bound_interface = None if bound_interface == "None" else bound_interface
|
||||
|
||||
|
||||
update_settings()
|
||||
consoleLog("Saved Settings")
|
||||
create_config()
|
||||
close()
|
||||
@@ -1,49 +0,0 @@
|
||||
from PySide6.QtCore import QObject, Signal
|
||||
from PySide6.QtWidgets import QTableWidget
|
||||
from typing import Optional, Any, List, Dict
|
||||
from pathlib import Path
|
||||
|
||||
class AppState(QObject):
|
||||
image_changed = Signal(str)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.posts: list[Any] | None = None
|
||||
self.post_titles: Optional[List] = None
|
||||
self.post_urls: Optional[List] = None
|
||||
self.post_author: List[str] = []
|
||||
self.post_seeders: List[str] = []
|
||||
self.post_leechers: List[str] = []
|
||||
self.version: str = "dev"
|
||||
self._image_path: str = ""
|
||||
self.ignore_updates: bool = False
|
||||
self.debug: bool = False
|
||||
self.autoresume: bool = True
|
||||
self.tracker: str = "rutracker"
|
||||
self.tracker_list: dict[str, QTableWidget] = {}
|
||||
self.api_url: str = "https://api.michijackson.xyz"
|
||||
self.download_path: str = str(Path.home() / "Downloads")
|
||||
self.up_speed_limit: int = 0
|
||||
self.down_speed_limit: int = 0
|
||||
self.max_connections: int = 200
|
||||
self.max_downloads: int = 10
|
||||
self.settings_path: str = ""
|
||||
self.dl_session: Any = None
|
||||
self.active_downloads: Dict = {}
|
||||
self.seeded_magnets: set = set()
|
||||
self.window_transparency: bool = False
|
||||
self.interfaces: List = []
|
||||
self.active_interfaces: List = []
|
||||
self.bound_interface: Any = None
|
||||
|
||||
@property
|
||||
def image_path(self) -> str:
|
||||
return self._image_path
|
||||
|
||||
@image_path.setter
|
||||
def image_path(self, new_path: str):
|
||||
if new_path != self._image_path:
|
||||
self._image_path = new_path
|
||||
self.image_changed.emit(new_path)
|
||||
|
||||
state = AppState()
|
||||
@@ -1,46 +0,0 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.utils.network.jsonhandler import format_data
|
||||
|
||||
|
||||
|
||||
def get_item_url(item, posts, post_titles): # softwarelist currentitem, post list (dict), post titles list
|
||||
post_index = post_titles.index(item)
|
||||
if 0 <= post_index < len(post_titles):
|
||||
if state.tracker == "uztracker":
|
||||
item = "https://uztracker.net/" + state.post_urls[post_index].lstrip("./")
|
||||
consoleLog(f"Found post URL: {item}")
|
||||
return item
|
||||
if state.tracker == "rutracker":
|
||||
item_dict = posts[post_index]
|
||||
_, post_links, _, _, _ = format_data([item_dict])
|
||||
consoleLog(f"Found post URL: {post_links[0]}")
|
||||
return post_links[0]
|
||||
if state.tracker == "m0nkrus":
|
||||
item_dict = posts[post_index]
|
||||
_, post_links, _, _, _,= format_data([item_dict])
|
||||
consoleLog(f"Found post URL: {post_links[0]}")
|
||||
return post_links[0]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def get_magnet_link(post_url):
|
||||
try:
|
||||
response = requests.get(post_url, timeout=15) # eventually impl. cloudscraper
|
||||
consoleLog("Sent Request to retrieve Magnet Link...")
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||
if magnet_link:
|
||||
consoleLog(f"Magnet Link Retrieved: {magnet_link['href']}")
|
||||
return magnet_link['href']
|
||||
else:
|
||||
consoleLog("Magnet Link not Found!")
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Failed to fetch {post_url}: {e}")
|
||||
return None
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import threading
|
||||
import os
|
||||
|
||||
shutdown_event = threading.Event()
|
||||
|
||||
def closehelper():
|
||||
shutdown_event.set()
|
||||
|
||||
def force_exit():
|
||||
os._exit(0)
|
||||
@@ -1,2 +0,0 @@
|
||||
def run_thread(thread):
|
||||
thread.start()
|
||||
@@ -1,40 +0,0 @@
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.utils.data.tracker import get_item_url
|
||||
from core.utils.data.tracker import get_magnet_link
|
||||
from core.network.libtorrent_wrapper import add_download
|
||||
from core.utils.general.wrappers import run_thread
|
||||
from core.utils.logging.logs import add_download_log
|
||||
from core.network.libtorrent_int import add_seed
|
||||
import threading
|
||||
|
||||
|
||||
def download_selected(items, posts, post_titles):
|
||||
if not items:
|
||||
consoleLog("No item selected for download.")
|
||||
return
|
||||
seen = set()
|
||||
for item in items:
|
||||
if item.column() != 0:
|
||||
continue
|
||||
text = item.text()
|
||||
if text and text not in seen:
|
||||
seen.add(text)
|
||||
consoleLog(f"Downloading {text}")
|
||||
run_thread(threading.Thread(target=run_download, args=(text, posts, post_titles)))
|
||||
|
||||
def run_download(item, posts, post_titles):
|
||||
post_url = get_item_url(item, posts, post_titles)
|
||||
consoleLog(f"Selected URL: {post_url}")
|
||||
magnet_uri = get_magnet_link(post_url)
|
||||
|
||||
if add_download(magnet_uri):
|
||||
add_download_log(item, post_url, magnet_uri, False)
|
||||
|
||||
def run_download_direct(magnet_uri):
|
||||
consoleLog(f"Direct download: {magnet_uri[:60]}")
|
||||
add_download(magnet_uri)
|
||||
add_download_log("Direct Download", "", magnet_uri, False)
|
||||
|
||||
def seed_magnet(magnet_uri, file_path):
|
||||
consoleLog(f"Seeding: {magnet_uri[:60]}")
|
||||
add_seed(magnet_uri, file_path)
|
||||
@@ -1,31 +0,0 @@
|
||||
import requests
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
|
||||
def check_for_updates():
|
||||
url = f"https://api.github.com/repos/KeksPirates/SoftwareManager/releases"
|
||||
response = requests.get(url, timeout=15)
|
||||
|
||||
if response.status_code != 200:
|
||||
consoleLog(f"Failed to fetch releases: {response.status_code}")
|
||||
return None, None
|
||||
|
||||
releases = response.json()
|
||||
releases.sort(key=lambda r: r["published_at"], reverse=True)
|
||||
|
||||
latest_release = releases[0]
|
||||
latest_version = latest_release["name"]
|
||||
assets = latest_release["assets"]
|
||||
|
||||
if latest_version != state.version:
|
||||
consoleLog(f"New release available: {latest_version}")
|
||||
if assets:
|
||||
consoleLog("Assets:")
|
||||
for asset in assets:
|
||||
consoleLog(f" - {asset['name']}: {asset['browser_download_url']}")
|
||||
return assets, latest_version
|
||||
else:
|
||||
return None, None
|
||||
else:
|
||||
consoleLog("Already up-to-date.")
|
||||
return None, None
|
||||
@@ -0,0 +1,26 @@
|
||||
from utils.logging.logs import consoleLog
|
||||
import requests
|
||||
|
||||
def scrape_buzzheavier(url):
|
||||
try:
|
||||
response = requests.get(url, timeout=15)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Buzzheavier: Failed to fetch page - {e}")
|
||||
return None
|
||||
|
||||
download_url = url + '/download'
|
||||
|
||||
headers = {
|
||||
'hx-current-url': url,
|
||||
'hx-request': 'true',
|
||||
'referer': url
|
||||
}
|
||||
|
||||
try:
|
||||
head_response = requests.head(download_url, headers=headers, allow_redirects=False, timeout=15)
|
||||
hx_redirect = head_response.headers.get('hx-redirect')
|
||||
return hx_redirect
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Buzzheavier: Failed to fetch download URL - {e}")
|
||||
return None
|
||||
@@ -0,0 +1,66 @@
|
||||
from utils.logging.logs import consoleLog
|
||||
import requests
|
||||
import hashlib
|
||||
import time
|
||||
import re
|
||||
|
||||
_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
||||
_WT_SECRET = "5d4f7g8sd45fsd"
|
||||
_API_BASE = "https://api.gofile.io"
|
||||
|
||||
|
||||
def _generate_website_token(account_token):
|
||||
time_bucket = str(int(time.time() / 14400))
|
||||
raw = f"{_USER_AGENT}::en-US::{account_token}::{time_bucket}::{_WT_SECRET}"
|
||||
return hashlib.sha256(raw.encode()).hexdigest()
|
||||
|
||||
|
||||
def scrape_gofile(url):
|
||||
match = re.search(r"gofile\.io/d/([a-zA-Z0-9]+)", url)
|
||||
if not match:
|
||||
consoleLog("GoFile: Invalid URL")
|
||||
return None
|
||||
|
||||
content_id = match.group(1)
|
||||
session = requests.Session()
|
||||
try:
|
||||
# Create a guest account
|
||||
r = session.post(f"{_API_BASE}/accounts", headers={"User-Agent": _USER_AGENT}, timeout=15)
|
||||
data = r.json()
|
||||
if data.get("status") != "ok":
|
||||
consoleLog("GoFile: Failed to create guest account")
|
||||
return None
|
||||
|
||||
account_token = data["data"]["token"]
|
||||
website_token = _generate_website_token(account_token)
|
||||
|
||||
headers = {
|
||||
"User-Agent": _USER_AGENT,
|
||||
"Authorization": f"Bearer {account_token}",
|
||||
"X-Website-Token": website_token,
|
||||
"X-BL": "en-US",
|
||||
"Referer": "https://gofile.io/",
|
||||
"Origin": "https://gofile.io",
|
||||
}
|
||||
|
||||
# Fetch folder contents
|
||||
r = session.get(f"{_API_BASE}/contents/{content_id}", headers=headers, timeout=15)
|
||||
data = r.json()
|
||||
if data.get("status") != "ok":
|
||||
consoleLog(f"GoFile: API error - {data.get('status')}")
|
||||
return None
|
||||
|
||||
children = data["data"].get("children", {})
|
||||
if not children:
|
||||
consoleLog("GoFile: No files found")
|
||||
return None
|
||||
|
||||
first_child = next(iter(children.values()))
|
||||
link = first_child.get("link")
|
||||
if not link:
|
||||
consoleLog("GoFile: No download link in response")
|
||||
return None
|
||||
|
||||
return link, headers
|
||||
finally:
|
||||
session.close()
|
||||
@@ -0,0 +1,43 @@
|
||||
from interface.dialogs.notificationpopup import NotificationPopup
|
||||
from utils.config.settings import save_settings
|
||||
from PySide6.QtCore import QObject, Signal, Qt
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import webbrowser
|
||||
import re
|
||||
|
||||
class UIBridge(QObject):
|
||||
show_notification = Signal()
|
||||
|
||||
ui_bridge = UIBridge()
|
||||
|
||||
def show_megadb_notification():
|
||||
notification_popup = NotificationPopup(title="Opened MegaDB link in browser",
|
||||
text="Beware of malicious Ads. Make sure to have an adblocker installed.\n" '<br><a href="https://ublockorigin.com">Visit uBlock Origin</a>',
|
||||
darkmode=False if state.window_transparency else True
|
||||
)
|
||||
|
||||
notification_popup.setTextFormat(Qt.TextFormat.RichText)
|
||||
notification_popup.setTextInteractionFlags(Qt.TextInteractionFlag.TextBrowserInteraction)
|
||||
|
||||
if state.window_transparency is True:
|
||||
notification_popup.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
button = notification_popup.addButton("Don't show again", QMessageBox.ButtonRole.AcceptRole)
|
||||
button.clicked.connect(lambda: setattr(state, "show_megadb_notification", False))
|
||||
|
||||
save_settings(show_megadb_notification=state.show_megadb_notification)
|
||||
notification_popup.exec()
|
||||
|
||||
def scrape_megadb(url):
|
||||
match = re.search(r"megadb\.net/([a-zA-Z0-9]+)", url)
|
||||
if not match:
|
||||
consoleLog("MegaDB: Invalid URL")
|
||||
return None
|
||||
|
||||
consoleLog("MegaDB: Captcha required, launching browser...")
|
||||
webbrowser.open(url)
|
||||
if state.show_megadb_notification is True:
|
||||
ui_bridge.show_notification.emit()
|
||||
return None
|
||||
@@ -0,0 +1,14 @@
|
||||
from utils.logging.logs import consoleLog
|
||||
import webbrowser
|
||||
import re
|
||||
|
||||
|
||||
def scrape_vikingfile(url):
|
||||
match = re.search(r"vikingfile\.com/f/([a-zA-Z0-9]+)", url)
|
||||
if not match:
|
||||
consoleLog("VikingFile: Invalid URL")
|
||||
return None
|
||||
|
||||
consoleLog("VikingFile: Captcha required, launching browser...")
|
||||
webbrowser.open(url)
|
||||
return None
|
||||
@@ -0,0 +1,12 @@
|
||||
from data.sources.rutracker import RutrackerScraper
|
||||
from data.sources.uztracker import UztrackerScraper
|
||||
from data.sources.steamrip import SteamripScraper
|
||||
from data.sources.monkrus import MonkrusScraper
|
||||
|
||||
# Register Scrapers here
|
||||
SCRAPERS = [
|
||||
RutrackerScraper(),
|
||||
SteamripScraper(),
|
||||
MonkrusScraper(),
|
||||
UztrackerScraper(),
|
||||
]
|
||||
@@ -0,0 +1,78 @@
|
||||
from utils.data.tracker import get_magnet_link
|
||||
from bs4 import BeautifulSoup
|
||||
from typing import Dict
|
||||
import requests
|
||||
import time
|
||||
|
||||
|
||||
class MonkrusScraper:
|
||||
name = "m0nkrus"
|
||||
headers = ["Post Title", "Author"]
|
||||
is_magnet = True
|
||||
|
||||
def __init__(self):
|
||||
self.cache = { "data": [], "last_fetched": 0 }
|
||||
self.cache_expiry = 300
|
||||
|
||||
def _get_telegram_posts(self):
|
||||
post = 100
|
||||
max_posts = 250
|
||||
posts = []
|
||||
added = set()
|
||||
|
||||
current_time = time.time()
|
||||
|
||||
if self.cache["data"] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
||||
return self.cache["data"]
|
||||
|
||||
while post <= max_posts:
|
||||
url = f"https://t.me/s/real_monkrus/{post}"
|
||||
response = requests.get(url, timeout=10)
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
bubbles = soup.find_all("div", class_="tgme_widget_message_bubble")
|
||||
|
||||
if not bubbles:
|
||||
break
|
||||
|
||||
for bubble in bubbles:
|
||||
post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text")
|
||||
if post_txt is None or post_txt.b is None:
|
||||
continue
|
||||
|
||||
title = post_txt.b.text
|
||||
link = bubble.find("a", href=lambda x: x and x.startswith("https://uztracker.net"))
|
||||
|
||||
if link:
|
||||
post_url = link["href"]
|
||||
if post_url not in added:
|
||||
added.add(post_url)
|
||||
posts.append(dict(
|
||||
title=title,
|
||||
author="m0nkrus",
|
||||
id=len(posts) + 1,
|
||||
url=post_url
|
||||
))
|
||||
|
||||
post += 22
|
||||
|
||||
posts.reverse()
|
||||
|
||||
self.cache["data"] = posts
|
||||
self.cache["last_fetched"] = current_time
|
||||
|
||||
return(posts)
|
||||
|
||||
def search(self, query):
|
||||
posts = self._get_telegram_posts()
|
||||
filtered_posts = []
|
||||
|
||||
for post in posts:
|
||||
if query.lower() in post["title"].lower():
|
||||
filtered_post = post.copy()
|
||||
filtered_post["id"] = len(filtered_posts) + 1
|
||||
filtered_posts.append(filtered_post)
|
||||
|
||||
return filtered_posts
|
||||
|
||||
def get_download_link(self, post: Dict):
|
||||
return get_magnet_link(post["url"])
|
||||
@@ -0,0 +1,55 @@
|
||||
from utils.network.jsonhandler import split_data, format_data
|
||||
from utils.data.tracker import get_magnet_link
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
from urllib.parse import quote
|
||||
from typing import Dict
|
||||
import requests
|
||||
|
||||
class RutrackerScraper:
|
||||
name = "rutracker"
|
||||
headers = ["Post Title", "Author", "Seeders", "Leechers"]
|
||||
is_magnet = True
|
||||
|
||||
def search(self, query):
|
||||
try:
|
||||
search = requests.get(f"{state.api_url}/search?q={quote(query)}", timeout=15)
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Failed to reach server: {e}")
|
||||
return []
|
||||
consoleLog("Sent request to server")
|
||||
if search:
|
||||
try:
|
||||
_, data, _, success, cached = split_data(search.text)
|
||||
except (KeyError, ValueError) as e:
|
||||
consoleLog(f"Failed to parse server response: {e}")
|
||||
return []
|
||||
if cached:
|
||||
consoleLog("Server response cached")
|
||||
if success:
|
||||
sorted_data = []
|
||||
|
||||
for entry in data:
|
||||
sorted_data.append(
|
||||
{
|
||||
"title" : entry["title"],
|
||||
"author" : entry["author"],
|
||||
"seeders" : entry["seeders"],
|
||||
"leechers" : entry["leechers"],
|
||||
"url" : entry["url"],
|
||||
"id" : entry["id"],
|
||||
}
|
||||
)
|
||||
|
||||
return sorted_data
|
||||
else:
|
||||
consoleLog("Scraping failed server-side, unable to fetch posts from rutracker")
|
||||
return []
|
||||
else:
|
||||
consoleLog("No response from server, returning nothing")
|
||||
return []
|
||||
|
||||
def get_download_link(self, post: Dict):
|
||||
_, post_links, _, _, _ = format_data([post])
|
||||
return get_magnet_link(post_links[0])
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
from data.hosts.buzzheavier import scrape_buzzheavier
|
||||
from data.hosts.vikingfile import scrape_vikingfile
|
||||
from data.hosts.gofile import scrape_gofile
|
||||
from data.hosts.megadb import scrape_megadb
|
||||
from utils.logging.logs import consoleLog
|
||||
from bs4 import BeautifulSoup
|
||||
from typing import Dict
|
||||
import webbrowser
|
||||
import requests
|
||||
import time
|
||||
import copy
|
||||
|
||||
class SteamripScraper:
|
||||
name = "steamrip"
|
||||
headers = ["Game"]
|
||||
is_magnet = False
|
||||
|
||||
def __init__(self):
|
||||
self.cache = { "data": [], "last_fetched": 0 }
|
||||
self.cache_expiry = 300
|
||||
|
||||
def scrape_steamrip_links(self):
|
||||
current_time = time.time()
|
||||
|
||||
if self.cache["data"] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
||||
return copy.deepcopy(self.cache["data"])
|
||||
|
||||
try:
|
||||
url = f"https://steamrip.com/games-list-page/"
|
||||
response = requests.get(url, timeout=15)
|
||||
response.raise_for_status()
|
||||
text = response.text
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"SteamRip: Failed to fetch games list - {e}")
|
||||
return []
|
||||
|
||||
soup = BeautifulSoup(text, "html.parser")
|
||||
games = soup.find_all("li", class_="az-list-item")
|
||||
|
||||
if len(games) == 0:
|
||||
return []
|
||||
|
||||
links = []
|
||||
names = []
|
||||
|
||||
for gamehtml in games:
|
||||
link = gamehtml.find("a", href=lambda x: x and x.startswith("/"))
|
||||
if link:
|
||||
links.append("https://steamrip.com" + link["href"])
|
||||
names.append(link.get_text())
|
||||
|
||||
ret = []
|
||||
|
||||
for i in range(len(names)):
|
||||
ret.append({"title" : names[i], "url" : links[i]})
|
||||
|
||||
self.cache["data"] = ret
|
||||
self.cache["last_fetched"] = current_time
|
||||
|
||||
return ret
|
||||
|
||||
def scrape_steamrip_game_downloads(self, url):
|
||||
try:
|
||||
response = requests.get(url, timeout=15)
|
||||
response.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"SteamRip: Failed to fetch game page - {e}")
|
||||
return []
|
||||
|
||||
soup = BeautifulSoup(response.text, "html.parser")
|
||||
download_link_elements = soup.find_all("a",class_="shortc-button")
|
||||
download_links = ["", "", "", ""]
|
||||
|
||||
for download_link in download_link_elements:
|
||||
pure = download_link.attrs.get("href")
|
||||
if not pure or len(pure) < 3:
|
||||
continue
|
||||
if pure[2] == "b":
|
||||
download_links[0] = "https:" + pure
|
||||
if pure[2] == "g":
|
||||
download_links[1] = "https:" + pure
|
||||
if pure[2] == "v":
|
||||
download_links[2] = "https:" + pure
|
||||
if pure[2] == "m":
|
||||
download_links[3] = "https:" + pure
|
||||
|
||||
ret = []
|
||||
|
||||
for link in download_links:
|
||||
if link != "":
|
||||
ret.append(link)
|
||||
|
||||
return ret
|
||||
|
||||
def get_download_link(self, post: Dict):
|
||||
url = post["url"]
|
||||
links = self.scrape_steamrip_game_downloads(url)
|
||||
|
||||
if not links:
|
||||
consoleLog("SteamRip: No download links found")
|
||||
return None, None
|
||||
|
||||
best = ""
|
||||
for link in links:
|
||||
if link[0] == "h":
|
||||
best = link
|
||||
break
|
||||
|
||||
if not best:
|
||||
consoleLog("SteamRip: No valid download links found")
|
||||
return None, None
|
||||
|
||||
|
||||
try:
|
||||
consoleLog(f"Found download link: {best}")
|
||||
if "buzzheavier" or "bzzhr" in best:
|
||||
link = scrape_buzzheavier(best)
|
||||
return link
|
||||
elif "gofile" in best:
|
||||
link, headers = scrape_gofile(best)
|
||||
return link, headers
|
||||
elif "vikingfile" in best:
|
||||
scrape_vikingfile(best)
|
||||
return None, None
|
||||
elif "megadb" in best:
|
||||
scrape_megadb(best)
|
||||
return None, None
|
||||
else:
|
||||
consoleLog("SteamRip: Unknown host, launching browser...")
|
||||
webbrowser.open(best)
|
||||
return None, None
|
||||
except Exception as e:
|
||||
consoleLog(f"SteamRip: Scraper failed - {e}")
|
||||
return None, None
|
||||
|
||||
def search(self, query: str):
|
||||
games = self.scrape_steamrip_links()
|
||||
|
||||
filtered_games = [
|
||||
game for game in games
|
||||
if query.lower() in game["title"].lower()
|
||||
]
|
||||
|
||||
return filtered_games
|
||||
@@ -0,0 +1,50 @@
|
||||
from utils.data.tracker import get_magnet_link
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
from urllib.parse import urljoin
|
||||
from bs4 import BeautifulSoup
|
||||
from typing import Dict
|
||||
import requests
|
||||
|
||||
class UztrackerScraper:
|
||||
name = "uztracker"
|
||||
headers = ["Post Title", "Author"]
|
||||
is_magnet = True
|
||||
|
||||
|
||||
def search(self, query):
|
||||
base_url="https://uztracker.net/"
|
||||
search_url = f"{base_url.rstrip('/')}/tracker.php?nm={query}"
|
||||
consoleLog(search_url)
|
||||
posts = []
|
||||
|
||||
try:
|
||||
response = requests.get(search_url, timeout=15)
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
links = soup.find_all('tr', class_="tCenter hl-tr", id=lambda x: x and x.startswith('tor_'))
|
||||
for link in links:
|
||||
|
||||
theme_link = link.find('a', class_="genmed tLink", href=lambda x: x and x.startswith('./viewtopic'))
|
||||
if not theme_link or not theme_link.b:
|
||||
continue
|
||||
url = urljoin(base_url, theme_link['href'])
|
||||
title = theme_link.b.text
|
||||
author_link = link.find('a', class_="med")
|
||||
author = author_link.text.strip() if author_link else "Unknown"
|
||||
|
||||
posts.append(dict(
|
||||
title=title,
|
||||
author=author,
|
||||
url=url,
|
||||
))
|
||||
|
||||
return posts
|
||||
|
||||
except requests.RequestException as e:
|
||||
consoleLog(f"Failed to fetch {search_url}: {e}")
|
||||
return []
|
||||
|
||||
def get_download_link(self, post: Dict):
|
||||
return get_magnet_link(post["url"])
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import base64
|
||||
import sys
|
||||
|
||||
if sys.argv[1] is None:
|
||||
print("Usage: python encode_icon.py <path_to_image>")
|
||||
sys.exit(1)
|
||||
else:
|
||||
with open(sys.argv[1], "rb") as image_file:
|
||||
encoded_string = base64.b64encode(image_file.read())
|
||||
print(encoded_string.decode("utf-8"))
|
||||
|
||||
|
After Width: | Height: | Size: 56 KiB |
@@ -0,0 +1,273 @@
|
||||
from PySide6.QtCore import Qt, QPoint, Signal, QThread
|
||||
from network.direct_download.handle import DirectDownloadHandle
|
||||
from utils.logging.logs import consoleLog, remove_download_log
|
||||
from utils.network.download import download_selected
|
||||
from utils.data.tracker import get_magnet_link
|
||||
from utils.general.wrappers import run_thread
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from utils.data.state import state
|
||||
from send2trash import send2trash
|
||||
from PySide6 import QtWidgets
|
||||
import threading
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import platform
|
||||
import os
|
||||
|
||||
|
||||
class MagnetWorker(QThread):
|
||||
finished = Signal(str)
|
||||
|
||||
def __init__(self, url, parent=None):
|
||||
super().__init__(parent)
|
||||
self.url = url
|
||||
|
||||
def run(self):
|
||||
magnet = get_magnet_link(self.url)
|
||||
if magnet:
|
||||
self.finished.emit(magnet)
|
||||
|
||||
class ContextMenu_Downloads:
|
||||
def __init__(self, main_window):
|
||||
self.main_window = main_window
|
||||
self.context_menu = QtWidgets.QMenu(main_window)
|
||||
self.context_menu.addAction("Open Containing Folder", self.openFolderAction)
|
||||
self.context_menu.addAction("Copy Download Link", self.copyMagnetURIAction)
|
||||
self.context_menu.addAction("Remove from list", self.cancelDownloadAction)
|
||||
self.context_menu.addAction("Delete File", self.deleteFileAction)
|
||||
|
||||
main_window.downloadList.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
main_window.downloadList.customContextMenuRequested.connect(self._show_context_menu)
|
||||
|
||||
@property
|
||||
def downloadList(self):
|
||||
return self.main_window.downloadList
|
||||
|
||||
def _show_context_menu(self, pos: QPoint):
|
||||
index = self.downloadList.indexAt(pos)
|
||||
if index.isValid():
|
||||
self._context_menu_row = index.row()
|
||||
self.context_menu.exec(self.downloadList.viewport().mapToGlobal(pos))
|
||||
|
||||
def openFolderAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
with state.downloads_lock:
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
keys = list(state.active_downloads.keys())
|
||||
magnet_link = keys[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
download_path = magnetdl.save_path()
|
||||
if download_path and os.path.exists(download_path):
|
||||
if platform.system() == "Windows":
|
||||
os.startfile(os.path.normpath(download_path))
|
||||
elif platform.system() == "Linux":
|
||||
subprocess.Popen(["xdg-open", download_path])
|
||||
elif platform.system() == "Darwin":
|
||||
subprocess.Popen(["open", download_path])
|
||||
|
||||
def copyMagnetURIAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
with state.downloads_lock:
|
||||
if row < 0 or row >= len(state.active_downloads):
|
||||
return
|
||||
keys = list(state.active_downloads.keys())
|
||||
magnet_link = keys[row]
|
||||
clipboard = QtWidgets.QApplication.clipboard()
|
||||
clipboard.setText(magnet_link)
|
||||
|
||||
def cancelDownloadAction(self):
|
||||
selected_rows = sorted(set(index.row() for index in self.downloadList.selectedIndexes()), reverse=True)
|
||||
|
||||
if not selected_rows:
|
||||
return
|
||||
|
||||
names = []
|
||||
items_to_remove = []
|
||||
|
||||
with state.downloads_lock:
|
||||
keys = list(state.active_downloads.keys())
|
||||
|
||||
for row in selected_rows:
|
||||
if 0 <= row < len(keys):
|
||||
magnet_link = keys[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
|
||||
try:
|
||||
name = magnetdl.status().name
|
||||
except RuntimeError:
|
||||
name = "Unknown"
|
||||
|
||||
names.append(name)
|
||||
items_to_remove.append((magnet_link, magnetdl, name))
|
||||
|
||||
confirm = QMessageBox.question(
|
||||
self.main_window,
|
||||
"Cancel Downloads",
|
||||
f"Are you sure you want to cancel {len(names)} download(s)?\n\n" + "\n".join(names),
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
|
||||
)
|
||||
|
||||
if confirm != QMessageBox.StandardButton.Yes:
|
||||
return
|
||||
|
||||
for magnet_link, magnetdl, name in items_to_remove:
|
||||
with state.downloads_lock:
|
||||
state.active_downloads.pop(magnet_link, None)
|
||||
|
||||
remove_download_log(magnet_link)
|
||||
|
||||
if isinstance(magnetdl, DirectDownloadHandle):
|
||||
try:
|
||||
magnetdl.stop()
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while stopping direct download: {e}")
|
||||
elif state.dl_session:
|
||||
try:
|
||||
state.dl_session.remove_torrent(magnetdl)
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while removing download from LibTorrent: {e}")
|
||||
|
||||
consoleLog(f"Cancelled download: {name}", True)
|
||||
|
||||
|
||||
def deleteFileAction(self):
|
||||
selected_rows = sorted(set(index.row() for index in self.downloadList.selectedIndexes()), reverse=True)
|
||||
|
||||
if not selected_rows:
|
||||
return
|
||||
|
||||
items_to_remove = []
|
||||
|
||||
with state.downloads_lock:
|
||||
keys = list(state.active_downloads.keys())
|
||||
|
||||
for row in selected_rows:
|
||||
if 0 <= row < len(keys):
|
||||
magnet_link = keys[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
|
||||
try:
|
||||
status = magnetdl.status()
|
||||
save_path = status.save_path
|
||||
torrent_name = status.name
|
||||
except RuntimeError:
|
||||
consoleLog("Error: torrent handle already invalid", True)
|
||||
continue
|
||||
|
||||
download_path = os.path.join(save_path, torrent_name)
|
||||
|
||||
items_to_remove.append((magnet_link, magnetdl, torrent_name, download_path))
|
||||
|
||||
if not items_to_remove:
|
||||
return
|
||||
|
||||
names = [item[2] for item in items_to_remove]
|
||||
|
||||
confirm = QMessageBox.question(
|
||||
self.main_window,
|
||||
"Delete Files",
|
||||
f"Are you sure you want to delete {len(names)} download(s)?\n\n" + "\n".join(names),
|
||||
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No
|
||||
)
|
||||
|
||||
if confirm != QMessageBox.StandardButton.Yes:
|
||||
return
|
||||
|
||||
for magnet_link, magnetdl, torrent_name, download_path in items_to_remove:
|
||||
with state.downloads_lock:
|
||||
state.active_downloads.pop(magnet_link, None)
|
||||
|
||||
remove_download_log(magnet_link)
|
||||
|
||||
if isinstance(magnetdl, DirectDownloadHandle):
|
||||
try:
|
||||
magnetdl.stop()
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while stopping direct download: {e}")
|
||||
elif state.dl_session:
|
||||
try:
|
||||
state.dl_session.remove_torrent(magnetdl)
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while removing download from LibTorrent: {e}")
|
||||
|
||||
if download_path and os.path.exists(download_path):
|
||||
try:
|
||||
if os.path.isfile(download_path) or os.path.isdir(download_path):
|
||||
send2trash(download_path)
|
||||
consoleLog(f"Deleted files for: {torrent_name}", True)
|
||||
except Exception as e:
|
||||
consoleLog(f"Error deleting files: {e}", True)
|
||||
else:
|
||||
consoleLog(f"Removed entry (files not found): {torrent_name}", True)
|
||||
|
||||
class ContextMenu_TrackerTable:
|
||||
def __init__(self, main_window):
|
||||
self.main_window = main_window
|
||||
self.context_menu = QtWidgets.QMenu(main_window)
|
||||
self.context_menu.addAction("Copy Download Link", self.copyMagnetURIAction)
|
||||
self.context_menu.addAction("Open in Browser", self.openInBrowserAction)
|
||||
self.context_menu.addAction("Download", self.downloadItemAction)
|
||||
|
||||
state.trackertable.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
|
||||
state.trackertable.customContextMenuRequested.connect(self._show_context_menu)
|
||||
|
||||
@property
|
||||
def TrackerTable(self):
|
||||
return state.trackertable
|
||||
|
||||
def _show_context_menu(self, pos: QPoint):
|
||||
index = self.TrackerTable.indexAt(pos)
|
||||
if index.isValid():
|
||||
self._context_menu_row = index.row()
|
||||
self.context_menu.exec(self.TrackerTable.viewport().mapToGlobal(pos))
|
||||
|
||||
def copyMagnetURIAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
post = state.posts[row]
|
||||
url = post.get("url")
|
||||
if not url:
|
||||
return
|
||||
|
||||
worker = MagnetWorker(url, parent=self.main_window)
|
||||
worker.finished.connect(self._on_magnet_fetched)
|
||||
worker.finished.connect(worker.deleteLater)
|
||||
worker.start()
|
||||
|
||||
def _on_magnet_fetched(self, magnet):
|
||||
clipboard = QtWidgets.QApplication.clipboard()
|
||||
clipboard.setText(magnet)
|
||||
consoleLog("Magnet URI copied to clipboard!", True)
|
||||
|
||||
def openInBrowserAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
post = state.posts[row]
|
||||
url = post.get("url")
|
||||
if url:
|
||||
try: webbrowser.open(url)
|
||||
except Exception as e: consoleLog(f"Failed to open URL: {e}", True)
|
||||
|
||||
def downloadItemAction(self):
|
||||
if not hasattr(self, '_context_menu_row'):
|
||||
return
|
||||
row = self._context_menu_row
|
||||
if not state.posts or row < 0 or row >= len(state.posts):
|
||||
return
|
||||
|
||||
run_thread(threading.Thread(target=download_selected, args=(state.trackertable.selectedItems(),)))
|
||||
@@ -0,0 +1,89 @@
|
||||
from interface.dialogs.pauseresumedelegate import PauseResumeDelegate
|
||||
from interface.dialogs.hoverrowdelegate import HoverRowDelegate
|
||||
from interface.dialogs.downloadmodel import DownloadModel
|
||||
from interface.dialogs.theme import _table_stylesheet
|
||||
from PySide6.QtWidgets import QTableView, QHeaderView
|
||||
from utils.logging.logs import consoleLog
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
def _create_download_list(self) -> QTableView:
|
||||
self.download_model = DownloadModel()
|
||||
self.downloadList.setModel(self.download_model)
|
||||
self.downloadList.horizontalHeader().setStretchLastSection(False)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(0, QHeaderView.ResizeMode.Fixed)
|
||||
self.downloadList.horizontalHeader().resizeSection(0, 70)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(1, QHeaderView.ResizeMode.Stretch)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(2, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(3, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(4, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(5, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setSectionResizeMode(6, QHeaderView.ResizeMode.ResizeToContents)
|
||||
self.downloadList.horizontalHeader().setMinimumSectionSize(60)
|
||||
self.downloadList.verticalHeader().setDefaultSectionSize(40)
|
||||
self.downloadList.setSelectionBehavior(QTableView.SelectionBehavior.SelectRows)
|
||||
self.downloadList.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
self.downloadList.verticalHeader().setVisible(False)
|
||||
self.downloadList.horizontalHeader().setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
self.downloadList.horizontalHeader().setHighlightSections(False)
|
||||
self.downloadList.setMouseTracking(True)
|
||||
self.downloadList.setShowGrid(False)
|
||||
self.downloadList.setStyleSheet(_table_stylesheet("QTableView"))
|
||||
self.downloadList.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
self.downloadList.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
download_model = self.download_model
|
||||
|
||||
def on_pause_resume_clicked(row):
|
||||
download_model.toggle_pause_resume(row)
|
||||
|
||||
self.downloadList.viewport().setMouseTracking(True)
|
||||
hover_delegate = HoverRowDelegate(self.downloadList)
|
||||
self.downloadList.setItemDelegate(hover_delegate)
|
||||
|
||||
delegate = PauseResumeDelegate(self.downloadList)
|
||||
self.downloadList.setItemDelegateForColumn(0, delegate)
|
||||
delegate.clicked.connect(on_pause_resume_clicked)
|
||||
|
||||
return self.downloadList
|
||||
|
||||
def download_list_update(self):
|
||||
self._update_speed_label()
|
||||
if not self.download_model:
|
||||
return
|
||||
|
||||
row_count = self.download_model.rowCount()
|
||||
col_count = self.download_model.columnCount()
|
||||
|
||||
if row_count > 0 and col_count > 0:
|
||||
top_left = self.download_model.index(0, 0)
|
||||
bottom_right = self.download_model.index(row_count - 1, col_count - 1)
|
||||
if top_left.isValid() and bottom_right.isValid():
|
||||
self.download_model.dataChanged.emit(top_left, bottom_right, [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.UserRole])
|
||||
|
||||
if row_count != self._last_dl_row_count:
|
||||
old_count = self._last_dl_row_count
|
||||
self._last_dl_row_count = row_count
|
||||
if row_count > 0:
|
||||
self.download_model.layoutAboutToBeChanged.emit()
|
||||
self.download_model.layoutChanged.emit()
|
||||
for row in range(row_count):
|
||||
idx = self.download_model.index(row, 0)
|
||||
if idx.isValid():
|
||||
self.downloadList.closePersistentEditor(idx)
|
||||
self.downloadList.openPersistentEditor(idx)
|
||||
elif old_count > 0:
|
||||
self.download_model.layoutAboutToBeChanged.emit()
|
||||
self.download_model.layoutChanged.emit()
|
||||
else:
|
||||
if row_count > 0:
|
||||
delegate = self.downloadList.itemDelegateForColumn(0)
|
||||
for row in range(row_count):
|
||||
idx = self.download_model.index(row, 0)
|
||||
if idx.isValid():
|
||||
editor = self.downloadList.indexWidget(idx)
|
||||
if editor and delegate:
|
||||
try:
|
||||
delegate.setEditorData(editor, idx)
|
||||
except RuntimeError as e:
|
||||
consoleLog(f"Exception while updating download list: {e}")
|
||||
@@ -0,0 +1,138 @@
|
||||
from PySide6.QtCore import QAbstractTableModel, QModelIndex, Qt
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import libtorrent as lt
|
||||
import subprocess
|
||||
import platform
|
||||
import os
|
||||
|
||||
class DownloadModel(QAbstractTableModel):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.headers = ["Action", "Name", "Status", "Progress", "Speed", "Size", "Total Size"]
|
||||
|
||||
def rowCount(self, parent=QModelIndex()):
|
||||
if parent.isValid():
|
||||
return 0
|
||||
with state.downloads_lock:
|
||||
return len(state.active_downloads)
|
||||
|
||||
def columnCount(self, parent=QModelIndex()):
|
||||
return len(self.headers)
|
||||
|
||||
def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole):
|
||||
if role == Qt.ItemDataRole.DisplayRole and orientation == Qt.Orientation.Horizontal:
|
||||
return self.headers[section]
|
||||
return None
|
||||
|
||||
def data(self, index, role=Qt.ItemDataRole.DisplayRole):
|
||||
if not index.isValid():
|
||||
return None
|
||||
|
||||
with state.downloads_lock:
|
||||
if index.row() >= len(state.active_downloads) or index.row() < 0:
|
||||
return None
|
||||
|
||||
try:
|
||||
keys = list(state.active_downloads.keys())
|
||||
magnet_link = keys[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
except (IndexError, KeyError, RuntimeError):
|
||||
return None
|
||||
|
||||
if role == Qt.ItemDataRole.DisplayRole:
|
||||
col = index.column()
|
||||
if col == 0:
|
||||
pass
|
||||
elif col == 1:
|
||||
return status.name if status.has_metadata else "Fetching metadata..."
|
||||
elif col == 2:
|
||||
if status.paused:
|
||||
is_auto = getattr(status, 'auto_managed', True)
|
||||
return "Queued" if is_auto else "Paused"
|
||||
elif status.state == lt.torrent_status.downloading:
|
||||
return "Downloading"
|
||||
elif status.state == lt.torrent_status.seeding:
|
||||
return "Seeding"
|
||||
else:
|
||||
return "Queued"
|
||||
elif col == 3:
|
||||
return f"{status.progress * 100:.1f}%"
|
||||
elif col == 4:
|
||||
down_kb = status.download_rate / 1024
|
||||
up_kb = status.upload_rate / 1024
|
||||
down_text = f"{down_kb / 1024:.1f} MB/s" if down_kb > 1024 else f"{down_kb:.1f} kB/s"
|
||||
up_text = f"{up_kb / 1024:.1f} MB/s" if up_kb > 1024 else f"{up_kb:.1f} kB/s"
|
||||
return f"↓ {down_text} ↑ {up_text}"
|
||||
elif col == 5:
|
||||
downloaded_mb = status.total_wanted_done / (1024 * 1024)
|
||||
if downloaded_mb > 1024:
|
||||
return f"{downloaded_mb / 1024:.2f} GB"
|
||||
else:
|
||||
return f"{downloaded_mb:.1f} MB"
|
||||
elif col == 6:
|
||||
total_mb = status.total_wanted / (1024 * 1024)
|
||||
if total_mb > 1024:
|
||||
return f"{total_mb / 1024:.2f} GB"
|
||||
else:
|
||||
return f"{total_mb:.1f} MB"
|
||||
elif col == 7:
|
||||
if status.download_rate > 0:
|
||||
bytes_left = status.total_wanted - status.total_wanted_done
|
||||
eta_seconds = bytes_left / status.download_rate
|
||||
if eta_seconds < 60:
|
||||
return f"{int(eta_seconds)}s"
|
||||
elif eta_seconds < 3600:
|
||||
minutes = int(eta_seconds / 60)
|
||||
seconds = int(eta_seconds % 60)
|
||||
return f"{minutes}m {seconds}s"
|
||||
else:
|
||||
hours = int(eta_seconds / 3600)
|
||||
minutes = int((eta_seconds % 3600) / 60)
|
||||
return f"{hours}h {minutes}m"
|
||||
else:
|
||||
return "∞" if status.paused else "Stalled"
|
||||
if role == Qt.ItemDataRole.UserRole and index.column() == 0:
|
||||
return status.paused
|
||||
return None
|
||||
|
||||
def toggle_pause_resume(self, row):
|
||||
with state.downloads_lock:
|
||||
if row >= len(state.active_downloads) or row < 0:
|
||||
return
|
||||
try:
|
||||
keys = list(state.active_downloads.keys())
|
||||
magnet_link = keys[row]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
except (IndexError, KeyError, RuntimeError):
|
||||
return
|
||||
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
try:
|
||||
save_path = magnetdl.save_path()
|
||||
if save_path and os.path.exists(save_path):
|
||||
if platform.system() == "Windows":
|
||||
os.startfile(os.path.normpath(save_path))
|
||||
elif platform.system() == "Linux":
|
||||
subprocess.Popen(["xdg-open", save_path])
|
||||
elif platform.system() == "Darwin":
|
||||
subprocess.Popen(["open", save_path])
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while opening file: {e}")
|
||||
return
|
||||
|
||||
is_paused = status.paused
|
||||
if is_paused:
|
||||
if hasattr(magnetdl, 'set_flags'):
|
||||
magnetdl.set_flags(lt.torrent_flags.auto_managed)
|
||||
magnetdl.resume()
|
||||
consoleLog(f"Resumed download: {status.name}", True)
|
||||
else:
|
||||
if hasattr(magnetdl, 'unset_flags'):
|
||||
magnetdl.unset_flags(lt.torrent_flags.auto_managed)
|
||||
magnetdl.pause()
|
||||
consoleLog(f"Paused download: {status.name}", True)
|
||||
idx = self.index(row, 0)
|
||||
self.dataChanged.emit(idx, idx, [Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.UserRole])
|
||||
@@ -0,0 +1,22 @@
|
||||
from interface.dialogs.theme import _theme_colors
|
||||
from PySide6.QtWidgets import QStyledItemDelegate
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
class ElidedItemDelegate(QStyledItemDelegate):
|
||||
def __init__(self, get_hovered_row, parent=None):
|
||||
super().__init__(parent)
|
||||
self._get_hovered_row = get_hovered_row
|
||||
|
||||
def initStyleOption(self, option, index):
|
||||
super().initStyleOption(option, index)
|
||||
if option.text:
|
||||
metrics = option.fontMetrics
|
||||
text_rect = option.rect.adjusted(14, 0, -14, 0)
|
||||
option.text = metrics.elidedText(option.text, Qt.TextElideMode.ElideMiddle, text_rect.width())
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
if index.row() == self._get_hovered_row():
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, option, index)
|
||||
@@ -0,0 +1,36 @@
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
from PySide6.QtCore import QEvent
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
try:
|
||||
if obj == state.trackertable.viewport():
|
||||
if event.type() == QEvent.Type.MouseMove:
|
||||
pos = event.position().toPoint() if hasattr(event, 'position') else event.pos()
|
||||
idx = state.trackertable.indexAt(pos)
|
||||
new_row = idx.row() if idx.isValid() else -1
|
||||
if new_row != self._tracker_hovered_row or state.trackertable is not self._tracker_hovered_table:
|
||||
self._tracker_hovered_row = new_row
|
||||
self._tracker_hovered_table = state.trackertable
|
||||
state.trackertable.viewport().update()
|
||||
elif event.type() == QEvent.Type.Leave:
|
||||
self._tracker_hovered_row = -1
|
||||
self._tracker_hovered_table = None
|
||||
state.trackertable.viewport().update()
|
||||
if obj == self.downloadList.viewport():
|
||||
if event.type() == QEvent.Type.MouseMove:
|
||||
pos = event.position().toPoint() if hasattr(event, 'position') else event.pos()
|
||||
idx = self.downloadList.indexAt(pos)
|
||||
new_row = idx.row() if idx.isValid() else -1
|
||||
if new_row != self._hovered_row:
|
||||
old_row = self._hovered_row
|
||||
self._hovered_row = new_row
|
||||
self._invalidate_hover_row(old_row)
|
||||
self._invalidate_hover_row(new_row)
|
||||
elif event.type() == QEvent.Type.Leave:
|
||||
old_row = self._hovered_row
|
||||
self._hovered_row = -1
|
||||
self._invalidate_hover_row(old_row)
|
||||
except (RuntimeError, AttributeError) as e:
|
||||
consoleLog(f"Exception in EventFilter: {e}")
|
||||
return super(type(self), self).eventFilter(obj, event)
|
||||
@@ -0,0 +1,19 @@
|
||||
from interface.dialogs.theme import _theme_colors
|
||||
from PySide6.QtWidgets import QStyledItemDelegate
|
||||
from PySide6 import QtWidgets
|
||||
|
||||
class HoverRowDelegate(QStyledItemDelegate):
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
from interface.gui import MainWindow
|
||||
|
||||
opt = QtWidgets.QStyleOptionViewItem(option)
|
||||
option.state &= ~QtWidgets.QStyle.StateFlag.State_HasFocus
|
||||
option.state &= ~QtWidgets.QStyle.StateFlag.State_Selected
|
||||
|
||||
hovered_row = MainWindow._instance._hovered_row if MainWindow._instance else -1
|
||||
if index.row() == hovered_row:
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, opt, index)
|
||||
@@ -0,0 +1,251 @@
|
||||
from PySide6.QtWidgets import QLabel, QGraphicsOpacityEffect, QStackedWidget
|
||||
from PySide6.QtCore import Qt, QSize, QEvent, QObject, QTimer
|
||||
from PySide6.QtGui import QImage, QPixmap
|
||||
from utils.data.state import state
|
||||
import darkdetect
|
||||
import os
|
||||
|
||||
|
||||
class Image(QObject):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
self.application = parent
|
||||
self.overlay_label = QLabel(parent)
|
||||
self.overlay_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
||||
|
||||
self.opacity_effect = QGraphicsOpacityEffect()
|
||||
self.overlay_label.setGraphicsEffect(self.opacity_effect)
|
||||
|
||||
self._current_image_path = None
|
||||
self._cached_qimage = None
|
||||
self._wallpaper_active = False
|
||||
self._original_stylesheets = {}
|
||||
|
||||
self._resize_timer = QTimer(self)
|
||||
self._resize_timer.setSingleShot(True)
|
||||
self._resize_timer.setInterval(100)
|
||||
self._resize_timer.timeout.connect(self._on_resize_finished)
|
||||
|
||||
parent.installEventFilter(self)
|
||||
state.image_changed.connect(self.update_image_overlay)
|
||||
|
||||
if state.image_path and os.path.exists(state.image_path):
|
||||
self._load_and_display(state.image_path)
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
if obj == self.application and event.type() == QEvent.Type.Resize:
|
||||
if self._current_image_path:
|
||||
self._apply_layout_fast()
|
||||
self._resize_timer.start()
|
||||
return False
|
||||
|
||||
def _on_resize_finished(self):
|
||||
if self._current_image_path:
|
||||
self._apply_layout()
|
||||
|
||||
def _set_wallpaper_transparency(self, enabled):
|
||||
if self._wallpaper_active == enabled:
|
||||
return
|
||||
self._wallpaper_active = enabled
|
||||
parent = self.application
|
||||
|
||||
central = parent.centralWidget()
|
||||
if central:
|
||||
central.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
for attr in ['tab_wrapper', 'corner_widget', 'titlebar']:
|
||||
w = getattr(parent, attr, None)
|
||||
if w:
|
||||
w.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
if hasattr(parent, 'tabs'):
|
||||
tabs = parent.tabs
|
||||
tabs.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
for i in range(tabs.count()):
|
||||
page = tabs.widget(i)
|
||||
if page:
|
||||
page.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
stack = tabs.findChild(QStackedWidget)
|
||||
if stack:
|
||||
stack.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
tab_bar = tabs.tabBar()
|
||||
if tab_bar:
|
||||
tab_bar.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
if 'tabs' not in self._original_stylesheets:
|
||||
self._original_stylesheets['tabs'] = tabs.styleSheet()
|
||||
if enabled:
|
||||
tabs.setStyleSheet(
|
||||
self._original_stylesheets['tabs']
|
||||
+ "\nQTabWidget::pane { background: transparent; }"
|
||||
+ "\nQTabBar { background: transparent; }"
|
||||
+ "\nQTabBar::tab { background: transparent; }"
|
||||
)
|
||||
else:
|
||||
tabs.setStyleSheet(self._original_stylesheets['tabs'])
|
||||
|
||||
# Searchbar
|
||||
if hasattr(parent, 'searchbar'):
|
||||
if 'searchbar' not in self._original_stylesheets:
|
||||
self._original_stylesheets['searchbar'] = parent.searchbar.styleSheet()
|
||||
if enabled:
|
||||
parent.searchbar.setStyleSheet("QLineEdit { background-color: transparent; }")
|
||||
else:
|
||||
parent.searchbar.setStyleSheet(self._original_stylesheets['searchbar'])
|
||||
|
||||
# Download button
|
||||
if hasattr(parent, 'dlbutton'):
|
||||
if 'dlbutton' not in self._original_stylesheets:
|
||||
self._original_stylesheets['dlbutton'] = parent.dlbutton.styleSheet()
|
||||
if enabled:
|
||||
parent.dlbutton.setStyleSheet("QPushButton { background-color: transparent; }")
|
||||
else:
|
||||
parent.dlbutton.setStyleSheet(self._original_stylesheets['dlbutton'])
|
||||
|
||||
# Labels
|
||||
for attr in ['emptyResults', 'emptyDownload']:
|
||||
w = getattr(parent, attr, None)
|
||||
if w:
|
||||
w.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, enabled)
|
||||
|
||||
if hasattr(parent, 'tracker_list'):
|
||||
if 'tracker_list' not in self._original_stylesheets:
|
||||
self._original_stylesheets['tracker_list'] = parent.tracker_list.styleSheet()
|
||||
if enabled:
|
||||
popup_bg = '#1e1e1e' if darkdetect.isDark() else '#ffffff'
|
||||
parent.tracker_list.setStyleSheet(
|
||||
"QComboBox { background-color: transparent; }"
|
||||
f" QComboBox QAbstractItemView {{ background-color: {popup_bg}; }}"
|
||||
)
|
||||
else:
|
||||
parent.tracker_list.setStyleSheet(self._original_stylesheets['tracker_list'])
|
||||
|
||||
def _load_and_display(self, image_path):
|
||||
if state.image_enabled is not True:
|
||||
self.overlay_label.hide()
|
||||
self._set_wallpaper_transparency(False)
|
||||
return
|
||||
self._current_image_path = image_path
|
||||
|
||||
# Only reload from disk when the path actually changed
|
||||
if self._cached_qimage is None or image_path != getattr(self, '_cached_path', None):
|
||||
image = QImage(image_path)
|
||||
if image.isNull():
|
||||
self.overlay_label.hide()
|
||||
self._cached_qimage = None
|
||||
return
|
||||
self._cached_qimage = image
|
||||
self._cached_path = image_path
|
||||
|
||||
self._apply_layout()
|
||||
|
||||
def _apply_layout_fast(self):
|
||||
if self._cached_qimage is None or not state.image_enabled:
|
||||
return
|
||||
|
||||
parent = self.application
|
||||
image = self._cached_qimage
|
||||
|
||||
if getattr(state, "image_as_wallpaper", False):
|
||||
scaled = image.scaled(
|
||||
parent.size(),
|
||||
Qt.AspectRatioMode.KeepAspectRatioByExpanding,
|
||||
Qt.TransformationMode.FastTransformation
|
||||
)
|
||||
cx = (scaled.width() - parent.width()) // 2
|
||||
cy = (scaled.height() - parent.height()) // 2
|
||||
cropped = scaled.copy(cx, cy, parent.width(), parent.height())
|
||||
self.overlay_label.setPixmap(QPixmap.fromImage(cropped))
|
||||
self.overlay_label.setGeometry(0, 0, parent.width(), parent.height())
|
||||
else:
|
||||
w = self.overlay_label.width()
|
||||
h = self.overlay_label.height()
|
||||
pos = state.image_position
|
||||
off = int(state.image_offset)
|
||||
if pos == "top-left":
|
||||
x, y = off, off
|
||||
elif pos == "top-right":
|
||||
x, y = parent.width() - w - off, off
|
||||
elif pos == "bottom-left":
|
||||
x, y = off, parent.height() - h - off
|
||||
elif pos == "center":
|
||||
x, y = (parent.width() - w) // 2, (parent.height() - h) // 2
|
||||
else:
|
||||
x, y = parent.width() - w - off, parent.height() - h - off
|
||||
self.overlay_label.move(x, y)
|
||||
|
||||
def _apply_layout(self):
|
||||
if self._cached_qimage is None or not state.image_enabled:
|
||||
self.overlay_label.hide()
|
||||
return
|
||||
|
||||
parent = self.application
|
||||
image = self._cached_qimage
|
||||
|
||||
if getattr(state, "image_as_wallpaper", False):
|
||||
scaled_image = image.scaled(
|
||||
parent.size(),
|
||||
Qt.AspectRatioMode.KeepAspectRatioByExpanding,
|
||||
Qt.TransformationMode.SmoothTransformation
|
||||
)
|
||||
|
||||
crop_x = (scaled_image.width() - parent.width()) // 2
|
||||
crop_y = (scaled_image.height() - parent.height()) // 2
|
||||
scaled_image = scaled_image.copy(crop_x, crop_y, parent.width(), parent.height())
|
||||
|
||||
pixmap = QPixmap.fromImage(scaled_image)
|
||||
self.overlay_label.setPixmap(pixmap)
|
||||
|
||||
self.overlay_label.setGeometry(0, 0, parent.width(), parent.height())
|
||||
self.overlay_label.lower()
|
||||
|
||||
self.opacity_effect.setOpacity(state.image_opacity / 100)
|
||||
self._set_wallpaper_transparency(True)
|
||||
|
||||
else:
|
||||
self._set_wallpaper_transparency(False)
|
||||
scaled_image = image.scaledToWidth(
|
||||
state.image_width, Qt.TransformationMode.SmoothTransformation
|
||||
)
|
||||
|
||||
max_width = parent.width()
|
||||
max_height = parent.height()
|
||||
if scaled_image.width() > max_width or scaled_image.height() > max_height:
|
||||
scaled_image = scaled_image.scaled(
|
||||
QSize(max_width, max_height),
|
||||
Qt.AspectRatioMode.KeepAspectRatio,
|
||||
Qt.TransformationMode.SmoothTransformation,
|
||||
)
|
||||
|
||||
pixmap = QPixmap.fromImage(scaled_image)
|
||||
self.overlay_label.setPixmap(pixmap)
|
||||
self.overlay_label.adjustSize()
|
||||
self.overlay_label.raise_()
|
||||
|
||||
pos = state.image_position
|
||||
off = int(state.image_offset)
|
||||
w = self.overlay_label.width()
|
||||
h = self.overlay_label.height()
|
||||
if pos == "top-left":
|
||||
x, y = off, off
|
||||
elif pos == "top-right":
|
||||
x, y = parent.width() - w - off, off
|
||||
elif pos == "bottom-left":
|
||||
x, y = off, parent.height() - h - off
|
||||
elif pos == "center":
|
||||
x, y = (parent.width() - w) // 2, (parent.height() - h) // 2
|
||||
else: # bottom-right (default)
|
||||
x, y = parent.width() - w - off, parent.height() - h - off
|
||||
|
||||
self.opacity_effect.setOpacity(state.image_opacity / 100)
|
||||
|
||||
self.overlay_label.move(x, y)
|
||||
self.overlay_label.show()
|
||||
|
||||
def update_image_overlay(self, new_image_path):
|
||||
if new_image_path != getattr(self, '_cached_path', None):
|
||||
self._cached_qimage = None
|
||||
self._load_and_display(new_image_path)
|
||||
@@ -0,0 +1,22 @@
|
||||
from PySide6.QtWidgets import QMessageBox
|
||||
from utils.data.state import state
|
||||
import qdarktheme
|
||||
|
||||
class NotificationPopup(QMessageBox):
|
||||
def __init__(self, title, text, infotext=None, parent=None, darkmode=True):
|
||||
super().__init__(parent)
|
||||
|
||||
if darkmode is True:
|
||||
custom_colors = {}
|
||||
if state.accent_color:
|
||||
custom_colors["primary"] = state.accent_color
|
||||
qdarktheme.setup_theme("auto", custom_colors=custom_colors if custom_colors else None)
|
||||
|
||||
self.setIcon(QMessageBox.Icon.Information)
|
||||
self.setWindowTitle(title)
|
||||
self.setText(text)
|
||||
|
||||
if infotext is not None:
|
||||
self.setInformativeText(infotext)
|
||||
|
||||
self.setStandardButtons(QMessageBox.StandardButton.Ok)
|
||||
@@ -0,0 +1,86 @@
|
||||
from interface.dialogs.theme import _theme_colors, SVG_PLAY, SVG_PAUSE, SVG_FOLDER
|
||||
from PySide6.QtWidgets import QStyledItemDelegate, QWidget, QHBoxLayout
|
||||
from interface.utils.svghelper import svg_icon
|
||||
from PySide6.QtCore import Qt, QSize, Signal
|
||||
from utils.data.state import state
|
||||
from PySide6 import QtWidgets
|
||||
import libtorrent as lt
|
||||
|
||||
class PauseResumeDelegate(QStyledItemDelegate):
|
||||
clicked = Signal(int)
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
from interface.gui import MainWindow
|
||||
|
||||
opt = QtWidgets.QStyleOptionViewItem(option)
|
||||
option.state &= ~QtWidgets.QStyle.StateFlag.State_HasFocus
|
||||
option.state &= ~QtWidgets.QStyle.StateFlag.State_Selected
|
||||
|
||||
hovered_row = MainWindow._instance._hovered_row if MainWindow._instance else -1
|
||||
if index.row() == hovered_row:
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, opt, index)
|
||||
|
||||
def setEditorData(self, editor, index):
|
||||
button = editor.findChild(QtWidgets.QPushButton)
|
||||
if not button:
|
||||
return
|
||||
try:
|
||||
with state.downloads_lock:
|
||||
keys = list(state.active_downloads.keys())
|
||||
if index.row() >= len(keys):
|
||||
return
|
||||
magnet_link = keys[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
except (RuntimeError, IndexError, KeyError):
|
||||
return
|
||||
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
button.setIcon(svg_icon(SVG_FOLDER, 18))
|
||||
button.setText("")
|
||||
else:
|
||||
is_user_paused = status.paused and not status.auto_managed
|
||||
button.setIcon(svg_icon(SVG_PLAY if is_user_paused else SVG_PAUSE, 18))
|
||||
button.setText("")
|
||||
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
try:
|
||||
with state.downloads_lock:
|
||||
keys = list(state.active_downloads.keys())
|
||||
if index.row() >= len(keys):
|
||||
return QWidget(parent)
|
||||
magnet_link = keys[index.row()]
|
||||
magnetdl = state.active_downloads[magnet_link]
|
||||
status = magnetdl.status()
|
||||
except (RuntimeError, IndexError, KeyError):
|
||||
return QWidget(parent)
|
||||
|
||||
widget = QWidget(parent)
|
||||
widget.setStyleSheet("border: none; background: transparent;")
|
||||
layout = QHBoxLayout(widget)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
btnPause = QtWidgets.QPushButton()
|
||||
btnPause.setIcon(svg_icon(SVG_FOLDER, 18))
|
||||
else:
|
||||
btnPause = QtWidgets.QPushButton()
|
||||
is_user_paused = status.paused and not status.auto_managed
|
||||
btnPause.setIcon(svg_icon(SVG_PLAY if is_user_paused else SVG_PAUSE, 18))
|
||||
btnPause.setIconSize(QSize(18, 18))
|
||||
btnPause.setFixedSize(30, 30)
|
||||
btnPause.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
btnPause.setStyleSheet("QPushButton { border: none; background: transparent; padding: 0px; }")
|
||||
btnPause.clicked.connect(lambda: self.clicked.emit(index.row()))
|
||||
layout.addStretch()
|
||||
layout.addWidget(btnPause)
|
||||
layout.addStretch()
|
||||
widget.setLayout(layout)
|
||||
return widget
|
||||
|
||||
|
||||
def editorEvent(self, event, model, option, index):
|
||||
return False
|
||||
@@ -0,0 +1,371 @@
|
||||
from interface.dialogs.theme import _accent_selection_color
|
||||
from interface.utils.tabhelper import create_tab
|
||||
from utils.config.settings import save_settings
|
||||
from interface.utils.svghelper import svg_icon
|
||||
from utils.logging.logs import consoleLog
|
||||
from PySide6.QtCore import Qt, QSize
|
||||
from utils.data.state import state
|
||||
from PySide6.QtGui import QColor
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QPushButton,
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QDialog,
|
||||
QLabel,
|
||||
QHBoxLayout,
|
||||
QSpinBox, QSlider, QCheckBox,
|
||||
QFileDialog,
|
||||
QComboBox,
|
||||
QColorDialog
|
||||
)
|
||||
|
||||
import platform
|
||||
|
||||
SVG_FOLDER = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 6c0-1.1.9-2 2-2h5l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6z" fill="{color}"/></svg>'
|
||||
|
||||
|
||||
def settings_dialog(self):
|
||||
temp_image_path = state.image_path
|
||||
temp_image_width = state.image_width
|
||||
temp_image_offset = state.image_offset
|
||||
temp_image_opacity = state.image_opacity
|
||||
temp_image_enabled = state.image_enabled
|
||||
temp_image_as_wallpaper = state.image_as_wallpaper
|
||||
temp_image_position = state.image_position
|
||||
|
||||
def create_widget(widget_type, label_text, **kwargs):
|
||||
container = QWidget()
|
||||
layout = QHBoxLayout()
|
||||
container.setLayout(layout)
|
||||
layout.addWidget(QLabel(label_text))
|
||||
|
||||
widget = widget_type()
|
||||
|
||||
if widget_type in (QSpinBox,):
|
||||
layout.addWidget(widget)
|
||||
widget.setMinimum(kwargs.get("minimum", 0))
|
||||
widget.setMaximum(kwargs.get("maximum", 10000000))
|
||||
widget.setFixedWidth(kwargs.get("width", 180))
|
||||
widget.setFixedHeight(kwargs.get("height", 30))
|
||||
elif widget_type in (QCheckBox,):
|
||||
layout.addStretch()
|
||||
layout.addWidget(widget)
|
||||
elif widget_type in (QLineEdit,):
|
||||
layout.addWidget(widget)
|
||||
container.setSizePolicy(QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Fixed)
|
||||
if "width" in kwargs:
|
||||
widget.setFixedWidth(kwargs["width"])
|
||||
if "height" in kwargs:
|
||||
widget.setFixedHeight(kwargs["height"])
|
||||
elif widget_type in (QComboBox,):
|
||||
layout.addWidget(widget)
|
||||
widget.setFixedWidth(kwargs.get("width", 180))
|
||||
widget.setFixedHeight(kwargs.get("height", 30))
|
||||
|
||||
return container, widget
|
||||
|
||||
consoleLog("Settings dialog opened")
|
||||
dialog = QDialog(self)
|
||||
dialog.setWindowTitle("Settings")
|
||||
dialog.setFixedSize(580, 400)
|
||||
|
||||
dialog_layout = QVBoxLayout()
|
||||
dialog.setLayout(dialog_layout)
|
||||
|
||||
if state.window_transparency and platform.system() != "Windows" and dialog:
|
||||
dialog.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
|
||||
# Ignore Updates checkbox
|
||||
update_checkbox_container, update_checkbox = create_widget(QCheckBox, "Ignore Updates: ")
|
||||
update_checkbox.setChecked(state.ignore_updates)
|
||||
update_checkbox.toggled.connect(lambda checked: setattr(state, 'ignore_updates', checked))
|
||||
|
||||
# Autoresume Container Checkbox
|
||||
autoresume_container, autoresume_checkbox = create_widget(QCheckBox, "Auto-Resume Downloads: ")
|
||||
autoresume_checkbox.setChecked(state.autoresume)
|
||||
autoresume_checkbox.toggled.connect(lambda checked: setattr(state, 'autoresume', checked))
|
||||
|
||||
# Transparent Window Checkbox
|
||||
transparent_window_container, transparent_window_checkbox = create_widget(QCheckBox, "Window Transparency (requires restart) (Linux/MacOS only): ")
|
||||
transparent_window_checkbox.setChecked(state.window_transparency)
|
||||
transparent_window_checkbox.toggled.connect(lambda checked: setattr(state, 'window_transparency', checked))
|
||||
|
||||
# Accent Color
|
||||
accent_color_container, accent_color_input = create_widget(QLineEdit, "Accent Color: ", width=180, height=30)
|
||||
accent_color_button = QPushButton("")
|
||||
accent_color_button.setFixedSize(21, 21)
|
||||
accent_color_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
def update_accent_button_color(color_str):
|
||||
c = color_str.strip()
|
||||
accent_color_button.setStyleSheet(
|
||||
f"QPushButton {{ background-color: {c if c else 'transparent'}; border: 1px solid palette(mid); border-radius: 3px; }}"
|
||||
)
|
||||
|
||||
def browse_accent_color():
|
||||
current = accent_color_input.text().strip()
|
||||
initial = QColor(current) if current else QColor()
|
||||
color = QColorDialog.getColor(initial, dialog, "Select Accent Color")
|
||||
if color.isValid():
|
||||
accent_color_input.setText(color.name())
|
||||
|
||||
accent_color_input.textChanged.connect(update_accent_button_color)
|
||||
accent_color_button.clicked.connect(browse_accent_color)
|
||||
accent_color_input.setPlaceholderText("e.g. #fca7d7")
|
||||
accent_color_input.setText(state.accent_color)
|
||||
update_accent_button_color(state.accent_color)
|
||||
accent_color_container.layout().insertWidget(1, accent_color_button)
|
||||
|
||||
|
||||
# API URL Widget
|
||||
api_url_container, api_url = create_widget(QLineEdit, "API Server URL: ", width=180, height=30)
|
||||
api_url.setText(state.api_url)
|
||||
|
||||
# Download Path Widget
|
||||
download_path_container, download_path = create_widget(QLineEdit, "Download Path: ")
|
||||
download_path.setText(state.download_path)
|
||||
download_path_layout = download_path_container.layout()
|
||||
|
||||
def browse_download_path():
|
||||
dir_path = QFileDialog.getExistingDirectory(dialog, "Select Download Directory", state.download_path)
|
||||
if dir_path:
|
||||
download_path.setText(dir_path)
|
||||
|
||||
browse_button = create_widget(QPushButton, "", width=36, height=36)[1]
|
||||
browse_button.setIconSize(QSize(24, 24))
|
||||
browse_button.setIcon(svg_icon(SVG_FOLDER, 24))
|
||||
browse_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
browse_button.setStyleSheet("""
|
||||
QPushButton {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0px;
|
||||
}
|
||||
""")
|
||||
|
||||
download_path_layout.addWidget(browse_button)
|
||||
browse_button.clicked.connect(browse_download_path)
|
||||
|
||||
|
||||
# Image Path
|
||||
image_path_container, image_path = create_widget(QLineEdit, "Image Path: ")
|
||||
image_path.setText(state.image_path)
|
||||
image_path_layout = image_path_container.layout()
|
||||
image_path.textChanged.connect(lambda text: setattr(state, 'image_path', text))
|
||||
|
||||
def browse_image_path():
|
||||
file_path = QFileDialog.getOpenFileName(dialog, "Select Image File", state.image_path, "Image Files (*.png *.jpg)")[0]
|
||||
if file_path:
|
||||
image_path.setText(file_path)
|
||||
|
||||
browse_button = create_widget(QPushButton, "", width=36, height=36)[1]
|
||||
browse_button.setIconSize(QSize(24, 24))
|
||||
browse_button.setIcon(svg_icon(SVG_FOLDER, 24))
|
||||
browse_button.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
browse_button.setStyleSheet("""
|
||||
QPushButton {
|
||||
border: none;
|
||||
background: transparent;
|
||||
padding: 0px;
|
||||
}
|
||||
""")
|
||||
image_path_layout.addWidget(browse_button)
|
||||
browse_button.clicked.connect(browse_image_path)
|
||||
|
||||
# Enable Image Checkbox
|
||||
enable_image_container, enable_image_checkbox = create_widget(QCheckBox, "Enable Image (requires image path): ", width=180, height=30)
|
||||
enable_image_checkbox.setChecked(state.image_enabled)
|
||||
enable_image_checkbox.toggled.connect(lambda checked: setattr(state, 'image_enabled', checked))
|
||||
|
||||
# Image Mode Checkbox
|
||||
image_mode_container, image_mode_checkbox = create_widget(QCheckBox, "Wallpaper Mode: ")
|
||||
image_mode_checkbox.setChecked(state.image_as_wallpaper)
|
||||
image_mode_checkbox.toggled.connect(lambda checked: setattr(state, 'image_as_wallpaper', checked))
|
||||
|
||||
# Image Position Preset
|
||||
positions = ["bottom-right", "bottom-left", "top-right", "top-left", "center"]
|
||||
image_position_container, image_position_combo = create_widget(QComboBox, "Position: ", width=180, height=30)
|
||||
image_position_combo.addItems(positions)
|
||||
idx = image_position_combo.findText(state.image_position)
|
||||
image_position_combo.setCurrentIndex(idx if idx >= 0 else 0)
|
||||
image_position_combo.currentTextChanged.connect(lambda val: setattr(state, 'image_position', val))
|
||||
|
||||
_slider_style = """
|
||||
QSlider::groove:horizontal {
|
||||
height: 3px;
|
||||
background: palette(mid);
|
||||
border-radius: 1px;
|
||||
}
|
||||
QSlider::handle:horizontal {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin: -4px 0;
|
||||
border-radius: 5px;
|
||||
}
|
||||
"""
|
||||
|
||||
# Image Width Slider
|
||||
image_width_container = QWidget()
|
||||
image_width_layout = QHBoxLayout(image_width_container)
|
||||
image_width_layout.addWidget(QLabel("Image Width: "))
|
||||
image_width = QSlider(Qt.Orientation.Horizontal)
|
||||
image_width.setFixedWidth(180)
|
||||
image_width.setStyleSheet(_slider_style)
|
||||
image_width.setMinimum(0)
|
||||
image_width.setMaximum(2500)
|
||||
image_width.setValue(state.image_width)
|
||||
image_width_val = QLabel(str(state.image_width))
|
||||
image_width_val.setFixedWidth(36)
|
||||
image_width.valueChanged.connect(lambda val: (setattr(state, 'image_width', val), image_width_val.setText(str(val))))
|
||||
image_width_layout.addWidget(image_width_val)
|
||||
image_width_layout.addWidget(image_width)
|
||||
|
||||
# Image Offset Slider
|
||||
image_offset_container = QWidget()
|
||||
image_offset_layout = QHBoxLayout(image_offset_container)
|
||||
image_offset_layout.addWidget(QLabel("Corner Offset: "))
|
||||
image_offset = QSlider(Qt.Orientation.Horizontal)
|
||||
image_offset.setFixedWidth(180)
|
||||
image_offset.setStyleSheet(_slider_style)
|
||||
image_offset.setMinimum(0)
|
||||
image_offset.setMaximum(500)
|
||||
image_offset.setValue(state.image_offset)
|
||||
image_offset_val = QLabel(str(state.image_offset))
|
||||
image_offset_val.setFixedWidth(36)
|
||||
image_offset.valueChanged.connect(lambda val: (setattr(state, 'image_offset', val), image_offset_val.setText(str(val))))
|
||||
image_offset_layout.addWidget(image_offset_val)
|
||||
image_offset_layout.addWidget(image_offset)
|
||||
|
||||
# Image Opacity Slider
|
||||
image_opacity_container = QWidget()
|
||||
image_opacity_layout = QHBoxLayout(image_opacity_container)
|
||||
image_opacity_layout.addWidget(QLabel("Image Opacity: "))
|
||||
image_opacity = QSlider(Qt.Orientation.Horizontal)
|
||||
image_opacity.setFixedWidth(180)
|
||||
image_opacity.setStyleSheet(_slider_style)
|
||||
image_opacity.setMinimum(0)
|
||||
image_opacity.setMaximum(100)
|
||||
image_opacity.setValue(state.image_opacity)
|
||||
image_opacity_val = QLabel(str(state.image_opacity))
|
||||
image_opacity_val.setFixedWidth(36)
|
||||
image_opacity.valueChanged.connect(lambda val: (setattr(state, 'image_opacity', val), image_opacity_val.setText(str(val))))
|
||||
image_opacity_layout.addWidget(image_opacity_val)
|
||||
image_opacity_layout.addWidget(image_opacity)
|
||||
|
||||
# Speed Limiting
|
||||
down_speed_limit_container, down_speed_limit = create_widget(QSpinBox, "Max Download Speed (KiB, 0 for unlimited): ", width=180, height=30)
|
||||
down_speed_limit.setMinimum(0)
|
||||
down_speed_limit.setValue(state.down_speed_limit)
|
||||
|
||||
up_speed_limit_container, up_speed_limit = create_widget(QSpinBox, "Max Upload Speed (KiB, 0 for unlimited): ", width=180, height=30)
|
||||
up_speed_limit.setMinimum(0)
|
||||
up_speed_limit.setValue(state.up_speed_limit)
|
||||
|
||||
# Connection Configs
|
||||
max_connections_container, max_connections = create_widget(QSpinBox, "Max Connections: ", width=180, height=30)
|
||||
max_connections.setMinimum(0)
|
||||
max_connections.setValue(state.max_connections)
|
||||
|
||||
|
||||
# Download Configs
|
||||
max_downloads_container, max_downloads = create_widget(QSpinBox, "Max Downloads: ", width=180, height=30)
|
||||
max_downloads.setMinimum(0)
|
||||
max_downloads.setValue(state.max_downloads)
|
||||
|
||||
# Interface Binding
|
||||
interface_container = QWidget()
|
||||
interface_layout = QHBoxLayout()
|
||||
|
||||
interface_label = QLabel("Network Interface:")
|
||||
interface_layout.addWidget(interface_label)
|
||||
interface_select = QComboBox()
|
||||
interface_select.addItems(["None"] + state.interfaces)
|
||||
|
||||
target = state.bound_interface if state.bound_interface else "None"
|
||||
|
||||
index = interface_select.findText(target)
|
||||
if index >= 0:
|
||||
interface_select.setCurrentIndex(index)
|
||||
else:
|
||||
interface_select.setCurrentIndex(0)
|
||||
|
||||
interface_select.setFixedWidth(180)
|
||||
interface_select.setFixedHeight(30)
|
||||
interface_layout.addWidget(interface_select)
|
||||
interface_container.setLayout(interface_layout)
|
||||
|
||||
# Close To Tray
|
||||
close_to_tray_container, close_to_tray_checkbox = create_widget(QCheckBox, "Close to Tray: ")
|
||||
close_to_tray_checkbox.setChecked(state.close_to_tray)
|
||||
close_to_tray_checkbox.toggled.connect(lambda checked: setattr(state, 'close_to_tray', checked))
|
||||
|
||||
# Show MegaDB Notification
|
||||
show_megadb_notification_container, show_megadb_notification_checkbox = create_widget(QCheckBox, "Show MegaDB Notifications: ")
|
||||
show_megadb_notification_checkbox.setChecked(state.show_megadb_notification)
|
||||
show_megadb_notification_checkbox.toggled.connect(lambda checked: setattr(state, 'show_megadb_notification', checked))
|
||||
|
||||
|
||||
# Save / Cancel buttons
|
||||
layout = QHBoxLayout()
|
||||
|
||||
save_btn = QPushButton("Save")
|
||||
cancel_btn = QPushButton("Cancel")
|
||||
save_btn.clicked.connect(lambda: handle_save())
|
||||
|
||||
def handle_save():
|
||||
save_settings(
|
||||
dialog.accept,
|
||||
api_url.text(),
|
||||
download_path.text(),
|
||||
down_speed_limit.value(),
|
||||
up_speed_limit.value(),
|
||||
image_path.text(),
|
||||
autoresume_checkbox.isChecked(),
|
||||
max_connections.value(),
|
||||
max_downloads.value(),
|
||||
interface_select.currentText(),
|
||||
image_width.value(),
|
||||
image_offset.value(),
|
||||
image_opacity.value(),
|
||||
image_as_wallpaper=image_mode_checkbox.isChecked(),
|
||||
image_position=image_position_combo.currentText(),
|
||||
accent_color=accent_color_input.text().strip(),
|
||||
close_to_tray=close_to_tray_checkbox.isChecked(),
|
||||
show_megadb_notification=show_megadb_notification_checkbox.isChecked()
|
||||
)
|
||||
color = _accent_selection_color()
|
||||
if color:
|
||||
self.tracker_list.setStyleSheet(
|
||||
f"QComboBox QAbstractItemView::item:selected {{ background: {color}; }}"
|
||||
)
|
||||
else:
|
||||
self.tracker_list.setStyleSheet("")
|
||||
|
||||
cancel_btn.clicked.connect(dialog.reject)
|
||||
layout.addWidget(cancel_btn)
|
||||
layout.addWidget(save_btn)
|
||||
|
||||
tabs = QtWidgets.QTabWidget()
|
||||
create_tab("General", [autoresume_container, update_checkbox_container, transparent_window_container, accent_color_container, close_to_tray_container, show_megadb_notification_container], tabs=tabs, stretch=True)
|
||||
create_tab("Image", [enable_image_container, image_mode_container, image_position_container, image_width_container, image_offset_container, image_opacity_container], tabs=tabs, stretch=True)
|
||||
create_tab("Paths", [download_path_container, image_path_container], tabs=tabs, stretch=True)
|
||||
create_tab("Network", [interface_container, max_connections_container, max_downloads_container, up_speed_limit_container, down_speed_limit_container, api_url_container], tabs=tabs, stretch=True)
|
||||
|
||||
|
||||
dialog_layout.addWidget(tabs)
|
||||
dialog_layout.addLayout(layout)
|
||||
|
||||
def on_dialog_finished(result): # Undo Image changes if "Save" button is not pressed
|
||||
if result == QtWidgets.QDialog.DialogCode.Rejected:
|
||||
state.image_path = temp_image_path
|
||||
state.image_width = temp_image_width
|
||||
state.image_offset = temp_image_offset
|
||||
state.image_opacity = temp_image_opacity
|
||||
state.image_enabled = temp_image_enabled
|
||||
state.image_as_wallpaper = temp_image_as_wallpaper
|
||||
state.image_position = temp_image_position
|
||||
|
||||
dialog.finished.connect(on_dialog_finished)
|
||||
dialog.exec()
|
||||
@@ -0,0 +1,98 @@
|
||||
from PySide6.QtGui import QColor
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import darkdetect
|
||||
|
||||
def _is_dark_mode():
|
||||
return darkdetect.isDark()
|
||||
|
||||
|
||||
def _theme_colors():
|
||||
dark = _is_dark_mode()
|
||||
if dark:
|
||||
return {
|
||||
"text": "rgba(255, 255, 255, 0.9)",
|
||||
"border": "rgba(255, 255, 255, 0.06)",
|
||||
"selected": "rgba(255, 255, 255, 0.04)",
|
||||
"header_text": "rgba(255, 255, 255, 0.5)",
|
||||
"header_border": "rgba(255, 255, 255, 0.1)",
|
||||
"hover": QColor(255, 255, 255, 15),
|
||||
}
|
||||
else:
|
||||
return {
|
||||
"text": "rgba(0, 0, 0, 0.87)",
|
||||
"border": "rgba(0, 0, 0, 0.08)",
|
||||
"selected": "rgba(0, 0, 0, 0.06)",
|
||||
"header_text": "rgba(0, 0, 0, 0.6)",
|
||||
"header_border": "rgba(0, 0, 0, 0.12)",
|
||||
"hover": QColor(0, 0, 0, 15),
|
||||
}
|
||||
|
||||
|
||||
def _accent_selection_color(alpha: float = 0.35) -> str:
|
||||
if not state.accent_color:
|
||||
return None
|
||||
try:
|
||||
hex_color = state.accent_color.lstrip('#')
|
||||
if len(hex_color) != 6:
|
||||
return None
|
||||
r, g, b = int(hex_color[0:2], 16), int(hex_color[2:4], 16), int(hex_color[4:6], 16)
|
||||
return f"rgba({r}, {g}, {b}, {alpha})"
|
||||
except ValueError:
|
||||
consoleLog(f"Invalid Color: {state.accent_color}")
|
||||
return None
|
||||
|
||||
|
||||
def _table_stylesheet(view_type="QTableWidget"):
|
||||
c = _theme_colors()
|
||||
dark = _is_dark_mode()
|
||||
color_rule = "" if dark else f"color: {c['text']};"
|
||||
selected_bg = _accent_selection_color() or c["selected"]
|
||||
selection_color_rule = f"selection-background-color: {selected_bg};" if state.accent_color else ""
|
||||
return f"""
|
||||
{view_type} {{
|
||||
border: none;
|
||||
outline: 0;
|
||||
font-size: 13px;
|
||||
{selection_color_rule}
|
||||
{color_rule}
|
||||
}}
|
||||
{view_type}::item {{
|
||||
border-bottom: 1px solid {c["border"]};
|
||||
padding: 6px 14px;
|
||||
outline: none;
|
||||
{color_rule}
|
||||
}}
|
||||
{view_type}::item:selected {{
|
||||
background: {selected_bg};
|
||||
outline: none;
|
||||
border: none;
|
||||
border-bottom: 1px solid {c["border"]};
|
||||
}}
|
||||
{view_type}::item:focus {{
|
||||
outline: none;
|
||||
border: none;
|
||||
border-bottom: 1px solid {c["border"]};
|
||||
}}
|
||||
QHeaderView {{
|
||||
background: transparent;
|
||||
}}
|
||||
QHeaderView::section {{
|
||||
background: transparent;
|
||||
color: {c["header_text"]};
|
||||
font-weight: normal;
|
||||
border: none;
|
||||
border-bottom: 1px solid {c["header_border"]};
|
||||
padding: 6px 14px;
|
||||
}}
|
||||
QHeaderView::section:checked {{
|
||||
background: transparent;
|
||||
color: {c["header_text"]};
|
||||
font-weight: normal;
|
||||
}}
|
||||
"""
|
||||
|
||||
|
||||
SVG_PLAY = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><polygon points="6,3 20,12 6,21" fill="{color}"/></svg>'
|
||||
SVG_PAUSE = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect x="5" y="3" width="4" height="18" rx="1" fill="{color}"/><rect x="15" y="3" width="4" height="18" rx="1" fill="{color}"/></svg>'
|
||||
SVG_FOLDER = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M2 6c0-1.1.9-2 2-2h5l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6z" fill="{color}"/></svg>'
|
||||
@@ -0,0 +1,14 @@
|
||||
from interface.dialogs.theme import _theme_colors
|
||||
from PySide6.QtWidgets import QStyledItemDelegate
|
||||
|
||||
class TrackerHoverDelegate(QStyledItemDelegate):
|
||||
def __init__(self, get_hovered_row, parent=None):
|
||||
super().__init__(parent)
|
||||
self._get_hovered_row = get_hovered_row
|
||||
|
||||
def paint(self, painter, option, index):
|
||||
if index.row() == self._get_hovered_row():
|
||||
painter.save()
|
||||
painter.fillRect(option.rect, _theme_colors()["hover"])
|
||||
painter.restore()
|
||||
super().paint(painter, option, index)
|
||||
@@ -0,0 +1,26 @@
|
||||
from interface.dialogs.theme import _table_stylesheet
|
||||
from PySide6.QtWidgets import QTableWidget
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
|
||||
def _create_tracker_table(self):
|
||||
table = QTableWidget()
|
||||
table.setEditTriggers(QtWidgets.QAbstractItemView.EditTrigger.NoEditTriggers)
|
||||
table.verticalHeader().setVisible(False)
|
||||
table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectionBehavior.SelectRows)
|
||||
table.setSelectionMode(QtWidgets.QAbstractItemView.SelectionMode.ExtendedSelection)
|
||||
table.setShowGrid(False)
|
||||
table.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
table.viewport().setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
table.horizontalHeader().setDefaultAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
table.horizontalHeader().setHighlightSections(False)
|
||||
table.horizontalHeader().setStretchLastSection(False)
|
||||
table.setStyleSheet(_table_stylesheet("QTableWidget"))
|
||||
table.setMouseTracking(True)
|
||||
table.viewport().setMouseTracking(True)
|
||||
table.viewport().installEventFilter(self)
|
||||
|
||||
table.setItemDelegateForColumn(0, self._tracker_elided_delegate)
|
||||
|
||||
self._apply_default_headers(table)
|
||||
return table
|
||||
@@ -0,0 +1,83 @@
|
||||
from PySide6.QtWidgets import QDialog, QMessageBox, QCheckBox
|
||||
from utils.network.update_checker import get_updates
|
||||
from utils.network.updater import download_update
|
||||
from utils.config.config import create_config
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
from pathlib import Path
|
||||
import webbrowser
|
||||
import platform
|
||||
import json
|
||||
import os
|
||||
|
||||
RELEASES_URL = "https://github.com/KeksPirates/SoftwareManager/releases/latest"
|
||||
|
||||
def _get_build_info_path() -> (Path | None):
|
||||
current_dir = Path(__file__).resolve().parent
|
||||
|
||||
for _ in range(6): # Climb max 6 directories
|
||||
file = current_dir / "build_info.json"
|
||||
if file.exists():
|
||||
return file
|
||||
# Go up one directory if file isn't found
|
||||
current_dir = current_dir.parent
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def get_version() -> None:
|
||||
# Get build info filepath
|
||||
build_info_path = _get_build_info_path()
|
||||
if build_info_path and os.path.exists(build_info_path):
|
||||
with open(build_info_path, "r") as f:
|
||||
build_info = json.load(f)
|
||||
state.version = build_info.get("version")
|
||||
else:
|
||||
consoleLog(f"Could not find build info file (Path: {build_info_path})")
|
||||
|
||||
|
||||
def _show_notify_dialog(latest: str) -> None:
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Icon.Information)
|
||||
msg.setWindowTitle("Update Available")
|
||||
msg.setText(f"A new version is available: <b>{latest}</b>")
|
||||
msg.setInformativeText("Visit the releases page to download it.")
|
||||
|
||||
dont_show = QCheckBox("Don't show again")
|
||||
msg.setCheckBox(dont_show)
|
||||
|
||||
open_btn = msg.addButton("Open Releases Page", QMessageBox.ButtonRole.AcceptRole)
|
||||
msg.addButton("Dismiss", QMessageBox.ButtonRole.RejectRole)
|
||||
|
||||
msg.exec()
|
||||
|
||||
if dont_show.isChecked():
|
||||
state.ignore_updates = True
|
||||
create_config()
|
||||
|
||||
if msg.clickedButton() == open_btn:
|
||||
webbrowser.open(RELEASES_URL)
|
||||
|
||||
|
||||
class UpdateDialog(QDialog):
|
||||
def __init__(self, parent=None):
|
||||
if state.ignore_updates:
|
||||
return
|
||||
|
||||
assets, latest = get_updates()
|
||||
if assets is None:
|
||||
return
|
||||
|
||||
if platform.system() == "Windows":
|
||||
msg = QMessageBox()
|
||||
msg.setIcon(QMessageBox.Icon.Information)
|
||||
msg.setWindowTitle("Update Available")
|
||||
msg.setText(f"A new version is available\n({latest})")
|
||||
msg.setInformativeText("Press Ok to download.")
|
||||
msg.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Ignore)
|
||||
response = msg.exec_()
|
||||
if response == QMessageBox.StandardButton.Ok:
|
||||
download_update(assets)
|
||||
else:
|
||||
_show_notify_dialog(latest)
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
from interface.dialogs.trackerhoverdelegate import TrackerHoverDelegate
|
||||
from interface.dialogs.elideditemdelegate import ElidedItemDelegate
|
||||
from interface.dialogs.trackertable import _create_tracker_table
|
||||
from interface.dialogs.downloadlist import _create_download_list
|
||||
from interface.assets.base64_icons import settings_white_base64
|
||||
from interface.assets.base64_icons import settings_black_base64
|
||||
from interface.dialogs.downloadlist import download_list_update
|
||||
from interface.dialogs.update import get_version, UpdateDialog
|
||||
from interface.dialogs.theme import _accent_selection_color
|
||||
from utils.logging.logs import consoleLog, flush_log_buffer
|
||||
from interface.dialogs.downloadmodel import DownloadModel
|
||||
from interface.dialogs.settings import settings_dialog
|
||||
from interface.assets.base64_icons import logo_base64
|
||||
from interface.dialogs.eventfilter import eventFilter
|
||||
from utils.network.download import download_selected
|
||||
from interface.utils.searchhelper import run_search
|
||||
from interface.utils.tabhelper import create_tab
|
||||
from utils.general.shutdown import closehelper
|
||||
from utils.general.wrappers import run_thread
|
||||
from utils.logging.logs import log_emitter
|
||||
from interface.dialogs.image import Image
|
||||
from utils.data.state import state
|
||||
|
||||
import interface.dialogs.contextmenu
|
||||
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import (
|
||||
Qt,
|
||||
QTimer,
|
||||
Signal,
|
||||
QSize
|
||||
)
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QLineEdit,
|
||||
QTableView,
|
||||
QWidget,
|
||||
QVBoxLayout,
|
||||
QLabel,
|
||||
QHBoxLayout,
|
||||
QComboBox,
|
||||
QTabWidget,
|
||||
QHeaderView,
|
||||
QTableWidgetItem,
|
||||
QTextEdit,
|
||||
QStatusBar,
|
||||
QStyledItemDelegate,
|
||||
)
|
||||
|
||||
from PySide6.QtGui import (
|
||||
QIcon,
|
||||
QCloseEvent,
|
||||
QPixmap,
|
||||
QGuiApplication,
|
||||
)
|
||||
|
||||
import darkdetect
|
||||
import threading
|
||||
import platform
|
||||
import base64
|
||||
|
||||
def windowCloseHelper():
|
||||
QGuiApplication.quit()
|
||||
|
||||
class CenteredDelegate(QStyledItemDelegate):
|
||||
def initStyleOption(self, option, index):
|
||||
super().initStyleOption(option, index)
|
||||
option.displayAlignment = Qt.AlignmentFlag.AlignVCenter
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, QWidget):
|
||||
eventFilter = eventFilter
|
||||
search_results_signal = Signal(list)
|
||||
_instance = None
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
MainWindow._instance = self
|
||||
self.search_results_signal.connect(self._on_search_results)
|
||||
|
||||
pixmap = QPixmap()
|
||||
image_data = base64.b64decode(logo_base64)
|
||||
pixmap.loadFromData(image_data)
|
||||
self.setWindowIcon(QIcon(pixmap))
|
||||
|
||||
# Set AppID on Windows
|
||||
if platform.system() == "Windows":
|
||||
try:
|
||||
import ctypes
|
||||
appid = 'SoftwareManager'
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(appid)
|
||||
except Exception as e:
|
||||
consoleLog(f"Could not set app ID: {e}")
|
||||
|
||||
# Get current version
|
||||
# interface.dialogs.update
|
||||
get_version()
|
||||
UpdateDialog()
|
||||
|
||||
# Initialize Window
|
||||
self.setWindowTitle("Software Manager")
|
||||
self.setGeometry(100, 100, 800, 600)
|
||||
|
||||
self.controls = QWidget()
|
||||
self.controlsLayout = QVBoxLayout()
|
||||
|
||||
# Searchbar
|
||||
self.searchbar = QLineEdit()
|
||||
self.searchbar.setPlaceholderText("Search for software...")
|
||||
self.searchbar.setClearButtonEnabled(True)
|
||||
self.searchbar.setMinimumHeight(30)
|
||||
self.searchbar.returnPressed.connect(self._start_search)
|
||||
|
||||
# Download Button
|
||||
self.dlbutton = QtWidgets.QPushButton("Download")
|
||||
self.dlbutton.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
|
||||
# Dialog for empty results
|
||||
self.emptyResults = QLabel("No Results")
|
||||
self.emptyResults.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
self.emptyResults.hide()
|
||||
|
||||
self.downloadList = QTableView()
|
||||
self.downloadList.setMouseTracking(True)
|
||||
self._hovered_row = -1
|
||||
self._tracker_hovered_row = -1
|
||||
self._tracker_hovered_table = None
|
||||
self._last_dl_row_count = 0
|
||||
self.emptyDownload = QLabel("No items in downloads.")
|
||||
self.emptyDownload.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
||||
|
||||
self.consoleLog = QTextEdit()
|
||||
self.statusbar = QStatusBar()
|
||||
|
||||
log_emitter.new_log.connect(self._on_log_signal)
|
||||
flush_log_buffer()
|
||||
|
||||
self._tracker_elided_delegate = ElidedItemDelegate(lambda: self._tracker_hovered_row, self)
|
||||
self._tracker_hover_delegate = TrackerHoverDelegate(lambda: self._tracker_hovered_row, self)
|
||||
|
||||
state.trackertable = _create_tracker_table(self)
|
||||
state.trackertable.cellDoubleClicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.selectedItems(),))))
|
||||
|
||||
container = QWidget()
|
||||
containerLayout = QVBoxLayout()
|
||||
containerLayout.addWidget(self.searchbar)
|
||||
containerLayout.addWidget(state.trackertable)
|
||||
|
||||
# interface.dialogs.hoverrowdelegate
|
||||
self.download_model = DownloadModel()
|
||||
self.downloadList = _create_download_list(self)
|
||||
self.downloadList.viewport().installEventFilter(self)
|
||||
|
||||
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.selectedItems(),))))
|
||||
|
||||
container.setLayout(containerLayout)
|
||||
self.setCentralWidget(container)
|
||||
|
||||
self.tabs = QTabWidget()
|
||||
self.tabs.setStyleSheet("""
|
||||
QTabBar::tab {
|
||||
font-size: 11px;
|
||||
padding: 2px 8px;
|
||||
height: 25px;
|
||||
}
|
||||
QTabWidget::pane {
|
||||
margin-top: -20px;
|
||||
}
|
||||
""")
|
||||
|
||||
self.horizontal_layout = QHBoxLayout()
|
||||
self.horizontal_layout.addWidget(self.emptyResults, stretch=3)
|
||||
self.horizontal_layout.addWidget(state.trackertable)
|
||||
|
||||
# Tabs
|
||||
create_tab("Search", [self.searchbar, self.horizontal_layout, self.dlbutton], tabs=self.tabs, stretch=False)
|
||||
create_tab("Downloads", [self.emptyDownload, self.downloadList], tabs=self.tabs, stretch=False)
|
||||
|
||||
# Corner Widget (Settings Button, Tracker list, Tab button container)
|
||||
self.corner_widget = QWidget()
|
||||
self.corner_layout = QHBoxLayout(self.corner_widget)
|
||||
self.corner_layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
# Tracker list
|
||||
self.tracker_list = QComboBox()
|
||||
self.tracker_list.setContentsMargins(0, 0, 0, 0)
|
||||
self.tracker_list.setItemDelegate(CenteredDelegate(self.tracker_list))
|
||||
self.tracker_list.addItems(list(state.trackers.keys()))
|
||||
self.tracker_list.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.tracker_list.activated.connect(self.set_tracker)
|
||||
if state.accent_color:
|
||||
self.tracker_list.setStyleSheet(
|
||||
f"QComboBox QAbstractItemView::item:selected {{ background: {_accent_selection_color()}; }}"
|
||||
)
|
||||
self.corner_layout.addWidget(self.tracker_list)
|
||||
|
||||
# Settings button
|
||||
self.settings_btn = QtWidgets.QToolButton()
|
||||
self.settings_btn.setIconSize(QSize(21, 21))
|
||||
self.settings_btn.setStyleSheet("background: transparent;")
|
||||
self.settings_btn.setToolTip("Settings")
|
||||
self.settings_btn.setCursor(Qt.CursorShape.PointingHandCursor)
|
||||
self.settings_btn.clicked.connect(lambda: settings_dialog(self))
|
||||
self.corner_layout.addWidget(self.settings_btn)
|
||||
|
||||
# Adjust theme based on system preferences
|
||||
if darkdetect.isDark():
|
||||
settings_white_pixmap = QPixmap()
|
||||
settings_white = base64.b64decode(settings_white_base64)
|
||||
settings_white_pixmap.loadFromData(settings_white)
|
||||
self.settings_btn.setIcon(QIcon(settings_white_pixmap))
|
||||
else:
|
||||
settings_black_pixmap = QPixmap()
|
||||
settings_black = base64.b64decode(settings_black_base64)
|
||||
settings_black_pixmap.loadFromData(settings_black)
|
||||
self.settings_btn.setIcon(QIcon(settings_black_pixmap))
|
||||
|
||||
self.tab_wrapper = QWidget()
|
||||
self.tab_layout = QVBoxLayout()
|
||||
self.tab_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.tab_layout.setSpacing(0)
|
||||
|
||||
self.tab_bar_layout = QHBoxLayout()
|
||||
self.tab_bar_layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.tab_bar_layout.setSpacing(0)
|
||||
|
||||
self.tab_bar_layout.addWidget(self.tabs.tabBar(), stretch=0)
|
||||
self.tab_bar_layout.addStretch()
|
||||
self.tab_bar_layout.addWidget(self.corner_widget, stretch=0)
|
||||
|
||||
self.tab_layout.addLayout(self.tab_bar_layout)
|
||||
self.tab_layout.addWidget(self.tabs)
|
||||
self.tab_wrapper.setLayout(self.tab_layout)
|
||||
|
||||
containerLayout.addWidget(self.tab_wrapper)
|
||||
containerLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
|
||||
|
||||
self.consoleLog.setReadOnly(True)
|
||||
self.consoleLog.setFixedHeight(150)
|
||||
self.consoleLog.setStyleSheet("margin-bottom: 0px; background: transparent;")
|
||||
containerLayout.addWidget(self.consoleLog)
|
||||
|
||||
self.statusbar.show()
|
||||
self.statusbar.setStyleSheet("background: transparent; border: none; padding-right: 1px; padding-left: 6px; padding-bottom: 1px; margin-top: -8px")
|
||||
|
||||
self.version = QLabel(f"Version: {state.version}")
|
||||
self.statusbar.addPermanentWidget(self.version, Qt.AlignmentFlag.AlignLeft)
|
||||
|
||||
# (\u2193) Arrow down, (\u2191) Arrow up
|
||||
self.speed_label = QLabel("↓ 0.0 kB/s ↑ 0.0 kB/s")
|
||||
self.speed_label.setStyleSheet("padding-right: 6px;")
|
||||
self.statusbar.addPermanentWidget(self.speed_label)
|
||||
|
||||
self.setStatusBar(self.statusbar)
|
||||
|
||||
self.download_timer = QTimer()
|
||||
self.download_timer.timeout.connect(lambda: download_list_update(self))
|
||||
self.download_timer.start(500)
|
||||
|
||||
self.active_timer = QTimer()
|
||||
self.active_timer.timeout.connect(self.show_empty_downloads)
|
||||
self.active_timer.start(500)
|
||||
|
||||
self._context_menu_downloads = interface.dialogs.contextmenu.ContextMenu_Downloads(self)
|
||||
self._context_menu_trackertable = interface.dialogs.contextmenu.ContextMenu_TrackerTable(self)
|
||||
self.image_overlay = Image(self)
|
||||
|
||||
def _apply_default_headers(self, table):
|
||||
tracker_name = state.currenttracker if hasattr(state, 'currenttracker') and state.currenttracker else None
|
||||
if tracker_name is None:
|
||||
keys = list(state.trackers.keys())
|
||||
tracker_name = keys[0] if keys else None
|
||||
|
||||
headers = []
|
||||
if tracker_name and tracker_name in state.trackers:
|
||||
tracker_mod = state.trackers[tracker_name]
|
||||
if hasattr(tracker_mod, 'headers'):
|
||||
headers = tracker_mod.headers
|
||||
elif hasattr(tracker_mod, 'HEADERS'):
|
||||
headers = tracker_mod.HEADERS
|
||||
|
||||
if not headers:
|
||||
if state.currenttracker == "rutracker":
|
||||
headers = ["Post Title", "Author", "Seeders", "Leechers"]
|
||||
elif state.currenttracker == "steamrip":
|
||||
headers = ["Game"]
|
||||
else:
|
||||
headers = ["Post Title", "Author"] # i know this makes it less "modular", but its qol
|
||||
|
||||
table.setRowCount(0)
|
||||
|
||||
col_count = table.columnCount()
|
||||
if col_count != len(headers):
|
||||
for i in range(col_count):
|
||||
table.setItemDelegateForColumn(i, None)
|
||||
table.setColumnCount(len(headers))
|
||||
|
||||
table.setHorizontalHeaderLabels(headers)
|
||||
self._apply_tracker_column_modes(table, len(headers))
|
||||
|
||||
def _apply_tracker_column_modes(self, table, col_count):
|
||||
header = table.horizontalHeader()
|
||||
if col_count > 0:
|
||||
header.setSectionResizeMode(0, QHeaderView.ResizeMode.Stretch)
|
||||
table.setItemDelegateForColumn(0, self._tracker_elided_delegate)
|
||||
for i in range(1, col_count):
|
||||
header.setSectionResizeMode(i, QHeaderView.ResizeMode.ResizeToContents)
|
||||
table.setItemDelegateForColumn(i, self._tracker_hover_delegate)
|
||||
|
||||
def _start_search(self):
|
||||
self.searchbar.setEnabled(False)
|
||||
state.trackertable.setRowCount(0)
|
||||
self.show_empty_results(False)
|
||||
|
||||
def _search_thread():
|
||||
try:
|
||||
run_search(self)
|
||||
except Exception as e:
|
||||
consoleLog(f"Search error: {e}", True)
|
||||
self.search_results_signal.emit([])
|
||||
run_thread(threading.Thread(target=_search_thread))
|
||||
|
||||
def _on_log_signal(self, text):
|
||||
if hasattr(self, 'consoleLog'):
|
||||
self.consoleLog.append(text)
|
||||
# Delete lines if exceeding 500
|
||||
doc = self.consoleLog.document()
|
||||
if doc.blockCount() > 500:
|
||||
cursor = self.consoleLog.textCursor()
|
||||
cursor.movePosition(cursor.MoveOperation.Start)
|
||||
cursor.movePosition(cursor.MoveOperation.Down, cursor.MoveMode.KeepAnchor, doc.blockCount() - 500)
|
||||
cursor.removeSelectedText()
|
||||
cursor.deleteChar()
|
||||
|
||||
self.consoleLog.verticalScrollBar().setValue(
|
||||
self.consoleLog.verticalScrollBar().maximum()
|
||||
)
|
||||
|
||||
def _on_search_results(self, headers):
|
||||
if state.posts is None or state.posts == []:
|
||||
self.show_empty_results(True)
|
||||
self.searchbar.setEnabled(True)
|
||||
self.searchbar.setFocus()
|
||||
return
|
||||
|
||||
table = state.trackertable
|
||||
table.setRowCount(0)
|
||||
|
||||
col_count = table.columnCount()
|
||||
need_reconfig = col_count != len(headers)
|
||||
|
||||
if need_reconfig:
|
||||
for i in range(col_count):
|
||||
table.setItemDelegateForColumn(i, None)
|
||||
table.setColumnCount(len(headers))
|
||||
table.setHorizontalHeaderLabels(headers)
|
||||
self._apply_tracker_column_modes(table, len(headers))
|
||||
else:
|
||||
table.setHorizontalHeaderLabels(headers)
|
||||
|
||||
table.setRowCount(len(state.posts))
|
||||
for x, rowdata in enumerate(state.posts):
|
||||
for y, (_, data) in enumerate(rowdata.items()):
|
||||
item = QTableWidgetItem(str(data))
|
||||
item.setData(Qt.ItemDataRole.UserRole, x)
|
||||
table.setItem(x, y, item)
|
||||
|
||||
self.show_empty_results(False)
|
||||
self.searchbar.setEnabled(True)
|
||||
self.searchbar.setFocus()
|
||||
|
||||
self._update_speed_label()
|
||||
|
||||
|
||||
def _update_speed_label(self):
|
||||
total_down = 0
|
||||
total_up = 0
|
||||
with state.downloads_lock:
|
||||
active_items = list(state.active_downloads.values())
|
||||
|
||||
for handle in active_items:
|
||||
try:
|
||||
s = handle.status()
|
||||
total_down += s.download_rate
|
||||
total_up += s.upload_rate
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while updating speed label: {e}")
|
||||
down_kb = total_down / 1024
|
||||
up_kb = total_up / 1024
|
||||
down_text = f"{down_kb / 1024:.1f} MB/s" if down_kb > 1024 else f"{down_kb:.1f} kB/s"
|
||||
up_text = f"{up_kb / 1024:.1f} MB/s" if up_kb > 1024 else f"{up_kb:.1f} kB/s"
|
||||
|
||||
|
||||
if hasattr(self, 'speed_label'):
|
||||
self.speed_label.setText(f"↓ {down_text} ↑ {up_text}")
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
state.trackertable.clearSelection()
|
||||
self.downloadList.clearSelection()
|
||||
super().mousePressEvent(event)
|
||||
|
||||
def changeEvent(self, event):
|
||||
super().changeEvent(event)
|
||||
|
||||
def closeEvent(self, event: QCloseEvent):
|
||||
if state.close_to_tray is True:
|
||||
event.ignore()
|
||||
self.hide()
|
||||
return
|
||||
else:
|
||||
self.shutdown(event)
|
||||
|
||||
def shutdown(self, event: QCloseEvent):
|
||||
closehelper()
|
||||
event.accept()
|
||||
from utils.general.shutdown import force_exit
|
||||
force_exit()
|
||||
|
||||
def _invalidate_hover_row(self, row):
|
||||
if row >= 0 and self.download_model:
|
||||
self.downloadList.viewport().update()
|
||||
|
||||
def set_tracker(self, _):
|
||||
state.currenttracker = self.tracker_list.currentText()
|
||||
self._apply_default_headers(state.trackertable)
|
||||
|
||||
def show_empty_results(self, show: bool):
|
||||
if show:
|
||||
state.trackertable.hide()
|
||||
self.emptyResults.show()
|
||||
else:
|
||||
state.trackertable.show()
|
||||
self.emptyResults.hide()
|
||||
|
||||
def show_empty_downloads(self):
|
||||
with state.downloads_lock:
|
||||
has_downloads = len(state.active_downloads) > 0
|
||||
if has_downloads:
|
||||
self.emptyDownload.hide()
|
||||
self.downloadList.show()
|
||||
else:
|
||||
self.emptyDownload.show()
|
||||
self.downloadList.hide()
|
||||
@@ -0,0 +1,23 @@
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
from data.sources import SCRAPERS
|
||||
|
||||
for scraper in SCRAPERS:
|
||||
state.trackers[scraper.name] = scraper
|
||||
|
||||
def run_search(self) -> None:
|
||||
search_text = self.searchbar.text()
|
||||
# Check for empty search
|
||||
if search_text == "":
|
||||
consoleLog("Error: Can't search for nothing")
|
||||
return
|
||||
|
||||
state.posts = []
|
||||
consoleLog(f"User searched for: {search_text}")
|
||||
|
||||
# Get current tracker and call its search function
|
||||
scraper = state.trackers[state.currenttracker]
|
||||
state.posts = scraper.search(search_text)
|
||||
|
||||
# Update GUI headers to match the current scraper
|
||||
self.search_results_signal.emit(scraper.headers)
|
||||
@@ -0,0 +1,27 @@
|
||||
from PySide6.QtGui import QIcon, QPixmap, QPainter
|
||||
from PySide6.QtCore import Qt, QByteArray
|
||||
from PySide6.QtSvg import QSvgRenderer
|
||||
from PySide6 import QtWidgets
|
||||
import darkdetect
|
||||
|
||||
# Check if darkmode is enabled
|
||||
def _is_dark_mode():
|
||||
return darkdetect.isDark()
|
||||
|
||||
def svg_icon(svg_str, size=20):
|
||||
app = QtWidgets.QApplication.instance()
|
||||
if app:
|
||||
if _is_dark_mode():
|
||||
color = "white"
|
||||
else:
|
||||
color = "#555555"
|
||||
else:
|
||||
color = "white"
|
||||
svg = svg_str.replace("{color}", color)
|
||||
renderer = QSvgRenderer(QByteArray(svg.encode()))
|
||||
pixmap = QPixmap(size, size)
|
||||
pixmap.fill(Qt.GlobalColor.transparent)
|
||||
painter = QPainter(pixmap)
|
||||
renderer.render(painter)
|
||||
painter.end()
|
||||
return QIcon(pixmap)
|
||||
@@ -0,0 +1,22 @@
|
||||
from PySide6.QtWidgets import QWidget, QVBoxLayout, QLayout
|
||||
|
||||
# Tab creation helper function
|
||||
def create_tab(title, items, tabs, stretch):
|
||||
tab = QWidget()
|
||||
layout = QVBoxLayout()
|
||||
|
||||
for item in items:
|
||||
if item is None:
|
||||
continue
|
||||
|
||||
if isinstance(item, QLayout):
|
||||
layout.addLayout(item)
|
||||
else:
|
||||
layout.addWidget(item)
|
||||
|
||||
if stretch:
|
||||
layout.addStretch()
|
||||
|
||||
tab.setLayout(layout)
|
||||
tabs.addTab(tab, title)
|
||||
return tab
|
||||
@@ -1,66 +1,162 @@
|
||||
from core.interface.gui import MainWindow, windowCloseHelper
|
||||
from core.utils.data.state import state
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.network.libtorrent_misc import send_notification, update_log, check_deleted_files
|
||||
from core.utils.logging.logs import get_download_logs
|
||||
from core.utils.general.shutdown import closehelper, shutdown_event
|
||||
from core.utils.general.wrappers import run_thread
|
||||
from core.utils.logging.loghandler import split_data, check_completed, check_downloads
|
||||
from core.network.interface import list_interfaces, init_interfaces
|
||||
from core.utils.config.config import read_config
|
||||
from utils.logging.loghandler import split_data, check_completed, check_downloads
|
||||
from network.interface import list_interfaces, init_interfaces
|
||||
from PySide6.QtNetwork import QLocalServer, QLocalSocket
|
||||
from utils.logging.logs import get_download_logs
|
||||
from utils.logging.logs import set_main_window
|
||||
from network.libtorrent_int import check_space
|
||||
from utils.general.shutdown import closehelper
|
||||
from utils.general.wrappers import run_thread
|
||||
from interface.assets.base64_icons import logo_base64
|
||||
from PySide6.QtWidgets import QSystemTrayIcon, QMenu
|
||||
from network.libtorrent_misc import AppDaemons
|
||||
from utils.general.shutdown import force_exit
|
||||
from utils.config.config import read_config
|
||||
from PySide6.QtGui import QAction, QPixmap
|
||||
from utils.logging.logs import consoleLog
|
||||
from interface.gui import MainWindow
|
||||
from PySide6.QtCore import Qt, QObject, QThread
|
||||
from utils.data.state import state
|
||||
from PySide6 import QtWidgets
|
||||
from PySide6.QtCore import Qt
|
||||
import qdarktheme
|
||||
import threading
|
||||
import platform
|
||||
import base64
|
||||
import signal
|
||||
import sys
|
||||
import time
|
||||
import sys
|
||||
|
||||
def run_gui():
|
||||
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
|
||||
qdarktheme.setup_theme("auto")
|
||||
SERVER_NAME = "SoftwareManager_KeksPirates"
|
||||
|
||||
class SingleInstance(QObject):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.server = QLocalServer()
|
||||
|
||||
socket = QLocalSocket()
|
||||
socket.connectToServer(SERVER_NAME)
|
||||
|
||||
if socket.waitForConnected(100):
|
||||
socket.write(b"raise")
|
||||
socket.flush()
|
||||
socket.waitForBytesWritten(100)
|
||||
self.is_running = True
|
||||
else:
|
||||
QLocalServer.removeServer(SERVER_NAME)
|
||||
self.server.listen(SERVER_NAME)
|
||||
self.server.newConnection.connect(self.handle_connection)
|
||||
self.is_running = False
|
||||
|
||||
def handle_connection(self):
|
||||
socket = self.server.nextPendingConnection()
|
||||
socket.readyRead.connect(lambda: self.read_socket(socket))
|
||||
|
||||
def read_socket(self, socket):
|
||||
msg = socket.readAll().data()
|
||||
if msg == b"raise":
|
||||
self.on_raise()
|
||||
|
||||
def on_raise(self):
|
||||
pass
|
||||
|
||||
def check_running(app):
|
||||
single = SingleInstance()
|
||||
if single.is_running:
|
||||
print("Another instance is already running. Exiting this instance.")
|
||||
closehelper()
|
||||
force_exit()
|
||||
|
||||
app._single_instance = single
|
||||
|
||||
|
||||
def run_gui(app):
|
||||
single = app._single_instance
|
||||
custom_colors = {}
|
||||
if state.accent_color:
|
||||
custom_colors["primary"] = state.accent_color
|
||||
qdarktheme.setup_theme("auto", custom_colors=custom_colors if custom_colors else None)
|
||||
widget = MainWindow()
|
||||
|
||||
|
||||
# Check OS for window transparency compatibility and apply
|
||||
if state.window_transparency and platform.system() != "Windows":
|
||||
widget.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)
|
||||
qdarktheme.setup_theme("auto", custom_colors={"background": "#00000000"})
|
||||
transparent_colors = {"background": "#00000000", **custom_colors}
|
||||
qdarktheme.setup_theme("auto", custom_colors=transparent_colors)
|
||||
|
||||
pixmap = QPixmap()
|
||||
image_data = base64.b64decode(logo_base64)
|
||||
pixmap.loadFromData(image_data)
|
||||
|
||||
tray = QSystemTrayIcon()
|
||||
tray.setIcon(pixmap)
|
||||
tray.setVisible(True)
|
||||
|
||||
menu = QMenu()
|
||||
|
||||
show = QAction("Show")
|
||||
show.triggered.connect(lambda: widget.show())
|
||||
menu.addAction(show)
|
||||
|
||||
quit = QAction("Quit")
|
||||
quit.triggered.connect(lambda: (closehelper(), force_exit()))
|
||||
menu.addAction(quit)
|
||||
|
||||
tray.activated.connect(lambda reason: widget.show() if reason == QSystemTrayIcon.ActivationReason.Trigger else None)
|
||||
tray.setContextMenu(menu)
|
||||
|
||||
def show_from_tray():
|
||||
widget.show()
|
||||
widget.raise_()
|
||||
widget.activateWindow()
|
||||
|
||||
single.on_raise = show_from_tray
|
||||
|
||||
from data.hosts.megadb import ui_bridge, show_megadb_notification
|
||||
ui_bridge.show_notification.connect(show_megadb_notification)
|
||||
|
||||
from core.utils.logging.logs import set_main_window
|
||||
set_main_window(widget)
|
||||
widget.show()
|
||||
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||
sys.exit(app.exec())
|
||||
|
||||
def keyboardinterrupthandler(signum, frame):
|
||||
closehelper()
|
||||
from core.utils.general.shutdown import force_exit
|
||||
force_exit()
|
||||
|
||||
|
||||
def main():
|
||||
# Begin counting startup time
|
||||
start_time = time.perf_counter()
|
||||
# Initialize UI Engine
|
||||
app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)
|
||||
# Check if SoftwareManager is already running
|
||||
check_running(app)
|
||||
# Parse saved files
|
||||
read_config()
|
||||
logs = get_download_logs()
|
||||
_, downloads = split_data(logs)
|
||||
# Initialize Keyboardinterrupt signal
|
||||
signal.signal(signal.SIGINT, keyboardinterrupthandler)
|
||||
consoleLog("Starting SoftwareManager...")
|
||||
consoleLog("Fetching Network Interfaces...")
|
||||
# Get network interface info
|
||||
list_interfaces()
|
||||
consoleLog("Initializing Interface variables...")
|
||||
init_interfaces()
|
||||
consoleLog(f"Current Bound: {state.bound_interface}")
|
||||
run_thread(threading.Thread(target=send_notification, args=(shutdown_event,), daemon=True))
|
||||
consoleLog("Started Thread: send_notification")
|
||||
run_thread(threading.Thread(target=update_log, args=(shutdown_event,), daemon=True))
|
||||
consoleLog("Started Thread: update_log")
|
||||
# Start background daemon threads
|
||||
app._daemon_thread = QThread()
|
||||
app._daemons = AppDaemons()
|
||||
app._daemons.moveToThread(app._daemon_thread)
|
||||
app._daemon_thread.started.connect(app._daemons.start_all)
|
||||
app.aboutToQuit.connect(app._daemon_thread.quit)
|
||||
app._daemon_thread.start()
|
||||
# Start background non-daemon threads
|
||||
run_thread(threading.Thread(target=check_completed, args=(downloads, state.autoresume)))
|
||||
consoleLog("Started Thread: check_completed")
|
||||
run_thread(threading.Thread(target=check_deleted_files, args=(shutdown_event,), daemon=True))
|
||||
consoleLog("Started Thread: check_deleted_files")
|
||||
run_thread(threading.Thread(target=check_downloads, args=(downloads,)))
|
||||
consoleLog("Started Thread: check_downloads")
|
||||
run_thread(threading.Thread(target=check_space, args=()))
|
||||
# Finish counting startup time
|
||||
elapsed = time.perf_counter() - start_time
|
||||
consoleLog(f"Initialization completed in {elapsed:.2f}s. Launching GUI")
|
||||
run_gui()
|
||||
# Launch GUI
|
||||
run_gui(app)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
from utils.logging.logs import consoleLog, add_download_log
|
||||
from utils.data.state import state
|
||||
from typing import Optional
|
||||
|
||||
|
||||
from network.direct_download.handle import DirectDownloadHandle
|
||||
from network.direct_download.utils import (
|
||||
sanitize_filename,
|
||||
extract_filename_from_url,
|
||||
detect_filename_from_headers,
|
||||
)
|
||||
|
||||
def add_direct_download(url: str, title: str, dl_path: Optional[str] = None, headers: Optional[dict] = None, single_threaded: bool = False):
|
||||
|
||||
if dl_path is None:
|
||||
dl_path = state.download_path
|
||||
|
||||
with state.downloads_lock:
|
||||
if url in state.active_downloads:
|
||||
consoleLog(f"Download already active: {title}")
|
||||
return
|
||||
|
||||
raw_filename = (
|
||||
detect_filename_from_headers(url, DirectDownloadHandle.USER_AGENT)
|
||||
or extract_filename_from_url(url)
|
||||
or sanitize_filename(title) + ".zip"
|
||||
)
|
||||
|
||||
filename = sanitize_filename(raw_filename)
|
||||
|
||||
handle = DirectDownloadHandle(url, filename, dl_path, headers, single_threaded)
|
||||
with state.downloads_lock:
|
||||
state.active_downloads[url] = handle
|
||||
add_download_log(title, url, "", False)
|
||||
handle.start()
|
||||
consoleLog(f"Started direct download: {filename}")
|
||||
@@ -0,0 +1,464 @@
|
||||
from network.direct_download.status import DirectDownloadStatus, ChunkSpec
|
||||
from utils.logging.logs import consoleLog, update_download_completed
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from network.direct_download.utils import format_size
|
||||
from utils.data.state import state
|
||||
from typing import Optional
|
||||
import libtorrent as lt
|
||||
import threading
|
||||
import requests
|
||||
import hashlib
|
||||
import json
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
class SimpleThrottler:
|
||||
def __init__(self):
|
||||
self._lock = threading.Lock()
|
||||
self._last_time = time.monotonic()
|
||||
self._allowance = 0.0
|
||||
|
||||
def throttle(self, bytes_count: int, limit_kbps: int):
|
||||
if limit_kbps <= 0:
|
||||
return
|
||||
|
||||
limit_bps = limit_kbps * 1024
|
||||
wait_time = 0
|
||||
with self._lock:
|
||||
now = time.monotonic()
|
||||
elapsed = now - self._last_time
|
||||
self._last_time = now
|
||||
|
||||
self._allowance += elapsed * limit_bps
|
||||
if self._allowance > 2 * limit_bps:
|
||||
self._allowance = 2 * limit_bps
|
||||
|
||||
self._allowance -= bytes_count
|
||||
|
||||
if self._allowance < 0:
|
||||
wait_time = -self._allowance / limit_bps
|
||||
self._allowance = 0
|
||||
|
||||
if wait_time > 0:
|
||||
time.sleep(min(wait_time, 1.0))
|
||||
|
||||
_throttler = SimpleThrottler()
|
||||
|
||||
class DirectDownloadHandle:
|
||||
STREAM_BLOCK_SIZE = 1 << 17 # 128 KiB per read
|
||||
MAX_RETRIES = 5
|
||||
RETRY_BACKOFF_BASE = 2.0
|
||||
NUM_THREADS = 16
|
||||
MIN_CHUNK_SIZE = 1 << 20 # 1 MiB minimum per chunk
|
||||
REQUEST_TIMEOUT = (15, 60) # (connect, read) timeouts
|
||||
USER_AGENT = (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) "
|
||||
"Chrome/125.0.0.0 Safari/537.36"
|
||||
)
|
||||
|
||||
def __init__(self, url: str, name: str, save_path: str, headers: Optional[dict] = None, single_threaded: bool = False):
|
||||
self.url = url
|
||||
self._name = name
|
||||
self._save_path = save_path
|
||||
self._file_path = os.path.join(save_path, name)
|
||||
self._status = DirectDownloadStatus(name, save_path, 0)
|
||||
self._stop_event = threading.Event()
|
||||
self._pause_event = threading.Event() # SET = paused
|
||||
self._thread: Optional[threading.Thread] = None
|
||||
self._session: Optional[requests.Session] = None
|
||||
self._supports_range = False
|
||||
self._custom_headers = headers
|
||||
self._single_threaded = single_threaded
|
||||
|
||||
state_dir = os.path.join(state.settings_path, "direct_downloads")
|
||||
os.makedirs(state_dir, exist_ok=True)
|
||||
url_hash = hashlib.sha256(url.encode()).hexdigest()
|
||||
self._state_file = os.path.join(state_dir, f"{url_hash}.json")
|
||||
|
||||
# Load state to initialize progress
|
||||
state_data = self._load_state()
|
||||
if state_data:
|
||||
total_wanted = state_data.get("total_wanted", 0)
|
||||
chunks_progress = state_data.get("chunks", {})
|
||||
chunks_progress = {int(k): int(v) for k, v in chunks_progress.items()}
|
||||
self._status.initialize_progress(total_wanted, chunks_progress)
|
||||
|
||||
|
||||
def status(self) -> DirectDownloadStatus:
|
||||
return self._status
|
||||
|
||||
def pause(self):
|
||||
self._status.paused = True
|
||||
self._pause_event.set()
|
||||
|
||||
def resume(self):
|
||||
self._status.paused = False
|
||||
self._pause_event.clear()
|
||||
|
||||
def set_flags(self, flags):
|
||||
if flags & lt.torrent_flags.auto_managed:
|
||||
self._status.auto_managed = True
|
||||
|
||||
def unset_flags(self, flags):
|
||||
if flags & lt.torrent_flags.auto_managed:
|
||||
self._status.auto_managed = False
|
||||
|
||||
def save_path(self) -> str:
|
||||
return self._save_path
|
||||
|
||||
def stop(self):
|
||||
self._stop_event.set()
|
||||
if self._thread and self._thread.is_alive():
|
||||
self._thread.join(timeout=10)
|
||||
|
||||
|
||||
def _load_state(self) -> dict:
|
||||
if os.path.exists(self._state_file):
|
||||
try:
|
||||
with open(self._state_file, "r") as f:
|
||||
return json.load(f)
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to load state for {self._name}: {e}")
|
||||
return {}
|
||||
|
||||
def _save_state(self, chunks_done: dict[int, int]):
|
||||
try:
|
||||
with open(self._state_file, "w") as f:
|
||||
json.dump({
|
||||
"url": self.url,
|
||||
"name": self._name,
|
||||
"save_path": self._save_path,
|
||||
"total_wanted": self._status.total_wanted,
|
||||
"chunks": chunks_done
|
||||
}, f)
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while saving download state: {e}")
|
||||
|
||||
def _clear_state(self):
|
||||
if os.path.exists(self._state_file):
|
||||
try:
|
||||
os.remove(self._state_file)
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while removing download state file: {e}")
|
||||
|
||||
|
||||
def start(self):
|
||||
self._thread = threading.Thread(
|
||||
target=self._download_orchestrator, name=f"dl-{self._name}", daemon=True
|
||||
)
|
||||
self._thread.start()
|
||||
|
||||
def _build_session(self) -> requests.Session:
|
||||
session = requests.Session()
|
||||
session.headers.update({"User-Agent": self.USER_AGENT})
|
||||
if self._custom_headers is not None:
|
||||
session.headers.update(self._custom_headers)
|
||||
adapter = requests.adapters.HTTPAdapter(
|
||||
max_retries=0,
|
||||
pool_connections=self.NUM_THREADS,
|
||||
pool_maxsize=self.NUM_THREADS + 2,
|
||||
)
|
||||
session.mount("https://", adapter)
|
||||
session.mount("http://", adapter)
|
||||
return session
|
||||
|
||||
def _probe_url(self, session: requests.Session) -> tuple[int, bool]:
|
||||
resp = session.head(self.url, allow_redirects=True, timeout=self.REQUEST_TIMEOUT)
|
||||
resp.raise_for_status()
|
||||
|
||||
total_size = int(resp.headers.get("content-length", 0))
|
||||
supports_range = (total_size > 0)
|
||||
|
||||
# Double-check range support with a small range request
|
||||
if supports_range:
|
||||
try:
|
||||
test = session.get(
|
||||
self.url,
|
||||
headers={"Range": "bytes=0-0"},
|
||||
timeout=self.REQUEST_TIMEOUT,
|
||||
stream=True,
|
||||
)
|
||||
supports_range = test.status_code == 206
|
||||
test.close()
|
||||
except Exception:
|
||||
supports_range = False
|
||||
|
||||
return total_size, supports_range
|
||||
|
||||
def _download_orchestrator(self):
|
||||
try:
|
||||
self._session = self._build_session()
|
||||
total_size, self._supports_range = self._probe_url(self._session)
|
||||
self._status.total_wanted = total_size
|
||||
|
||||
os.makedirs(self._save_path, exist_ok=True)
|
||||
|
||||
use_multithreaded = (
|
||||
self._supports_range
|
||||
and total_size > self.MIN_CHUNK_SIZE * 2
|
||||
and not self._single_threaded
|
||||
)
|
||||
|
||||
if use_multithreaded:
|
||||
consoleLog(
|
||||
f"Multi-threaded download ({self.NUM_THREADS} threads): {self._name} "
|
||||
f"({format_size(total_size)})"
|
||||
)
|
||||
self._preallocate_file(total_size)
|
||||
self._multithreaded_download(total_size)
|
||||
else:
|
||||
reason = "no range support" if not self._supports_range else "file too small or single-threaded mode"
|
||||
consoleLog(f"Single-threaded download ({reason}): {self._name}")
|
||||
self._single_threaded_download()
|
||||
|
||||
if not self._stop_event.is_set() and self._status.error is None:
|
||||
self._verify_download(total_size)
|
||||
self._status.mark_completed()
|
||||
update_download_completed(self.url, True)
|
||||
self._clear_state()
|
||||
consoleLog(f"Finished downloading {self._name}")
|
||||
|
||||
except Exception as e:
|
||||
self._status.mark_error(str(e))
|
||||
consoleLog(f"Download failed for {self._name}: {e}")
|
||||
finally:
|
||||
if self._session:
|
||||
self._session.close()
|
||||
|
||||
|
||||
def _preallocate_file(self, total_size: int):
|
||||
if os.path.exists(self._file_path) and os.path.getsize(self._file_path) == total_size:
|
||||
return
|
||||
|
||||
with open(self._file_path, "wb") as f:
|
||||
if sys.platform == "win32":
|
||||
import msvcrt
|
||||
import ctypes
|
||||
from ctypes.wintypes import DWORD
|
||||
|
||||
handle = msvcrt.get_osfhandle(f.fileno())
|
||||
kernel32 = ctypes.windll.kernel32
|
||||
|
||||
bytes_returned = DWORD()
|
||||
kernel32.DeviceIoControl(
|
||||
handle, 590020, None, 0, None, 0, ctypes.byref(bytes_returned), None
|
||||
)
|
||||
kernel32.SetFilePointerEx(handle, ctypes.c_int64(total_size), None, 0)
|
||||
kernel32.SetEndOfFile(handle)
|
||||
else:
|
||||
f.truncate(total_size)
|
||||
|
||||
def _compute_chunks(self, total_size: int) -> list[ChunkSpec]:
|
||||
num_chunks = min(self.NUM_THREADS, max(1, total_size // self.MIN_CHUNK_SIZE))
|
||||
chunk_size = total_size // num_chunks
|
||||
chunks = []
|
||||
for i in range(num_chunks):
|
||||
start = i * chunk_size
|
||||
end = (i + 1) * chunk_size - 1 if i < num_chunks - 1 else total_size - 1
|
||||
chunks.append(ChunkSpec(chunk_id=i, start=start, end=end))
|
||||
return chunks
|
||||
|
||||
def _multithreaded_download(self, total_size: int):
|
||||
chunks = self._compute_chunks(total_size)
|
||||
state_data = self._load_state()
|
||||
chunks_progress = state_data.get("chunks", {})
|
||||
|
||||
chunks_progress = {int(k): int(v) for k, v in chunks_progress.items()}
|
||||
|
||||
# Initialize progress in status
|
||||
for chunk_id, bytes_done in chunks_progress.items():
|
||||
self._status.update_chunk_progress(chunk_id, bytes_done)
|
||||
|
||||
with ThreadPoolExecutor(
|
||||
max_workers=len(chunks), thread_name_prefix="dl-chunk"
|
||||
) as executor:
|
||||
futures = {
|
||||
executor.submit(self._download_chunk_with_retry, chunk, chunks_progress.get(chunk.chunk_id, 0)): chunk
|
||||
for chunk in chunks
|
||||
}
|
||||
|
||||
for future in as_completed(futures):
|
||||
chunk = futures[future]
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
consoleLog(
|
||||
f"Chunk {chunk.chunk_id} ({chunk.start}-{chunk.end}) "
|
||||
f"failed permanently: {e}"
|
||||
)
|
||||
self._status.mark_error(
|
||||
f"Chunk {chunk.chunk_id} failed: {e}"
|
||||
)
|
||||
self._stop_event.set()
|
||||
|
||||
def _download_chunk_with_retry(self, chunk: ChunkSpec, initial_bytes: int):
|
||||
bytes_written = initial_bytes
|
||||
|
||||
for attempt in range(1, self.MAX_RETRIES + 1):
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
|
||||
current_start = chunk.start + bytes_written
|
||||
if current_start > chunk.end:
|
||||
return
|
||||
|
||||
try:
|
||||
# _download_range returns new bytes written
|
||||
bytes_written += self._download_range(
|
||||
chunk.chunk_id, current_start, chunk.end, bytes_written
|
||||
)
|
||||
return
|
||||
except Exception as e:
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
if attempt < self.MAX_RETRIES:
|
||||
wait = self.RETRY_BACKOFF_BASE ** attempt
|
||||
consoleLog(
|
||||
f"Chunk {chunk.chunk_id} attempt {attempt} failed: {e}. "
|
||||
f"Retrying in {wait:.0f}s (resuming from byte {current_start})..."
|
||||
)
|
||||
if self._stop_event.wait(timeout=wait):
|
||||
return
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f"Chunk {chunk.chunk_id} failed after {self.MAX_RETRIES} attempts: {e}"
|
||||
) from e
|
||||
|
||||
def _download_range(
|
||||
self, chunk_id: int, start: int, end: int, prior_bytes: int
|
||||
) -> int:
|
||||
|
||||
headers = {"Range": f"bytes={start}-{end}"}
|
||||
new_bytes = 0
|
||||
|
||||
with self._session.get(
|
||||
self.url, headers=headers, stream=True, timeout=self.REQUEST_TIMEOUT
|
||||
) as resp:
|
||||
resp.raise_for_status()
|
||||
if resp.status_code not in (200, 206):
|
||||
raise RuntimeError(f"Unexpected status {resp.status_code}")
|
||||
|
||||
with open(self._file_path, "r+b") as f:
|
||||
f.seek(start)
|
||||
for block in resp.iter_content(chunk_size=self.STREAM_BLOCK_SIZE):
|
||||
if self._stop_event.is_set():
|
||||
return new_bytes
|
||||
|
||||
self._wait_if_paused()
|
||||
if self._stop_event.is_set():
|
||||
return new_bytes
|
||||
|
||||
_throttler.throttle(len(block), state.down_speed_limit)
|
||||
|
||||
f.write(block)
|
||||
new_bytes += len(block)
|
||||
self._status.update_chunk_progress(
|
||||
chunk_id, prior_bytes + new_bytes
|
||||
)
|
||||
|
||||
|
||||
if new_bytes % (1024 * 1024) < len(block):
|
||||
|
||||
with self._status._lock:
|
||||
self._save_state(self._status._chunk_bytes)
|
||||
|
||||
with self._status._lock:
|
||||
self._save_state(self._status._chunk_bytes)
|
||||
|
||||
return new_bytes
|
||||
|
||||
|
||||
def _single_threaded_download(self):
|
||||
chunk_id = 0
|
||||
bytes_written = 0
|
||||
|
||||
if os.path.exists(self._file_path):
|
||||
bytes_written = os.path.getsize(self._file_path)
|
||||
if bytes_written > 0:
|
||||
self._status.update_chunk_progress(chunk_id, bytes_written)
|
||||
|
||||
for attempt in range(1, self.MAX_RETRIES + 1):
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
|
||||
try:
|
||||
headers = {}
|
||||
mode = "wb"
|
||||
|
||||
if bytes_written > 0 and self._supports_range:
|
||||
headers["Range"] = f"bytes={bytes_written}-"
|
||||
mode = "r+b"
|
||||
elif bytes_written > 0:
|
||||
bytes_written = 0
|
||||
mode = "wb"
|
||||
|
||||
with self._session.get(
|
||||
self.url, headers=headers, stream=True, timeout=self.REQUEST_TIMEOUT
|
||||
) as resp:
|
||||
resp.raise_for_status()
|
||||
|
||||
if self._status.total_wanted == 0:
|
||||
content_length = int(resp.headers.get("content-length", 0))
|
||||
self._status.total_wanted = content_length + bytes_written
|
||||
|
||||
with open(self._file_path, mode) as f:
|
||||
if mode == "r+b":
|
||||
f.seek(bytes_written)
|
||||
|
||||
for block in resp.iter_content(
|
||||
chunk_size=self.STREAM_BLOCK_SIZE
|
||||
):
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
|
||||
self._wait_if_paused()
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
|
||||
_throttler.throttle(len(block), state.down_speed_limit)
|
||||
|
||||
f.write(block)
|
||||
bytes_written += len(block)
|
||||
self._status.update_chunk_progress(chunk_id, bytes_written)
|
||||
|
||||
# Periodic state save (single thread, chunk_id=0)
|
||||
if bytes_written % (1024 * 1024) < len(block):
|
||||
self._save_state({0: bytes_written})
|
||||
|
||||
self._save_state({0: bytes_written})
|
||||
return
|
||||
|
||||
except Exception as e:
|
||||
if self._stop_event.is_set():
|
||||
return
|
||||
if attempt < self.MAX_RETRIES:
|
||||
wait = self.RETRY_BACKOFF_BASE ** attempt
|
||||
consoleLog(
|
||||
f"Download attempt {attempt} failed: {e}. "
|
||||
f"Retrying in {wait:.0f}s..."
|
||||
)
|
||||
if self._stop_event.wait(timeout=wait):
|
||||
return
|
||||
else:
|
||||
raise RuntimeError(
|
||||
f"Download failed after {self.MAX_RETRIES} attempts: {e}"
|
||||
) from e
|
||||
|
||||
|
||||
def _wait_if_paused(self):
|
||||
while self._pause_event.is_set():
|
||||
if self._stop_event.wait(timeout=0.5):
|
||||
return
|
||||
|
||||
def _verify_download(self, expected_size: int):
|
||||
if expected_size <= 0:
|
||||
return
|
||||
actual_size = os.path.getsize(self._file_path)
|
||||
if actual_size != expected_size:
|
||||
raise RuntimeError(
|
||||
f"Size mismatch: expected {format_size(expected_size)}, "
|
||||
f"got {format_size(actual_size)}"
|
||||
)
|
||||
@@ -0,0 +1,96 @@
|
||||
from dataclasses import dataclass
|
||||
from collections import deque
|
||||
from typing import Optional
|
||||
import libtorrent as lt
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
@dataclass
|
||||
class ChunkSpec:
|
||||
chunk_id: int
|
||||
start: int
|
||||
end: int # inclusive
|
||||
|
||||
|
||||
class DirectDownloadStatus:
|
||||
|
||||
def __init__(self, name: str, save_path: str, total_size: int = 0):
|
||||
self.name = name
|
||||
self.save_path = save_path
|
||||
self.total_wanted = total_size
|
||||
self.paused = False
|
||||
self.auto_managed = True
|
||||
self.has_metadata = True
|
||||
self.state = lt.torrent_status.downloading
|
||||
self.error: Optional[str] = None
|
||||
|
||||
self._lock = threading.Lock()
|
||||
self._total_wanted_done = 0
|
||||
self._progress = 0.0
|
||||
self._download_rate = 0
|
||||
self._upload_rate = 0
|
||||
|
||||
self._chunk_bytes: dict[int, int] = {}
|
||||
self._speed_window: deque[tuple[float, int]] = deque()
|
||||
self._speed_window_size = 3.0
|
||||
|
||||
@property
|
||||
def total_wanted_done(self) -> int:
|
||||
with self._lock:
|
||||
return self._total_wanted_done
|
||||
|
||||
@property
|
||||
def progress(self) -> float:
|
||||
with self._lock:
|
||||
return self._progress
|
||||
|
||||
@property
|
||||
def download_rate(self) -> int:
|
||||
with self._lock:
|
||||
return self._download_rate
|
||||
|
||||
@property
|
||||
def upload_rate(self) -> int:
|
||||
return 0
|
||||
|
||||
def update_chunk_progress(self, chunk_id: int, bytes_downloaded: int):
|
||||
with self._lock:
|
||||
self._chunk_bytes[chunk_id] = bytes_downloaded
|
||||
self._total_wanted_done = sum(self._chunk_bytes.values())
|
||||
if self.total_wanted > 0:
|
||||
self._progress = min(self._total_wanted_done / self.total_wanted, 1.0)
|
||||
|
||||
|
||||
now = time.monotonic()
|
||||
self._speed_window.append((now, self._total_wanted_done))
|
||||
|
||||
cutoff = now - self._speed_window_size
|
||||
while self._speed_window and self._speed_window[0][0] < cutoff:
|
||||
self._speed_window.popleft()
|
||||
if len(self._speed_window) >= 2:
|
||||
oldest_time, oldest_bytes = self._speed_window[0]
|
||||
dt = now - oldest_time
|
||||
if dt > 0:
|
||||
self._download_rate = int(
|
||||
(self._total_wanted_done - oldest_bytes) / dt
|
||||
)
|
||||
|
||||
def initialize_progress(self, total_wanted: int, chunk_bytes: dict[int, int]):
|
||||
with self._lock:
|
||||
self.total_wanted = total_wanted
|
||||
self._chunk_bytes = chunk_bytes.copy()
|
||||
self._total_wanted_done = sum(self._chunk_bytes.values())
|
||||
if self.total_wanted > 0:
|
||||
self._progress = min(self._total_wanted_done / self.total_wanted, 1.0)
|
||||
|
||||
def mark_completed(self):
|
||||
with self._lock:
|
||||
self.state = lt.torrent_status.seeding
|
||||
self._progress = 1.0
|
||||
self._download_rate = 0
|
||||
|
||||
def mark_error(self, error: str):
|
||||
with self._lock:
|
||||
self.error = error
|
||||
self._download_rate = 0
|
||||
@@ -0,0 +1,49 @@
|
||||
from urllib.parse import urlparse, unquote
|
||||
from utils.logging.logs import consoleLog
|
||||
from typing import Optional
|
||||
import requests
|
||||
import os
|
||||
|
||||
def sanitize_filename(name: str) -> str:
|
||||
# Remove or replace dangerous characters
|
||||
keepchars = (" ", ".", "_", "-")
|
||||
cleaned = "".join(c for c in name if c.isalnum() or c in keepchars).strip()
|
||||
while " " in cleaned:
|
||||
cleaned = cleaned.replace(" ", " ")
|
||||
return cleaned or "download"
|
||||
|
||||
|
||||
def extract_filename_from_url(url: str) -> Optional[str]:
|
||||
parsed = urlparse(url)
|
||||
path = unquote(parsed.path)
|
||||
basename = os.path.basename(path)
|
||||
if basename and "." in basename and len(basename) < 256:
|
||||
return basename
|
||||
return None
|
||||
|
||||
|
||||
def detect_filename_from_headers(url: str, user_agent: str) -> Optional[str]:
|
||||
try:
|
||||
resp = requests.head(
|
||||
url,
|
||||
headers={"User-Agent": user_agent},
|
||||
allow_redirects=True,
|
||||
timeout=15,
|
||||
)
|
||||
cd = resp.headers.get("content-disposition", "")
|
||||
if "filename=" in cd:
|
||||
parts = cd.split("filename=")
|
||||
if len(parts) > 1:
|
||||
fname = parts[1].split(";")[0].strip().strip('"').strip("'")
|
||||
if fname:
|
||||
return fname
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while retrieving filename from headers: {e}")
|
||||
return None
|
||||
|
||||
def format_size(size_bytes: int) -> str:
|
||||
for unit in ("B", "KiB", "MiB", "GiB", "TiB"):
|
||||
if abs(size_bytes) < 1024:
|
||||
return f"{size_bytes:.1f} {unit}"
|
||||
size_bytes /= 1024
|
||||
return f"{size_bytes:.1f} PiB"
|
||||
@@ -1,20 +1,22 @@
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.utils.data.state import state
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import psutil
|
||||
|
||||
addrs = psutil.net_if_addrs()
|
||||
stats = psutil.net_if_stats()
|
||||
|
||||
def get_net_interfaces():
|
||||
addrs = psutil.net_if_addrs()
|
||||
for interface in addrs.keys():
|
||||
consoleLog(f"Found Interface: {interface}")
|
||||
return addrs.keys()
|
||||
|
||||
|
||||
def get_active_interfaces():
|
||||
addrs = psutil.net_if_addrs()
|
||||
stats = psutil.net_if_stats()
|
||||
active = []
|
||||
|
||||
for interface, addr_list in addrs.items():
|
||||
if interface not in stats:
|
||||
continue
|
||||
up = stats[interface].isup
|
||||
for addr in addr_list:
|
||||
if addr.family == 2: # ipv4
|
||||
@@ -27,26 +29,33 @@ def get_active_interfaces():
|
||||
|
||||
|
||||
def list_interfaces() -> None:
|
||||
consoleLog("Fetching Network Interfaces...")
|
||||
addrs = psutil.net_if_addrs()
|
||||
stats = psutil.net_if_stats()
|
||||
|
||||
for interface, addr_list in addrs.items():
|
||||
if interface not in stats:
|
||||
continue
|
||||
up = stats[interface].isup
|
||||
status = "INACTIVE"
|
||||
for addr in addr_list:
|
||||
if addr.family == 2: # ipv4
|
||||
ipv4 = addr.address
|
||||
if not ipv4.startswith("127.") and not ipv4.startswith("169.254") and up:
|
||||
status = "ACTIVE"
|
||||
else:
|
||||
status = "INACTIVE"
|
||||
consoleLog(f"Found Interface: {interface} [{status}]")
|
||||
|
||||
def init_interfaces():
|
||||
consoleLog("Initializing Interface variables...")
|
||||
addrs = psutil.net_if_addrs()
|
||||
state.interfaces = list(addrs.keys())
|
||||
state.active_interfaces = get_active_interfaces()
|
||||
|
||||
def get_interface_ip(interface_name):
|
||||
addrs = psutil.net_if_addrs()
|
||||
if interface_name in addrs:
|
||||
for addr in addrs[interface_name]:
|
||||
if addr.family == 2: # ipv4
|
||||
if not addr.address.startswith("127.") and not addr.address.startswith("169.254"):
|
||||
return addr.address
|
||||
return None
|
||||
return None
|
||||
@@ -0,0 +1,229 @@
|
||||
from network.interface import get_interface_ip
|
||||
from utils.general.wrappers import run_thread
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import libtorrent as lt
|
||||
import threading
|
||||
import platform
|
||||
import ctypes
|
||||
import time
|
||||
import os
|
||||
|
||||
|
||||
_loop_lock = threading.Lock()
|
||||
|
||||
def get_free_space_mb(dirname):
|
||||
if platform.system() == 'Windows':
|
||||
free_bytes = ctypes.c_ulonglong(0)
|
||||
ctypes.windll.kernel32.GetDiskFreeSpaceExW(ctypes.c_wchar_p(dirname), None, None, ctypes.pointer(free_bytes))
|
||||
return free_bytes.value
|
||||
else:
|
||||
st = os.statvfs(dirname)
|
||||
return st.f_bavail * st.f_frsize
|
||||
|
||||
def check_space():
|
||||
while not state.shutdown_event.is_set():
|
||||
with state.downloads_lock:
|
||||
items = list(state.active_downloads.items())
|
||||
for _, magnetdl in items:
|
||||
try:
|
||||
status = magnetdl.status()
|
||||
except RuntimeError:
|
||||
continue
|
||||
|
||||
if status.state == lt.torrent_status.downloading:
|
||||
free_space = get_free_space_mb(state.download_path)
|
||||
total_size = status.total_wanted
|
||||
|
||||
if free_space < total_size:
|
||||
consoleLog(f"Not enough free space to continue downloading: {status.name}")
|
||||
magnetdl.pause()
|
||||
break
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
def init_session():
|
||||
if state.dl_session is not None:
|
||||
return
|
||||
|
||||
state.dl_session = lt.session()
|
||||
|
||||
|
||||
settings = {
|
||||
"upload_rate_limit": state.up_speed_limit * 1024,
|
||||
"download_rate_limit": state.down_speed_limit * 1024,
|
||||
"enable_dht": True,
|
||||
"enable_lsd": True,
|
||||
"enable_upnp": True,
|
||||
"enable_natpmp": True,
|
||||
"dht_bootstrap_nodes": "router.bittorrent.com:6881,dht.transmissionbt.com:6881",
|
||||
"connections_limit": state.max_connections,
|
||||
"active_downloads": state.max_downloads
|
||||
}
|
||||
|
||||
if state.bound_interface:
|
||||
interface_ip = get_interface_ip(state.bound_interface)
|
||||
if interface_ip:
|
||||
settings["outgoing_interfaces"] = interface_ip
|
||||
settings["listen_interfaces"] = f"{interface_ip}:6881"
|
||||
consoleLog(f"Binding to Interface IP: {interface_ip}")
|
||||
else:
|
||||
consoleLog(f"Skipping Binding, no Interface set. ({state.bound_interface})")
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
|
||||
consoleLog("Initialized Session")
|
||||
|
||||
|
||||
def add_download(magnet_uri):
|
||||
|
||||
if state.active_downloads is None:
|
||||
state.active_downloads = {}
|
||||
|
||||
init_session()
|
||||
free_space = get_free_space_mb(state.download_path)
|
||||
|
||||
with state.downloads_lock:
|
||||
already_active = magnet_uri in state.active_downloads
|
||||
handle = state.active_downloads.get(magnet_uri) if already_active else None
|
||||
if already_active:
|
||||
try:
|
||||
status = handle.status()
|
||||
|
||||
if status.has_metadata:
|
||||
filepath = os.path.join(status.save_path, status.name)
|
||||
|
||||
if not os.path.exists(filepath):
|
||||
|
||||
consoleLog(f"File Deleted, redownloading: {status.name}")
|
||||
state.dl_session.remove_torrent(handle)
|
||||
with state.downloads_lock:
|
||||
del state.active_downloads[magnet_uri]
|
||||
else:
|
||||
consoleLog("Skipping Downloading, download already running...")
|
||||
return False
|
||||
else:
|
||||
consoleLog("Skipping Downloading, download already running... ")
|
||||
return False
|
||||
except RuntimeError as e:
|
||||
consoleLog(f"Error in LibTorrent Handle: {e}")
|
||||
with state.downloads_lock:
|
||||
del state.active_downloads[magnet_uri]
|
||||
|
||||
try:
|
||||
params = lt.parse_magnet_uri(magnet_uri)
|
||||
params.save_path = state.download_path
|
||||
|
||||
handle = state.dl_session.add_torrent(params)
|
||||
metadata_timeout = 60
|
||||
metadata_start = time.time()
|
||||
while not handle.has_metadata():
|
||||
if time.time() - metadata_start > metadata_timeout:
|
||||
state.dl_session.remove_torrent(handle)
|
||||
consoleLog("Timed out waiting for torrent metadata")
|
||||
return False
|
||||
time.sleep(1)
|
||||
|
||||
total_size = handle.get_torrent_info().total_size()
|
||||
|
||||
if free_space <= total_size:
|
||||
state.dl_session.remove_torrent(handle)
|
||||
consoleLog("Not enough free space to download this item.")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to add torrent or fetch info: {e}")
|
||||
return False
|
||||
if handle:
|
||||
with state.downloads_lock:
|
||||
state.active_downloads[magnet_uri] = handle
|
||||
consoleLog(f"Added {magnet_uri} to downloads")
|
||||
|
||||
run_thread(threading.Thread(target=dl_status_loop))
|
||||
return True
|
||||
|
||||
|
||||
def add_seed(magnet_uri, file_path):
|
||||
if state.active_downloads is None:
|
||||
state.active_downloads = {}
|
||||
|
||||
init_session()
|
||||
|
||||
with state.downloads_lock:
|
||||
if magnet_uri in state.active_downloads:
|
||||
consoleLog("Already seeding this torrent")
|
||||
return False
|
||||
|
||||
try:
|
||||
magnetdl = lt.parse_magnet_uri(magnet_uri)
|
||||
magnetdl.save_path = os.path.dirname(file_path)
|
||||
handle = state.dl_session.add_torrent(magnetdl)
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to add seed: {e}")
|
||||
return False
|
||||
with state.downloads_lock:
|
||||
state.active_downloads[magnet_uri] = handle
|
||||
state.seeded_magnets.add(magnet_uri)
|
||||
return True
|
||||
|
||||
|
||||
def dl_status_loop():
|
||||
if not _loop_lock.acquire(blocking=False):
|
||||
return
|
||||
|
||||
try:
|
||||
completed_set = set()
|
||||
|
||||
if not state.active_downloads:
|
||||
consoleLog("No active downloads")
|
||||
return
|
||||
|
||||
while state.active_downloads and not state.shutdown_event.is_set():
|
||||
with state.downloads_lock:
|
||||
items = list(state.active_downloads.items())
|
||||
for magnet_uri, magnetdl in items:
|
||||
try:
|
||||
status = magnetdl.status()
|
||||
except RuntimeError:
|
||||
continue
|
||||
|
||||
if status.state == lt.torrent_status.seeding and magnet_uri not in completed_set:
|
||||
consoleLog(f"Download completed: {status.name}")
|
||||
|
||||
completed_set.add(magnet_uri)
|
||||
|
||||
if not state.active_downloads:
|
||||
break
|
||||
|
||||
time.sleep(1)
|
||||
finally:
|
||||
_loop_lock.release()
|
||||
|
||||
def update_settings():
|
||||
|
||||
if state.dl_session is None:
|
||||
return
|
||||
|
||||
settings = {
|
||||
"upload_rate_limit": state.up_speed_limit * 1024,
|
||||
"download_rate_limit": state.down_speed_limit * 1024,
|
||||
"connections_limit": state.max_connections,
|
||||
"active_downloads": state.max_downloads
|
||||
}
|
||||
|
||||
if state.bound_interface:
|
||||
interface_ip = get_interface_ip(state.bound_interface)
|
||||
if interface_ip:
|
||||
settings["outgoing_interfaces"] = interface_ip
|
||||
settings["listen_interfaces"] = f"{interface_ip}:6881"
|
||||
consoleLog(f"Binding to Interface IP: {interface_ip}")
|
||||
else:
|
||||
consoleLog(f"Skipping Binding, no Interface set. ({state.bound_interface})")
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
|
||||
def update_bound_interface():
|
||||
|
||||
settings = { "outgoing_interfaces": state.bound_interface }
|
||||
|
||||
state.dl_session.apply_settings(settings)
|
||||
@@ -0,0 +1,95 @@
|
||||
from utils.logging.logs import update_download_completed_by_hash
|
||||
from utils.logging.logs import consoleLog
|
||||
from PySide6.QtCore import QObject, QTimer
|
||||
from utils.data.state import state
|
||||
from plyer import notification
|
||||
import libtorrent as lt
|
||||
import os
|
||||
|
||||
|
||||
def cleanup_session():
|
||||
if state.dl_session is not None:
|
||||
with state.downloads_lock:
|
||||
for magnetdl in state.active_downloads.values():
|
||||
if hasattr(magnetdl, 'pause'): # check it's a handle
|
||||
magnetdl.pause()
|
||||
|
||||
del state.dl_session
|
||||
state.dl_session = None
|
||||
with state.downloads_lock:
|
||||
state.active_downloads.clear()
|
||||
|
||||
class AppDaemons(QObject):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
self.notified_magnets = set()
|
||||
self.updated_magnets = set()
|
||||
|
||||
# Create Timers
|
||||
self.deleted_files_timer = QTimer(self)
|
||||
self.completed_downloads_timer = QTimer(self)
|
||||
|
||||
# Connect Timer Signals
|
||||
self.deleted_files_timer.timeout.connect(self.check_deleted_files)
|
||||
self.completed_downloads_timer.timeout.connect(self.check_completed_downloads)
|
||||
|
||||
def start_all(self):
|
||||
consoleLog("Starting Timer: deleted_files")
|
||||
self.deleted_files_timer.start(2000)
|
||||
consoleLog("Starting Timer: completed_downloads")
|
||||
self.completed_downloads_timer.start(5000)
|
||||
|
||||
def check_deleted_files(self):
|
||||
try:
|
||||
with state.downloads_lock:
|
||||
items = list(state.active_downloads.items())
|
||||
for magnet_uri, magnetdl in items:
|
||||
if isinstance(magnetdl, dict):
|
||||
continue
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding and status.has_metadata:
|
||||
file_path = os.path.join(status.save_path, status.name)
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
consoleLog(f"Registered File Deletion: {status.name}")
|
||||
state.dl_session.remove_torrent(magnetdl)
|
||||
with state.downloads_lock:
|
||||
del state.active_downloads[magnet_uri]
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while checking for file deletions: {e}")
|
||||
|
||||
def check_completed_downloads(self):
|
||||
try:
|
||||
with state.downloads_lock:
|
||||
items = list(state.active_downloads.items())
|
||||
seeded = set(state.seeded_magnets)
|
||||
for magnet_uri, magnetdl in items:
|
||||
if isinstance(magnetdl, dict):
|
||||
continue
|
||||
|
||||
status = magnetdl.status()
|
||||
|
||||
if status.state == lt.torrent_status.seeding:
|
||||
|
||||
if magnet_uri not in self.updated_magnets and magnet_uri not in seeded:
|
||||
consoleLog(f"Marking {status.name} as completed")
|
||||
if hasattr(status, 'info_hashes'):
|
||||
info_hash = str(status.info_hashes.v1)
|
||||
else:
|
||||
info_hash = str(status.info_hash)
|
||||
update_download_completed_by_hash(info_hash, True)
|
||||
self.updated_magnets.add(magnet_uri)
|
||||
|
||||
if magnet_uri not in self.notified_magnets:
|
||||
notification.notify(
|
||||
title="Download finished",
|
||||
message=f"{status.name} has finished downloading.",
|
||||
timeout=4
|
||||
)
|
||||
self.notified_magnets.add(magnet_uri)
|
||||
|
||||
except Exception as e:
|
||||
consoleLog(f"Exception while checking downloads: {e}")
|
||||
@@ -1,5 +1,6 @@
|
||||
from core.utils.logging.logs import consoleLog
|
||||
from core.network.libtorrent_int import add_download
|
||||
from network.libtorrent_int import add_download
|
||||
from utils.logging.logs import consoleLog
|
||||
|
||||
|
||||
def add_magnet(uri):
|
||||
if uri is not None and uri.startswith("magnet:?"):
|
||||
@@ -0,0 +1,154 @@
|
||||
from interface.dialogs.notificationpopup import NotificationPopup
|
||||
from utils.logging.logs import consoleLog
|
||||
from utils.data.state import state
|
||||
import configparser
|
||||
import platform
|
||||
import time
|
||||
import os
|
||||
|
||||
|
||||
def create_config():
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
config["General"] = {
|
||||
"debug": str(state.debug),
|
||||
"ignore_updates": str(state.ignore_updates),
|
||||
"autoresume": str(state.autoresume),
|
||||
"window_transparency": str(state.window_transparency),
|
||||
"accent_color": str(state.accent_color),
|
||||
"close_to_tray": str(state.close_to_tray),
|
||||
"show_megadb_notification": str(state.show_megadb_notification)
|
||||
}
|
||||
|
||||
config["Network"] = {
|
||||
"api_url": str(state.api_url),
|
||||
"bound_interface": str(state.bound_interface) if state.bound_interface is not None else "None",
|
||||
"download_speed_limit": str(state.down_speed_limit),
|
||||
"upload_speed_limit": str(state.up_speed_limit),
|
||||
"max_connections": str(state.max_connections),
|
||||
"max_downloads": str(state.max_downloads)
|
||||
}
|
||||
|
||||
config["Paths"] = {
|
||||
"download_path": str(state.download_path),
|
||||
"image_path": str(state.image_path)
|
||||
}
|
||||
|
||||
config["Image"] = {
|
||||
"enable_image": str(state.image_enabled),
|
||||
"image_width": str(state.image_width),
|
||||
"image_offset": str(state.image_offset),
|
||||
"image_opacity": str(state.image_opacity),
|
||||
"image_as_wallpaper": str(state.image_as_wallpaper),
|
||||
"image_position": str(state.image_position)
|
||||
}
|
||||
|
||||
if platform.system() == "Windows":
|
||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||
else:
|
||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||
|
||||
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||
os.makedirs(state.settings_path, exist_ok=True)
|
||||
|
||||
with open(os.path.join(state.settings_path, "config.ini"), 'w') as cf:
|
||||
config.write(cf)
|
||||
|
||||
|
||||
def read_config():
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
if platform.system() == "Windows":
|
||||
config_dir = os.environ.get("APPDATA", os.path.expanduser("~\\AppData\\Roaming"))
|
||||
else:
|
||||
config_dir = os.environ.get("XDG_CONFIG_HOME", os.path.expanduser("~/.config"))
|
||||
|
||||
state.settings_path = os.path.join(config_dir, "SoftwareManager")
|
||||
|
||||
# Temporary migration logic, keep for a while
|
||||
old_config_file = os.path.join(state.settings_path, "config.yml")
|
||||
new_config_file = os.path.join(state.settings_path, "config.ini")
|
||||
|
||||
if os.path.exists(old_config_file):
|
||||
try:
|
||||
os.replace(old_config_file, new_config_file)
|
||||
consoleLog("Successfully migrated config.yml to config.ini")
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to migrate config file: {e}")
|
||||
|
||||
if not os.path.exists(new_config_file):
|
||||
create_config()
|
||||
return
|
||||
try:
|
||||
config.read(new_config_file)
|
||||
|
||||
# General
|
||||
state.debug = config.getboolean("General", "debug", fallback=state.debug)
|
||||
state.ignore_updates = config.getboolean("General", "ignore_updates", fallback=state.ignore_updates)
|
||||
state.autoresume = config.getboolean("General", "autoresume", fallback=state.autoresume)
|
||||
state.window_transparency = config.getboolean("General", "window_transparency", fallback=state.window_transparency)
|
||||
state.accent_color = config.get("General", "accent_color", fallback=state.accent_color)
|
||||
state.close_to_tray = config.getboolean("General", "close_to_tray", fallback=state.close_to_tray)
|
||||
state.show_megadb_notification = config.getboolean("General", "show_megadb_notification", fallback=state.show_megadb_notification)
|
||||
|
||||
# Network
|
||||
state.api_url = config.get("Network", "api_url", fallback=state.api_url)
|
||||
state.bound_interface = config.get("Network", "bound_interface", fallback=state.bound_interface)
|
||||
if state.bound_interface == "None":
|
||||
state.bound_interface = None
|
||||
state.down_speed_limit = config.getint("Network", "download_speed_limit", fallback=state.down_speed_limit)
|
||||
state.up_speed_limit = config.getint("Network", "upload_speed_limit", fallback=state.up_speed_limit)
|
||||
state.max_connections = config.getint("Network", "max_connections", fallback=state.max_connections)
|
||||
state.max_downloads = config.getint("Network", "max_downloads", fallback=state.max_downloads)
|
||||
|
||||
# Paths
|
||||
state.download_path = config.get("Paths", "download_path", fallback=state.download_path)
|
||||
state.image_path = config.get("Paths", "image_path", fallback=state.image_path)
|
||||
|
||||
# Image
|
||||
state.image_enabled = config.getboolean("Image", "enable_image", fallback=state.image_enabled)
|
||||
state.image_width = config.getint("Image", "image_width", fallback=state.image_width)
|
||||
state.image_offset = config.getint("Image", "image_offset", fallback=state.image_offset)
|
||||
state.image_opacity = config.getint("Image", "image_opacity", fallback=state.image_opacity)
|
||||
state.image_as_wallpaper = config.getboolean("Image", "image_as_wallpaper", fallback=state.image_as_wallpaper)
|
||||
state.image_position = config.get("Image", "image_position", fallback=state.image_position)
|
||||
|
||||
create_config()
|
||||
|
||||
except configparser.Error as e:
|
||||
consoleLog(f"Error: Configuration file corrupted ({e}). Resetting to defaults.")
|
||||
backup_config(new_config_file) # Back up corrupted config
|
||||
create_config() # Create new config file
|
||||
NotificationPopup(
|
||||
title="Config Reset",
|
||||
text="Your configuration file has been reset due to a structural error.",
|
||||
infotext="A backup of your old configuration file is available in the settings folder."
|
||||
).exec()
|
||||
|
||||
except ValueError as e:
|
||||
consoleLog(f"Error: Invalid data types in configuration file ({e}). Resetting to defaults.")
|
||||
backup_config(new_config_file) # Back up corrupted config
|
||||
create_config() # Create new config file
|
||||
NotificationPopup(
|
||||
title="Config Reset",
|
||||
text="Your configuration file has been reset due to invalid data types.",
|
||||
infotext="A backup of your old configuration file is available in the settings folder."
|
||||
).exec()
|
||||
|
||||
except Exception as e:
|
||||
consoleLog(f"Unexpected error occurred while loading settings: {e}")
|
||||
NotificationPopup(
|
||||
title="Unexpected Error",
|
||||
text="An unknown error occurred while loading your settings.",
|
||||
infotext=f"System returned: {e}\n\nThe application may not function as expected."
|
||||
).exec()
|
||||
|
||||
def backup_config(config_path):
|
||||
if os.path.exists(config_path):
|
||||
timestamp = time.strftime("%Y%m%d-%H%M%S")
|
||||
backup_path = f"{config_path}.{timestamp}.bak"
|
||||
try:
|
||||
os.replace(config_path, backup_path)
|
||||
consoleLog(f"Successfully created backup of corrupted config: {backup_path}")
|
||||
except Exception as e:
|
||||
consoleLog(f"Failed to create backup of corrupted config: {e}")
|
||||