[feature] support 40-byte infohash (not a magnet) as a way to add torrents
This commit is contained in:
parent
8d2aa93a78
commit
95f5a322f6
3 changed files with 23 additions and 2 deletions
|
|
@ -35,6 +35,16 @@ impl Magnet {
|
|||
|
||||
/// Parse a magnet link.
|
||||
pub fn parse(url: &str) -> anyhow::Result<Magnet> {
|
||||
if url.len() == 40 {
|
||||
if let Ok(id20) = Id20::from_str(url) {
|
||||
return Ok(Magnet {
|
||||
id20: Some(id20),
|
||||
id32: None,
|
||||
trackers: vec![],
|
||||
select_only: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
let url = url::Url::parse(url).context("magnet link must be a valid URL")?;
|
||||
if url.scheme() != "magnet" {
|
||||
anyhow::bail!("expected scheme magnet");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue