From 63d56c47fc0ec118c9840b52923d3703564f21e7 Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 24 Jul 2024 09:26:31 +1000 Subject: [PATCH] Added linux build --- .github/workflows/x86-linux.yml | 54 +++++++++++++++++++++++++++++++++ README.md | 3 +- scripts/create_package.sh | 3 +- scripts/download_ubuntu.sh | 9 ++++++ src/main.rs | 4 +++ 5 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/x86-linux.yml create mode 100755 scripts/download_ubuntu.sh diff --git a/.github/workflows/x86-linux.yml b/.github/workflows/x86-linux.yml new file mode 100644 index 0000000..2f3543c --- /dev/null +++ b/.github/workflows/x86-linux.yml @@ -0,0 +1,54 @@ +name: x86-linux + +on: + workflow_dispatch: + push: + branches: [ "master", "main", "dev" ] + +env: + PACKAGE_DIR: package + +jobs: + skip_check: + continue-on-error: false + runs-on: ubuntu-22.04 + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@v5 + with: + concurrent_skipping: 'same_content' + cancel_others: 'true' + skip_after_successful_duplicate: 'true' + paths_ignore: '["**/README.md", "**/docs/**", "**/LICENSE"]' + do_not_skip: '["workflow_dispatch", "schedule"]' + + build: + needs: skip_check + if: needs.skip_check.outputs.should_skip != 'true' + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Build + shell: bash + run: cargo build + + - name: Copy files + shell: bash + run: ./scripts/create_package.sh ${{env.PACKAGE_DIR}} debug ytdlp_server + + - name: Download third party binaries + shell: bash + run: ./scripts/download_ubuntu.sh + + - name: Upload files + uses: actions/upload-artifact@v3 + with: + name: ytdlp_webui_ubuntu_x86 + path: ${{github.workspace}}/${{env.PACKAGE_DIR}} diff --git a/README.md b/README.md index cace8ea..e7b8159 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Introduction [![x86-windows](https://github.com/williamyang98/ytdlp_webui/actions/workflows/x86-windows.yml/badge.svg)](https://github.com/williamyang98/ytdlp_webui/actions/workflows/x86-windows.yml) +[![x86-linux](https://github.com/williamyang98/ytdlp_webui/actions/workflows/x86-linux.yml/badge.svg)](https://github.com/williamyang98/ytdlp_webui/actions/workflows/x86-linux.yml) Download and convert Youtube videos into audio clips. Has a web UI client that wraps around ```yt-dlp``` and ```ffmpeg``` and caches downloaded and transcoded files locally. @@ -16,6 +17,6 @@ Download and convert Youtube videos into audio clips. Has a web UI client that w ## Building 1. Download rust. -2. Download ffmpeg and yt-dlp using ```./scripts/download_win32.sh``` or links for your platform. +2. Download ffmpeg and yt-dlp using ```./scripts/download_*.sh``` for your platform. 3. Build server: ```cargo build -r``` 4. Run server: ```cargo run -r``` diff --git a/scripts/create_package.sh b/scripts/create_package.sh index 31c45e6..fffe66d 100755 --- a/scripts/create_package.sh +++ b/scripts/create_package.sh @@ -1,9 +1,10 @@ #!/bin/sh path=${1:-package} build_type=${2:-release} +exec_name=${3:-ytdlp_server.exe} rm -rf $path/ mkdir -p $path/ -cp ./target/$build_type/ytdlp_server.exe $path/ +cp ./target/$build_type/$exec_name $path/ cp ./README.md $path/ cp ./LICENSE $path/ cp -rf ./static/ $path/ diff --git a/scripts/download_ubuntu.sh b/scripts/download_ubuntu.sh new file mode 100755 index 0000000..0f3e6fb --- /dev/null +++ b/scripts/download_ubuntu.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# Install yt-dlp +mkdir ./bin/ +curl -fLo ./bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/download/2024.07.16/yt-dlp_linux +set -e +echo a6b840e536014ce7b2c7c40b758080498ed5054aa96979e64fcc369752cdc8d3 ./bin/yt-dlp | sha256sum --check +sudo chmod 777 ./bin/yt-dlp +# Install ffmpeg +sudo apt-get --yes install ffmpeg diff --git a/src/main.rs b/src/main.rs index a83a1f6..a5f0db5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,9 +29,13 @@ struct Args { total_worker_threads: usize, /// ffmpeg binary for transcoding between formats #[arg(long)] + #[cfg_attr(windows, arg(default_value = Some("./bin/ffmpeg.exe")))] + #[cfg_attr(unix, arg(default_value = Some("ffmpeg")))] ffmpeg_binary_path: Option, /// yt-dlp binary for downloading from Youtube #[arg(long)] + #[cfg_attr(windows, arg(default_value = Some("./bin/yt-dlp.exe")))] + #[cfg_attr(unix, arg(default_value = Some("./bin/yt-dlp")))] ytdlp_binary_path: Option, }