refactor(streams): better syntax
@@ -104,22 +104,17 @@ impl Stream {
info_hash,
file_idx,
announce,
- ..
- } => streaming_server_url
+ } => Some(
+ streaming_server_url
.join(&format!("{}/", hex::encode(info_hash)))
- .map(|url| match file_idx {
+ .and_then(|url| match file_idx {
Some(idx) => url.join(&format!("{}/", idx)),
None => Ok(url),
})
- .map(|url| match url {
- Ok(url) => url.join(&format!("?tr={}", announce.join("&tr="))),
- _ => url,
- })
- .map(|url| match url {
- Ok(url) => Some(url.to_string()),
- _ => None,
- })
+ .and_then(|url| url.join(&format!("?tr={}", announce.join("&tr="))))
+ .map(|url| url.to_string())
.expect("Failed to build streaming url for torrent"),
+ ),
StreamSource::YouTube { yt_id } => {
Some(format!("{}yt/{}", streaming_server_url, yt_id))
}
