Skip to content

Commit 3854977

Browse files
Gabatxo1312angrynode
authored andcommitted
Move qbitorrent config to config file
1 parent 81121e5 commit 3854977

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

TorrentManager.toml.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
media_dir = ""
2+
media_categories = ""
3+
4+
[qbittorrent_config]
5+
web_url = ""
6+
username = ""
7+
password = ""

src/config.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ pub enum ConfigError {
4545
/// to store files for seeding
4646
/// - contains the directories for the different categories
4747
///
48+
/// The qbittorent config:
49+
/// - use to connect torrentmanager to an instance of qbittorrent
50+
///
4851
/// What is currently not configurable:
4952
///
5053
/// - where magnets/torrents uploaded to TorrentManager are stored, hardcoded
@@ -63,6 +66,8 @@ pub struct AppConfig {
6366
#[serde(skip, default)]
6467
config_path: Utf8PathBuf,
6568

69+
pub qbittorrent_config: QbittorrentConfig,
70+
6671
/// Main directory where content files are stored
6772
pub media_dir: Utf8PathBuf,
6873

@@ -86,6 +91,16 @@ pub struct AppConfig {
8691
pub listen: ListenerAddress,
8792
}
8893

94+
#[derive(Clone, Debug, Deserialize, Serialize)]
95+
pub struct QbittorrentConfig {
96+
// Web URL of your Qbittorrent instance
97+
pub web_url: String,
98+
// Admin username for accessing qBittorrent
99+
pub username: String,
100+
// Admin password for accessing qBittorrent
101+
pub password: String,
102+
}
103+
89104
impl AppConfig {
90105
pub fn xdg_base_directories() -> BaseDirectories {
91106
BaseDirectories::with_prefix("torrentmanager")

src/state/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@ impl AppState {
5454
pub async fn new(config: AppConfig) -> Result<Self, AppStateError> {
5555
// TODO: config for torrent backend
5656

57-
let torrent_client =
58-
QBittorrentClient::new_not_logged_in("http://localhost:8080", "admin", "adminadmin")
59-
.context(InitAPISnafu)?;
57+
let torrent_client = QBittorrentClient::new_not_logged_in(
58+
&config.qbittorrent_config.web_url,
59+
&config.qbittorrent_config.username,
60+
&config.qbittorrent_config.password,
61+
)
62+
.context(InitAPISnafu)?;
6063

6164
Ok(Self {
6265
config,

0 commit comments

Comments
 (0)