From 4ac34e7bfe16873c83074104f5813c226d2bbfc8 Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 24 Jul 2024 05:19:24 +1000 Subject: [PATCH] Added manifest for third party binaries --- .github/workflows/x86-windows.yml | 4 ++++ .gitignore | 1 + README.md | 5 +++-- bin/README.md | 5 +++++ scripts/download_win32.sh | 17 +++++++++++++++++ src/main.rs | 13 +++++++++++-- 6 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 bin/README.md create mode 100755 scripts/download_win32.sh diff --git a/.github/workflows/x86-windows.yml b/.github/workflows/x86-windows.yml index 6946055..7f07c0c 100644 --- a/.github/workflows/x86-windows.yml +++ b/.github/workflows/x86-windows.yml @@ -43,6 +43,10 @@ jobs: shell: bash run: ./scripts/create_package.sh ${{env.PACKAGE_DIR}} debug + - name: Download third party binaries + shell: bash + run: ./scripts/download_win32.sh + - name: Upload files uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index 6169dd6..4eac754 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /target/ /data/ /package/ +/bin/ diff --git a/README.md b/README.md index de60d7a..cace8ea 100644 --- a/README.md +++ b/README.md @@ -16,5 +16,6 @@ Download and convert Youtube videos into audio clips. Has a web UI client that w ## Building 1. Download rust. -2. Build server: ```cargo build -r``` -3. Run server: ```cargo run -r``` +2. Download ffmpeg and yt-dlp using ```./scripts/download_win32.sh``` or links for your platform. +3. Build server: ```cargo build -r``` +4. Run server: ```cargo run -r``` diff --git a/bin/README.md b/bin/README.md new file mode 100644 index 0000000..de788ed --- /dev/null +++ b/bin/README.md @@ -0,0 +1,5 @@ +# Source for binaries +| Name | Location | MD5 Hash | +| --- | --- | --- | +| ffmpeg | [Link](https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-2024-07-18-git-fa5a605542-essentials_build.7z) | 7c35458246ef08c70b76f11b2a12c41c83d72508eefaf9b75e572089c1c1b1c8 | +| yt-dlp | [Link](https://github.com/yt-dlp/yt-dlp/releases/download/2024.07.16/yt-dlp.exe) | e96f6348244306ac999501b1e8e2b096b8a57f098c3b2b9ffe64b2107039e0ae | diff --git a/scripts/download_win32.sh b/scripts/download_win32.sh new file mode 100755 index 0000000..5367d3a --- /dev/null +++ b/scripts/download_win32.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Download files +mkdir ./bin/ +cd ./bin +curl -fLo ./yt-dlp.exe https://github.com/yt-dlp/yt-dlp/releases/download/2024.07.16/yt-dlp.exe & +curl -fLo ./ffmpeg.7z https://github.com/GyanD/codexffmpeg/releases/download/7.0.1/ffmpeg-7.0.1-essentials_build.7z & +wait +# Unzip +7z x ./ffmpeg.7z -offmpeg -y +cp ./ffmpeg/ffmpeg-7.0.1-essentials_build/bin/ffmpeg.exe ./ffmpeg.exe +# Verify hash +set -e +echo d7b51e782c79f564d6e33907b17b010f01634c00e3c42559975cbc7a82982f8f ffmpeg.exe | sha256sum --check +echo e96f6348244306ac999501b1e8e2b096b8a57f098c3b2b9ffe64b2107039e0ae yt-dlp.exe | sha256sum --check +# Cleanup +rm ./ffmpeg.7z +rm -rf ./ffmpeg diff --git a/src/main.rs b/src/main.rs index 144f80d..a83a1f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use std::sync::{Arc, Mutex}; +use std::path::PathBuf; use actix_web::{middleware, web, App, HttpServer}; use clap::Parser; use dashmap::DashMap; @@ -15,7 +16,7 @@ use ytdlp_server::{ #[command(version, about, long_about = None)] struct Args { /// Url of server - #[arg(long, default_value = "127.0.0.1")] + #[arg(long, default_value = "0.0.0.0")] url: String, /// Port of server #[arg(long, default_value_t = 8080)] @@ -26,6 +27,12 @@ struct Args { /// Maximum number of worker threads #[arg(long, default_value_t = 0)] total_worker_threads: usize, + /// ffmpeg binary for transcoding between formats + #[arg(long)] + ffmpeg_binary_path: Option, + /// yt-dlp binary for downloading from Youtube + #[arg(long)] + ytdlp_binary_path: Option, } #[actix_web::main] @@ -41,7 +48,9 @@ async fn main() -> Result<(), Box> { 0 => std::thread::available_parallelism().map(|v| v.get()).unwrap_or(1), x => x, }; - let app_config = AppConfig::default(); + let mut app_config = AppConfig::default(); + if let Some(path) = args.ytdlp_binary_path { app_config.ytdlp_binary = PathBuf::from(path); } + if let Some(path) = args.ffmpeg_binary_path { app_config.ffmpeg_binary = PathBuf::from(path); } app_config.seed_directories()?; let db_manager = r2d2_sqlite::SqliteConnectionManager::file(app_config.root.join("index.db")); let db_pool = DatabasePool::new(db_manager)?;