mirror of
https://github.com/kristoferssolo/tg-relay-rs.git
synced 2025-12-20 11:04:41 +00:00
feat(yt): use yt-dlp preset aliases
This commit is contained in:
parent
ef3e903a6f
commit
17f29f59be
@ -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
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user