feat(yt): use yt-dlp preset aliases

This commit is contained in:
Kristofers Solo 2025-09-23 11:37:02 +03:00
parent ef3e903a6f
commit 17f29f59be
Signed by: kristoferssolo
GPG Key ID: 74FF8144483D82C8
2 changed files with 2 additions and 14 deletions

View File

@ -7,7 +7,6 @@ services:
BINARY_NAME: tg-relay-rs
environment:
TELOXIDE_TOKEN: ${TELOXIDE_TOKEN}
YTDLP_FORMAT: ${YTDLP_FORMAT:-best}
COOKIES_PATH: /app/yt-cookies.txt
RUST_LOG: ${RUST_LOG:-info}
restart: unless-stopped

View File

@ -8,7 +8,6 @@ use crate::{
use futures::{StreamExt, stream};
use std::{
cmp::min,
env,
ffi::OsStr,
fs::{self, metadata},
path::{Path, PathBuf},
@ -130,18 +129,13 @@ pub async fn download_ytdlp<P: AsRef<Path>>(
url: &str,
cookies_path: Option<P>,
) -> Result<DownloadResult> {
let format_selector = env::var("YTDLP_FORMAT").unwrap_or_else(|_| "best".into());
info!(format_selector = format_selector, "video format");
let base_args = [
"--no-playlist",
"--merge-output-format",
"-t",
"mp4",
"-f",
// format_selector
"--restrict-filenames",
"-o",
"%(id)s.%(ext)s",
"%(title)s.%(ext)s",
"--no-warnings",
"--quiet",
];
@ -151,11 +145,6 @@ pub async fn download_ytdlp<P: AsRef<Path>>(
.map(ToString::to_string)
.collect::<Vec<_>>();
match args.iter().position(|s| s == "-f") {
Some(pos) => args.insert(pos + 1, format_selector),
None => args.extend(["-f".into(), format_selector]),
}
if let Some(cookie_path) = cookies_path {
let path = cookie_path.as_ref();
let path_str = path.to_string_lossy().to_string();