feat(yt): add cookies env flag

This commit is contained in:
Kristofers Solo 2025-09-23 10:15:54 +03:00
parent e11223fa75
commit 5ad4aea252
Signed by: kristoferssolo
GPG Key ID: 74FF8144483D82C8
3 changed files with 8 additions and 2 deletions

View File

@ -41,5 +41,6 @@ RUN uv tool install instaloader \
&& uv tool install yt-dlp[default] \
&& yt-dlp --version
WORKDIR /app
COPY --from=builder-rs /app/target/release/tg-relay-rs /usr/local/bin/tg-relay-rs
CMD ["/usr/local/bin/tg-relay-rs"]

View File

@ -8,8 +8,9 @@ services:
environment:
TELOXIDE_TOKEN: ${TELOXIDE_TOKEN}
COOKIES_PATH: ${COOKIES_PATH:-/app/yt-cookies.txt}
COOKIES: ${COOKIES:-false}
RUST_LOG: ${RUST_LOG:-info}
restart: unless-stopped
volumes:
- ./comments.txt:/app/comments.txt:ro
- /etc/secrets/yt-cookies.txt:/app/yt-cookies.txt
- /etc/secrets/yt-cookies.txt:/app/yt-cookies.txt:ro

View File

@ -144,7 +144,11 @@ pub async fn download_ytdlp(url: &str, cookies: Option<&str>) -> Result<Download
"--quiet",
];
if let Some(cookie_path) = cookies {
let with_cookies = env::var("COOKIES")
.unwrap_or_else(|_| "false".into())
.parse::<bool>()
.unwrap_or(false);
if with_cookies && let Some(cookie_path) = cookies {
if Path::new(cookie_path).exists() {
args.extend(["--cookies", cookie_path]);
} else {