Compare commits
8 Commits
22d7a252b8
...
renovate/a
Author | SHA1 | Date | |
---|---|---|---|
99ffff47e4 | |||
acb12c1e33 | |||
d515ad9545
|
|||
14ceadddd4
|
|||
36c9d0f0e5
|
|||
cd861c82fd | |||
ae139e425a | |||
1d3dccbf6d |
14
.drone.yml
14
.drone.yml
@@ -8,10 +8,15 @@ steps:
|
|||||||
settings:
|
settings:
|
||||||
username: kasperhermansen
|
username: kasperhermansen
|
||||||
password:
|
password:
|
||||||
from_secret:
|
from_secret: docker_secret
|
||||||
docker_secret
|
|
||||||
repo: kasperhermansen/twatch
|
repo: kasperhermansen/twatch
|
||||||
tags: latest
|
tags: latest
|
||||||
|
when:
|
||||||
|
event:
|
||||||
|
include:
|
||||||
|
- push
|
||||||
|
- tag
|
||||||
|
- promote
|
||||||
|
|
||||||
- name: send telegram notification
|
- name: send telegram notification
|
||||||
image: appleboy/drone-telegram
|
image: appleboy/drone-telegram
|
||||||
@@ -20,3 +25,8 @@ steps:
|
|||||||
from_secret: telegram_token
|
from_secret: telegram_token
|
||||||
to: 2129601481
|
to: 2129601481
|
||||||
format: markdown
|
format: markdown
|
||||||
|
depends_on:
|
||||||
|
- "docker"
|
||||||
|
when:
|
||||||
|
status:
|
||||||
|
- "failure"
|
||||||
|
1428
Cargo.lock
generated
1428
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
|||||||
FROM rust:slim-bullseye AS builder
|
FROM harbor.front.kjuulh.io/docker-proxy/library/rust:slim-bullseye AS builder
|
||||||
|
|
||||||
COPY . /app/builder/
|
COPY . /app/builder/
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ WORKDIR /app/builder/
|
|||||||
|
|
||||||
RUN cargo build --release
|
RUN cargo build --release
|
||||||
|
|
||||||
FROM debian:bullseye-slim
|
FROM harbor.front.kjuulh.io/docker-proxy/library/debian:bullseye-slim
|
||||||
|
|
||||||
COPY --from=builder /app/builder/target/release/ /app/
|
COPY --from=builder /app/builder/target/release/ /app/
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
3
renovate.json
Normal file
3
renovate.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://docs.renovatebot.com/renovate-schema.json"
|
||||||
|
}
|
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
twatch_core = {path="../twatch_core"}
|
twatch_core = {path="../twatch_core"}
|
||||||
tokio = {version="1.17.0", features=["full"]}
|
tokio = {version="1.21.2", features=["full"]}
|
||||||
env_logger="0.9.0"
|
env_logger="0.11.0"
|
||||||
log = "0.4.16"
|
log = "0.4.17"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
@@ -1,19 +1,22 @@
|
|||||||
|
use log::info;
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::env::VarError;
|
use std::env::VarError;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use log::info;
|
|
||||||
use twatch_core::App;
|
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
use twatch_core::App;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), VarError> {
|
async fn main() -> Result<(), VarError> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
dotenv::dotenv();
|
dotenv::dotenv().expect("to load .env");
|
||||||
|
|
||||||
let url = env::var("T_URL")?;
|
let url = env::var("T_URL")?;
|
||||||
let user = env::var("T_USER")?;
|
let user = env::var("T_USER")?;
|
||||||
let password = env::var("T_PASSWORD")?;
|
let password = env::var("T_PASSWORD")?;
|
||||||
let cycle_seconds = env::var("T_CYCLE").unwrap_or("30".to_string()).parse::<u64>().unwrap_or(30);
|
let cycle_seconds = env::var("T_CYCLE")
|
||||||
|
.unwrap_or("30".to_string())
|
||||||
|
.parse::<u64>()
|
||||||
|
.unwrap_or(30);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
info!("running clean up cycle");
|
info!("running clean up cycle");
|
||||||
|
@@ -6,6 +6,6 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
transmission-rpc = "0.3.6"
|
transmission-rpc = "0.5.0"
|
||||||
env_logger="0.9.0"
|
env_logger="0.11.0"
|
||||||
log = "0.4.16"
|
log = "0.4.17"
|
@@ -1,6 +1,6 @@
|
|||||||
|
use log::info;
|
||||||
|
use transmission_rpc::types::{BasicAuth, Id, Result, Torrent, Torrents};
|
||||||
use transmission_rpc::TransClient;
|
use transmission_rpc::TransClient;
|
||||||
use transmission_rpc::types::{Result, BasicAuth, Torrent, Torrents, Id};
|
|
||||||
use log::{info};
|
|
||||||
|
|
||||||
pub struct App {
|
pub struct App {
|
||||||
client: TransClient,
|
client: TransClient,
|
||||||
@@ -8,29 +8,36 @@ pub struct App {
|
|||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
pub fn new(url: &String, username: &String, password: &String) -> Self {
|
pub fn new(url: &String, username: &String, password: &String) -> Self {
|
||||||
let auth = BasicAuth { user: username.clone(), password: password.clone() };
|
let auth = BasicAuth {
|
||||||
|
user: username.clone(),
|
||||||
|
password: password.clone(),
|
||||||
|
};
|
||||||
let client = TransClient::with_auth(url.as_str(), auth);
|
let client = TransClient::with_auth(url.as_str(), auth);
|
||||||
Self {
|
Self { client }
|
||||||
client
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn run(&self) -> Result<()> {
|
pub async fn run(mut self) -> Result<()> {
|
||||||
let response = self.client.torrent_get(None, None).await;
|
let response = self.client.torrent_get(None, None).await;
|
||||||
match response {
|
match response {
|
||||||
Ok(res) => self.scan_files(res.arguments).await.unwrap(),
|
Ok(res) => self.scan_files(res.arguments).await.unwrap(),
|
||||||
Err(e) => println!("{}", e.to_string())
|
Err(e) => println!("{}", e.to_string()),
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
async fn scan_files(&self, torrents: Torrents<Torrent>) -> Result<()> {
|
async fn scan_files(self, torrents: Torrents<Torrent>) -> Result<()> {
|
||||||
let mut torrents_to_remove = Vec::new();
|
let mut torrents_to_remove = Vec::new();
|
||||||
|
|
||||||
for torrent in torrents.torrents {
|
for torrent in torrents.torrents {
|
||||||
match (torrent.id, torrent.is_stalled) {
|
match (torrent.id, torrent.is_stalled) {
|
||||||
(Some(id), Some(true)) => {
|
(Some(id), Some(true)) => {
|
||||||
info!("processing: (id: {}, name: {})", id, torrent.name.unwrap_or("name could not be found from torrent".to_string()));
|
info!(
|
||||||
|
"processing: (id: {}, name: {})",
|
||||||
|
id,
|
||||||
|
torrent
|
||||||
|
.name
|
||||||
|
.unwrap_or("name could not be found from torrent".to_string())
|
||||||
|
);
|
||||||
torrents_to_remove.push(id);
|
torrents_to_remove.push(id);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@@ -49,7 +56,11 @@ impl App {
|
|||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
async fn clean_up_torrents(&self, torrent_ids: Vec<i64>) {
|
async fn clean_up_torrents(mut self, torrent_ids: Vec<i64>) {
|
||||||
self.client.torrent_remove(torrent_ids.iter().map(|ti| { Id::Id(*ti) }).collect(), true).await;
|
self.client
|
||||||
|
.torrent_remove(torrent_ids.iter().map(|ti| Id::Id(*ti)).collect(), true)
|
||||||
|
.await
|
||||||
|
.expect("to remove torrent");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user