mirror of
https://github.com/YGGverse/aquatic-crawler.git
synced 2026-03-31 17:15:35 +00:00
implement export-trackers argument option
This commit is contained in:
parent
f4425557ee
commit
113dd9ac09
4 changed files with 23 additions and 5 deletions
|
|
@ -45,6 +45,10 @@ pub struct Config {
|
|||
#[arg(long)]
|
||||
pub export_rss_description: Option<String>,
|
||||
|
||||
/// Appends `--tracker` value to magnets and torrents
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub export_trackers: bool,
|
||||
|
||||
/// Enable DHT resolver
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub enable_dht: bool,
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -67,7 +67,7 @@ async fn main() -> Result<()> {
|
|||
upload_bps: config.upload_limit.and_then(NonZero::new),
|
||||
download_bps: config.download_limit.and_then(NonZero::new),
|
||||
},
|
||||
trackers: trackers.clone(),
|
||||
trackers: trackers.list().clone(),
|
||||
..SessionOptions::default()
|
||||
},
|
||||
)
|
||||
|
|
@ -109,7 +109,14 @@ async fn main() -> Result<()> {
|
|||
match time::timeout(
|
||||
Duration::from_secs(config.add_torrent_timeout),
|
||||
session.add_torrent(
|
||||
AddTorrent::from_url(magnet(&i, None)),
|
||||
AddTorrent::from_url(magnet(
|
||||
&i,
|
||||
if config.export_trackers && !trackers.is_empty() {
|
||||
Some(trackers.list())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
)),
|
||||
Some(AddTorrentOptions {
|
||||
paused: true, // continue after `only_files` init
|
||||
overwrite: true,
|
||||
|
|
@ -227,7 +234,11 @@ async fn main() -> Result<()> {
|
|||
&config.export_rss_title,
|
||||
&config.export_rss_link,
|
||||
&config.export_rss_description,
|
||||
Some(trackers.clone()),
|
||||
if config.export_trackers && !trackers.is_empty() {
|
||||
Some(trackers.list().clone())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
)?;
|
||||
for (k, v) in index.list() {
|
||||
rss.push(
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl Trackers {
|
|||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
}
|
||||
pub fn clone(&self) -> HashSet<Url> {
|
||||
self.0.clone()
|
||||
pub fn list(&self) -> &HashSet<Url> {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue