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
|
|
@ -87,6 +87,9 @@ aquatic-crawler --infohash /path/to/info-hash-ipv4.json\
|
||||||
--export-rss-description <EXPORT_RSS_DESCRIPTION>
|
--export-rss-description <EXPORT_RSS_DESCRIPTION>
|
||||||
Custom description for RSS feed (channel)
|
Custom description for RSS feed (channel)
|
||||||
|
|
||||||
|
--export-trackers
|
||||||
|
Appends `--tracker` value to magnets and torrents
|
||||||
|
|
||||||
--enable-dht
|
--enable-dht
|
||||||
Enable DHT resolver
|
Enable DHT resolver
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ pub struct Config {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub export_rss_description: Option<String>,
|
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
|
/// Enable DHT resolver
|
||||||
#[arg(long, default_value_t = false)]
|
#[arg(long, default_value_t = false)]
|
||||||
pub enable_dht: bool,
|
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),
|
upload_bps: config.upload_limit.and_then(NonZero::new),
|
||||||
download_bps: config.download_limit.and_then(NonZero::new),
|
download_bps: config.download_limit.and_then(NonZero::new),
|
||||||
},
|
},
|
||||||
trackers: trackers.clone(),
|
trackers: trackers.list().clone(),
|
||||||
..SessionOptions::default()
|
..SessionOptions::default()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
@ -109,7 +109,14 @@ async fn main() -> Result<()> {
|
||||||
match time::timeout(
|
match time::timeout(
|
||||||
Duration::from_secs(config.add_torrent_timeout),
|
Duration::from_secs(config.add_torrent_timeout),
|
||||||
session.add_torrent(
|
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 {
|
Some(AddTorrentOptions {
|
||||||
paused: true, // continue after `only_files` init
|
paused: true, // continue after `only_files` init
|
||||||
overwrite: true,
|
overwrite: true,
|
||||||
|
|
@ -227,7 +234,11 @@ async fn main() -> Result<()> {
|
||||||
&config.export_rss_title,
|
&config.export_rss_title,
|
||||||
&config.export_rss_link,
|
&config.export_rss_link,
|
||||||
&config.export_rss_description,
|
&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() {
|
for (k, v) in index.list() {
|
||||||
rss.push(
|
rss.push(
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ impl Trackers {
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.0.is_empty()
|
self.0.is_empty()
|
||||||
}
|
}
|
||||||
pub fn clone(&self) -> HashSet<Url> {
|
pub fn list(&self) -> &HashSet<Url> {
|
||||||
self.0.clone()
|
&self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue