mirror of
https://github.com/kristoferssolo/tg-relay-rs.git
synced 2025-12-20 11:04:41 +00:00
feat: add instagram session file
This commit is contained in:
parent
fd389020c8
commit
85f7b9d2fb
@ -7,9 +7,11 @@ services:
|
|||||||
BINARY_NAME: tg-relay-rs
|
BINARY_NAME: tg-relay-rs
|
||||||
environment:
|
environment:
|
||||||
TELOXIDE_TOKEN: ${TELOXIDE_TOKEN}
|
TELOXIDE_TOKEN: ${TELOXIDE_TOKEN}
|
||||||
COOKIES_PATH: /app/yt-cookies.txt
|
COOKIES_PATH: ${YT_COOKIES_PATH:-/app/yt-cookies.txt}
|
||||||
|
SESSION_PATH: ${IG_SESSION_PATH:-/app/ig-session}
|
||||||
RUST_LOG: ${RUST_LOG:-info}
|
RUST_LOG: ${RUST_LOG:-info}
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./comments.txt:/app/comments.txt:ro
|
- ./comments.txt:/app/comments.txt:ro
|
||||||
- /etc/secrets/yt-cookies.txt:/app/yt-cookies.txt:rw
|
- /etc/secrets/ig-session:${IG_SESSION_PATH:-/app/ig-session}:ro
|
||||||
|
- /etc/secrets/yt-cookies.txt:${YT_COOKIES_PATH:-/app/yt-cookies.txt}:rw
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use crate::{
|
|||||||
use futures::{StreamExt, stream};
|
use futures::{StreamExt, stream};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::min,
|
cmp::min,
|
||||||
|
env,
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
fs::{self, metadata},
|
fs::{self, metadata},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@ -109,7 +110,14 @@ async fn run_command_in_tempdir(cmd: &str, args: &[&str]) -> Result<DownloadResu
|
|||||||
///
|
///
|
||||||
/// - Propagates `run_command_in_tempdir` errors.
|
/// - Propagates `run_command_in_tempdir` errors.
|
||||||
pub async fn download_instaloader(shortcode: &str) -> Result<DownloadResult> {
|
pub async fn download_instaloader(shortcode: &str) -> Result<DownloadResult> {
|
||||||
|
fn get_env_var(name: &str) -> Result<String> {
|
||||||
|
env::var(name).map_err(|_| Error::env(name))
|
||||||
|
}
|
||||||
|
let session_file = get_env_var("IG_SESSION_PATH")?;
|
||||||
|
|
||||||
let args = [
|
let args = [
|
||||||
|
"--sessionfile",
|
||||||
|
&session_file,
|
||||||
"--dirname-pattern=.",
|
"--dirname-pattern=.",
|
||||||
"--no-metadata-json",
|
"--no-metadata-json",
|
||||||
"--no-compress-json",
|
"--no-compress-json",
|
||||||
@ -138,6 +146,8 @@ pub async fn download_ytdlp<P: AsRef<Path>>(
|
|||||||
"%(title)s.%(ext)s",
|
"%(title)s.%(ext)s",
|
||||||
"--no-warnings",
|
"--no-warnings",
|
||||||
"--quiet",
|
"--quiet",
|
||||||
|
"--postprocessor-args",
|
||||||
|
"ffmpeg:-vf setsar=1 -c:v libx264 -crf 20 -preset veryfast -c:a aac -b:a 128k -movflags +faststart",
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut args = base_args
|
let mut args = base_args
|
||||||
|
|||||||
@ -26,8 +26,8 @@ pub enum Error {
|
|||||||
#[error("join error: {0}")]
|
#[error("join error: {0}")]
|
||||||
Join(#[from] tokio::task::JoinError),
|
Join(#[from] tokio::task::JoinError),
|
||||||
|
|
||||||
#[error("rate limit exceeded")]
|
#[error("environment variable `{0}` not found")]
|
||||||
RateLimit,
|
EnvNotFound(String),
|
||||||
|
|
||||||
#[error("other: {0}")]
|
#[error("other: {0}")]
|
||||||
Other(String),
|
Other(String),
|
||||||
@ -53,6 +53,11 @@ impl Error {
|
|||||||
pub fn validation_falied(text: impl Into<String>) -> Self {
|
pub fn validation_falied(text: impl Into<String>) -> Self {
|
||||||
Self::ValidationFailed(text.into())
|
Self::ValidationFailed(text.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn env(text: impl Into<String>) -> Self {
|
||||||
|
Self::EnvNotFound(text.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user