Spaces:
Running
Running
Upload soundcloud.rs
Browse files- src/soundcloud.rs +10 -3
src/soundcloud.rs
CHANGED
|
@@ -279,10 +279,17 @@ pub async fn download(Query(params): Query<DownloadParams>) -> impl IntoResponse
|
|
| 279 |
};
|
| 280 |
|
| 281 |
// Telegram Bot API плохо работает с некоторыми форматами по URL.
|
| 282 |
-
// Конвертируем OPUS и
|
| 283 |
let (final_data, final_content_type, final_extension) =
|
| 284 |
-
if actual_file.ends_with(".opus") || actual_file.ends_with(".webm") {
|
| 285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 286 |
|
| 287 |
let mp3_file = format!("{}.mp3", temp_file);
|
| 288 |
let convert_output = Command::new("ffmpeg")
|
|
|
|
| 279 |
};
|
| 280 |
|
| 281 |
// Telegram Bot API плохо работает с некоторыми форматами по URL.
|
| 282 |
+
// Конвертируем OPUS, WEBM и M4A в MP3 для совместимости.
|
| 283 |
let (final_data, final_content_type, final_extension) =
|
| 284 |
+
if actual_file.ends_with(".opus") || actual_file.ends_with(".webm") || actual_file.ends_with(".m4a") || actual_file.ends_with(".aac") {
|
| 285 |
+
let target_format = if actual_file.ends_with(".m4a") || actual_file.ends_with(".aac") {
|
| 286 |
+
"AAC/M4A"
|
| 287 |
+
} else if actual_file.ends_with(".opus") {
|
| 288 |
+
"OPUS"
|
| 289 |
+
} else {
|
| 290 |
+
"WEBM"
|
| 291 |
+
};
|
| 292 |
+
tracing::info!("Converting {} to MP3 320k for Telegram compatibility", target_format);
|
| 293 |
|
| 294 |
let mp3_file = format!("{}.mp3", temp_file);
|
| 295 |
let convert_output = Command::new("ffmpeg")
|