feat: wire videy + tiktok/v2 + twitter/v2 downloader endpoints
Deploy Scraper / build-and-deploy (push) Canceled after 0s
Deploy Scraper / build-and-deploy (push) Canceled after 0s
Ported all missing downloader endpoints from Shirokami-API source
(verified against /home/code/Shirokami-API/scraper/downloader/):
- /download/videy: direct CDN link build (cdn.videy.co/{id}.mp4|.mov)
matches videy.js exactly (id.len()==9 && id[8]=='2' -> .mov)
- /download/tiktok/v2: douyin.wtf hybrid API w/ fallback to embed scrape
- /download/twitter/v2: twitsave.com HTML scrape w/ fallback to Syndication API
- detect_platform now recognizes videy.co
- download_all_in_one dispatches videy
fetch_videy already existed as dead code (never wired); connected it.
== all others (bilibili/danbooru/dood/gdrive/instagram/kfiles/mediafire/
== mega/pinterest/pixeldrain/savetube/soundcloud/spotify/terabox/threads/
== tiktok/twitter/youtubeV2) already mapped to their Rust equivalents
This commit is contained in:
1 parent
dfa37f86e3
commit
dc44085cad
4 files changed
+78
No files matched your search
@@ -119,6 +119,18 @@ pub async fn download_streamable(url: &str) -> Result<DownloadResult, ScrapingEr
|
|||||||
DownloaderRepository::download_streamable(url).await
|
DownloaderRepository::download_streamable(url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn download_videy(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
DownloaderRepository::download_videy(url).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn download_tiktok_v2(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
DownloaderRepository::download_tiktok_v2(url, None).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn download_twitter_v2(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
DownloaderRepository::download_twitter_v2(url, None).await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn download_bilibili(url: &str) -> Result<DownloadResult, ScrapingError> {
|
pub async fn download_bilibili(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
DownloaderRepository::download_bilibili(url).await
|
DownloaderRepository::download_bilibili(url).await
|
||||||
}
|
}
|
||||||
@@ -165,6 +177,8 @@ pub fn detect_platform(url: &str) -> String {
|
|||||||
"dailymotion".to_string()
|
"dailymotion".to_string()
|
||||||
} else if url.contains("streamable.com") {
|
} else if url.contains("streamable.com") {
|
||||||
"streamable".to_string()
|
"streamable".to_string()
|
||||||
|
} else if url.contains("videy.co") {
|
||||||
|
"videy".to_string()
|
||||||
} else if url.contains("bilibili.com") || url.contains("b23.tv") {
|
} else if url.contains("bilibili.com") || url.contains("b23.tv") {
|
||||||
"bilibili".to_string()
|
"bilibili".to_string()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -451,6 +451,7 @@ impl DownloaderRepository {
|
|||||||
Err(_) => Self::download_facebook(url, cookies).await,
|
Err(_) => Self::download_facebook(url, cookies).await,
|
||||||
},
|
},
|
||||||
"tiktok" => Self::download_tiktok(url, cookies).await,
|
"tiktok" => Self::download_tiktok(url, cookies).await,
|
||||||
|
"videy" => Self::download_videy(url).await,
|
||||||
"youtube" => match Self::download_youtube(url, "720").await {
|
"youtube" => match Self::download_youtube(url, "720").await {
|
||||||
ok @ Ok(_) => ok,
|
ok @ Ok(_) => ok,
|
||||||
Err(_) => Self::download_youtube_mp3(url).await,
|
Err(_) => Self::download_youtube_mp3(url).await,
|
||||||
@@ -608,6 +609,33 @@ impl DownloaderRepository {
|
|||||||
fetch_streamable(url).await
|
fetch_streamable(url).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Videy video (direct CDN link build; ported from Shirokami-API videy.js).
|
||||||
|
pub async fn download_videy(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
fetch_videy(url).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// TikTok v2 (douyin.wtf hybrid API; falls back to embed scrape when dead).
|
||||||
|
pub async fn download_tiktok_v2(
|
||||||
|
url: &str,
|
||||||
|
cookies: Option<&str>,
|
||||||
|
) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
match fetch_tiktok_v2(url).await {
|
||||||
|
ok @ Ok(_) => ok,
|
||||||
|
Err(_) => Self::download_tiktok(url, cookies).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Twitter v2 (twitsave.com scrape; falls back to Syndication API when blocked).
|
||||||
|
pub async fn download_twitter_v2(
|
||||||
|
url: &str,
|
||||||
|
cookies: Option<&str>,
|
||||||
|
) -> Result<DownloadResult, ScrapingError> {
|
||||||
|
match fetch_twitter_v2(url).await {
|
||||||
|
ok @ Ok(_) => ok,
|
||||||
|
Err(_) => Self::download_twitter(url, cookies).await,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Bilibili video via b23.tv short link expansion.
|
/// Bilibili video via b23.tv short link expansion.
|
||||||
pub async fn download_bilibili(url: &str) -> Result<DownloadResult, ScrapingError> {
|
pub async fn download_bilibili(url: &str) -> Result<DownloadResult, ScrapingError> {
|
||||||
fetch_bilibili(url).await
|
fetch_bilibili(url).await
|
||||||
|
|||||||
@@ -219,6 +219,30 @@ pub async fn download_streamable(
|
|||||||
Ok(Json(DownloadResponse::ok(result)))
|
Ok(Json(DownloadResponse::ok(result)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handler for _videy.
|
||||||
|
pub async fn download_videy(
|
||||||
|
Query(params): Query<DownloadParams>,
|
||||||
|
) -> Result<Json<DownloadResponse>, AppError> {
|
||||||
|
let result = use_cases::download_videy(¶ms.url).await?;
|
||||||
|
Ok(Json(DownloadResponse::ok(result)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Handler for _tiktok_v2.
|
||||||
|
pub async fn download_tiktok_v2(
|
||||||
|
Query(params): Query<DownloadParams>,
|
||||||
|
) -> Result<Json<DownloadResponse>, AppError> {
|
||||||
|
let result = use_cases::download_tiktok_v2(¶ms.url).await?;
|
||||||
|
Ok(Json(DownloadResponse::ok(result)))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Handler for _twitter_v2.
|
||||||
|
pub async fn download_twitter_v2(
|
||||||
|
Query(params): Query<DownloadParams>,
|
||||||
|
) -> Result<Json<DownloadResponse>, AppError> {
|
||||||
|
let result = use_cases::download_twitter_v2(¶ms.url).await?;
|
||||||
|
Ok(Json(DownloadResponse::ok(result)))
|
||||||
|
}
|
||||||
|
|
||||||
/// Handler for _bilibili.
|
/// Handler for _bilibili.
|
||||||
pub async fn download_bilibili(
|
pub async fn download_bilibili(
|
||||||
Query(params): Query<DownloadParams>,
|
Query(params): Query<DownloadParams>,
|
||||||
|
|||||||
@@ -248,6 +248,18 @@ pub fn build_router(app_state: Arc<AppState>) -> anyhow::Result<Router> {
|
|||||||
"/download/streamable",
|
"/download/streamable",
|
||||||
axum::routing::get(crate::presentation::handler::downloader::download_streamable),
|
axum::routing::get(crate::presentation::handler::downloader::download_streamable),
|
||||||
)
|
)
|
||||||
|
.route(
|
||||||
|
"/download/videy",
|
||||||
|
axum::routing::get(crate::presentation::handler::downloader::download_videy),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/download/tiktok/v2",
|
||||||
|
axum::routing::get(crate::presentation::handler::downloader::download_tiktok_v2),
|
||||||
|
)
|
||||||
|
.route(
|
||||||
|
"/download/twitter/v2",
|
||||||
|
axum::routing::get(crate::presentation::handler::downloader::download_twitter_v2),
|
||||||
|
)
|
||||||
.route(
|
.route(
|
||||||
"/download/bilibili",
|
"/download/bilibili",
|
||||||
axum::routing::get(crate::presentation::handler::downloader::download_bilibili),
|
axum::routing::get(crate::presentation::handler::downloader::download_bilibili),
|
||||||
|
|||||||
Reference in new issue
Block a user