Skip to content

Commit

Permalink
[+] add youtube downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed May 11, 2024
1 parent 450cbe0 commit d4e2b04
Show file tree
Hide file tree
Showing 9 changed files with 1,442 additions and 99 deletions.
613 changes: 518 additions & 95 deletions rust/Cargo.lock

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ crate-type = ["cdylib", "staticlib"]
[dependencies]
log = "0.4"
anyhow = "1.0"
regex = "1.10"
chrono = "0.4"
lazy_static = "1.4"
flutter_rust_bridge = "=2.0.0-dev.33"
tokio = { version = "1", features = ["full"] }
tokio = { version = "1.37", features = ["full"] }
serde = { version = "1.0", features = ["serde_derive"] }

[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
env_logger = "0.10"
reqwest = { version = "0.12", features = ["json", "socks"] }
sqlx = { version = "0.7", features = ["runtime-tokio", "sqlite"] }
rustube = { git = "https://github.com/Heng30/rustube.git", features = [
"default",
"socks",
"callback",
] }

[target.'cfg(target_os = "ios")'.dependencies]
oslog = "0.2.0"
Expand All @@ -29,8 +35,13 @@ android_logger = "0.13"
# mobile platform
[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
reqwest = { version = "0.12", features = [
"rustls-tls",
"native-tls-vendored",
"json",
"socks",
] }
rustube = { git = "https://github.com/Heng30/rustube.git", features = [
"default",
"native-tls-vendored",
"socks",
"callback",
] }
12 changes: 12 additions & 0 deletions rust/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

run-evn=RUST_LOG=error,warn,info,debug,sqlx=off,reqwest=off,html2text=off

all:
cargo build

build-android:
cargo apk build --lib

run:
$(run-evn) cargo run --bin downloader
1 change: 1 addition & 0 deletions rust/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
stable
4 changes: 3 additions & 1 deletion rust/src/api/db.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use anyhow::Result;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use tokio::{fs, sync::Mutex};

#[cfg(not(any(target_os = "android", target_os = "ios")))]
use serde::{Deserialize, Serialize};

#[cfg(not(any(target_os = "android", target_os = "ios")))]
use sqlx::{
migrate::MigrateDatabase,
Expand Down
2 changes: 2 additions & 0 deletions rust/src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
pub mod log;
pub mod db;
pub mod video_info;
pub mod youtube;

#[flutter_rust_bridge::frb(init)]
pub fn init_app() {
Expand Down
16 changes: 16 additions & 0 deletions rust/src/api/video_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#[derive(Debug, Clone)]
pub struct Info {
pub title: String,
pub author: String,
pub video_id: String,
pub short_description: String,
pub view_count: u64,
pub length_seconds: u64,
}

#[derive(Debug, Clone, Default)]
pub struct ProgerssData {
pub current_size: u64,
pub total_size: Option<u64>,
}

Loading

0 comments on commit d4e2b04

Please sign in to comment.