feat: match RSS results by IMDb id (#99)
This commit was merged in pull request #99.
This commit is contained in:
@@ -72,6 +72,10 @@ pub struct SearchRelease {
|
||||
/// TMDB id the tracker attached to the item, when it attached one. An ID
|
||||
/// the indexer supplies beats anything read off the release name.
|
||||
pub tmdb_id: Option<u32>,
|
||||
/// `IMDb` id the tracker attached to the item, as it spelled it. Kept
|
||||
/// verbatim because definitions differ on the `tt` prefix and on the
|
||||
/// zero padding; matching (§6.2) normalises both sides.
|
||||
pub imdb_id: Option<String>,
|
||||
}
|
||||
|
||||
/// Results from one indexer in a multi-indexer search.
|
||||
@@ -283,6 +287,7 @@ struct ReleaseBuilder {
|
||||
link: Option<String>,
|
||||
enclosure_url: Option<String>,
|
||||
tmdb_id: Option<u32>,
|
||||
imdb_id: Option<String>,
|
||||
}
|
||||
|
||||
impl ReleaseBuilder {
|
||||
@@ -300,6 +305,7 @@ impl ReleaseBuilder {
|
||||
publish_date: self.publish_date,
|
||||
download_url,
|
||||
tmdb_id: self.tmdb_id,
|
||||
imdb_id: self.imdb_id,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -428,6 +434,12 @@ fn read_element_attributes(
|
||||
.filter(|&id| id != 0)
|
||||
.or(builder.tmdb_id);
|
||||
}
|
||||
Some("imdbid" | "imdb") => {
|
||||
builder.imdb_id = value
|
||||
.map(|value| value.trim().to_owned())
|
||||
.filter(|value| !value.is_empty())
|
||||
.or_else(|| builder.imdb_id.take());
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -760,6 +772,45 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
/// `imdbid` is the id most Cardigann definitions carry, and it is kept
|
||||
/// exactly as the tracker spelled it — matching normalises (§6.2).
|
||||
#[test]
|
||||
fn a_torznab_imdb_id_is_kept() {
|
||||
let body = br#"
|
||||
<rss version="2.0" xmlns:torznab="http://torznab.com/schemas/2015/feed">
|
||||
<channel>
|
||||
<item>
|
||||
<title>Dune.Part.Two.2024.2160p.WEB-DL</title>
|
||||
<guid>prefixed</guid>
|
||||
<link>https://indexer.invalid/download/prefixed</link>
|
||||
<torznab:attr name="imdbid" value="tt15239678"/>
|
||||
</item>
|
||||
<item>
|
||||
<title>Dune.2021.2160p.WEB-DL</title>
|
||||
<guid>bare</guid>
|
||||
<link>https://indexer.invalid/download/bare</link>
|
||||
<torznab:attr name="imdbid" value=" 1160419 "/>
|
||||
</item>
|
||||
<item>
|
||||
<title>Nosferatu.2024.2160p.WEB-DL</title>
|
||||
<guid>anonymous</guid>
|
||||
<link>https://indexer.invalid/download/anonymous</link>
|
||||
<torznab:attr name="imdbid" value=""/>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
"#;
|
||||
|
||||
let releases = parse_releases(3, body).expect("feed structure is valid");
|
||||
|
||||
assert_eq!(releases[0].imdb_id.as_deref(), Some("tt15239678"));
|
||||
assert_eq!(releases[1].imdb_id.as_deref(), Some("1160419"));
|
||||
assert_eq!(
|
||||
releases[2].imdb_id, None,
|
||||
"an empty attribute is the tracker saying it does not know"
|
||||
);
|
||||
}
|
||||
|
||||
/// A pack and one episode of that pack carry the same series title, so
|
||||
/// the tag on the release name is the only thing separating them.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user