Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TorrentManager.toml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
media_dir = ""
media_categories = ""

[qbittorrent_config]
web_url = ""
username = ""
password = ""
15 changes: 15 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub enum ConfigError {
/// to store files for seeding
/// - contains the directories for the different categories
///
/// The qbittorent config:
/// - use to connect torrentmanager to an instance of qbittorrent
///
/// What is currently not configurable:
///
/// - where magnets/torrents uploaded to TorrentManager are stored, hardcoded
Expand All @@ -63,6 +66,8 @@ pub struct AppConfig {
#[serde(skip, default)]
config_path: Utf8PathBuf,

pub qbittorrent_config: QbittorrentConfig,

/// Main directory where content files are stored
pub media_dir: Utf8PathBuf,

Expand All @@ -86,6 +91,16 @@ pub struct AppConfig {
pub listen: ListenerAddress,
}

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct QbittorrentConfig {
// Web URL of your Qbittorrent instance
pub web_url: String,
// Admin username for accessing qBittorrent
pub username: String,
// Admin password for accessing qBittorrent
pub password: String,
}

impl AppConfig {
pub fn xdg_base_directories() -> BaseDirectories {
BaseDirectories::with_prefix("torrentmanager")
Expand Down
9 changes: 6 additions & 3 deletions src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ impl AppState {
pub async fn new(config: AppConfig) -> Result<Self, AppStateError> {
// TODO: config for torrent backend

let torrent_client =
QBittorrentClient::new_not_logged_in("http://localhost:8080", "admin", "adminadmin")
.context(InitAPISnafu)?;
let torrent_client = QBittorrentClient::new_not_logged_in(
&config.qbittorrent_config.web_url,
&config.qbittorrent_config.username,
&config.qbittorrent_config.password,
)
.context(InitAPISnafu)?;

Ok(Self {
config,
Expand Down
Loading