diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..87438cb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,103 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + workflow_dispatch: + +jobs: + build-windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Build executable + run: | + pyinstaller --onefile --name nvr-export --console src/tplink_nvr_export/cli.py + + - name: Test executable + run: | + ./dist/nvr-export.exe --version + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: nvr-export-windows + path: dist/nvr-export.exe + + build-linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pyinstaller + pip install -e . + + - name: Build executable + run: | + pyinstaller --onefile --name nvr-export --console src/tplink_nvr_export/cli.py + + - name: Make executable + run: chmod +x dist/nvr-export + + - name: Test executable + run: | + ./dist/nvr-export --version + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: nvr-export-linux + path: dist/nvr-export + + release: + needs: [build-windows, build-linux] + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + steps: + - name: Download Windows artifact + uses: actions/download-artifact@v4 + with: + name: nvr-export-windows + path: windows + + - name: Download Linux artifact + uses: actions/download-artifact@v4 + with: + name: nvr-export-linux + path: linux + + - name: Rename artifacts + run: | + mv windows/nvr-export.exe nvr-export-windows.exe + mv linux/nvr-export nvr-export-linux + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + files: | + nvr-export-windows.exe + nvr-export-linux + generate_release_notes: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..87d7eea --- /dev/null +++ b/.gitignore @@ -0,0 +1,72 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +*.egg +MANIFEST + +# PyInstaller +*.manifest +*.spec +!nvr-export.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Project specific +exports/ +*.mp4 +*.h264 diff --git a/README.md b/README.md index bd81386..b9a8e6c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,19 @@ A CLI tool to export video recordings from TP-Link Vigi NVRs over a specified ti ## Installation +### Option 1: Download Windows Executable (Recommended for Windows) + +1. Go to [Releases](https://github.com/johannes/tplink-nvr-export/releases) +2. Download `nvr-export-windows.exe` +3. Run from Command Prompt or PowerShell + +```powershell +# Example usage +.\nvr-export-windows.exe export -h 192.168.1.100 -u admin -c 1 -s "2024-12-28" -e "2024-12-29" -o ./exports +``` + +### Option 2: Install with pip (Requires Python) + ```bash # Clone the repository git clone https://github.com/johannes/tplink-nvr-export.git @@ -32,6 +45,18 @@ pip install -e . pipx install . ``` +### Option 3: Build Windows Executable Locally + +```bash +# Install dependencies +pip install -e ".[dev]" + +# Build single-file executable +pyinstaller --onefile --name nvr-export --console src/tplink_nvr_export/cli.py + +# Executable will be in dist/nvr-export.exe +``` + ## NVR Setup Before using this tool, enable OpenAPI on your NVR: diff --git a/nvr-export.spec b/nvr-export.spec new file mode 100644 index 0000000..f1028a4 --- /dev/null +++ b/nvr-export.spec @@ -0,0 +1,50 @@ +# -*- mode: python ; coding: utf-8 -*- +"""PyInstaller spec file for nvr-export Windows executable.""" + +block_cipher = None + +a = Analysis( + ['src/tplink_nvr_export/cli.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[ + 'click', + 'requests', + 'tqdm', + 'urllib3', + ], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) + +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='nvr-export', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, + icon=None, +) diff --git a/pyproject.toml b/pyproject.toml index 8b6923c..c9e1772 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dev = [ "pytest-cov>=4.1.0", "black>=23.0.0", "ruff>=0.1.0", + "pyinstaller>=6.0.0", ] [project.scripts]