Skip to content

Commit 0aaacc0

Browse files
committed
fix(importer): incorrect trakt entries being imported
If a movie and show on trakt have the same ID (which happens very rarely), the importer was using an incorrect comparison to add entries to the seen history.
1 parent 1dac299 commit 0aaacc0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/services/importer/src/trakt.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,10 @@ pub async fn import(input: DeployTraktImportInput) -> Result<ImportResult> {
218218
show_episode_number,
219219
..Default::default()
220220
});
221-
if let Some(a) = media.iter_mut().find(|i| i.source_id == d.source_id) {
221+
if let Some(a) = media
222+
.iter_mut()
223+
.find(|i| i.identifier == d.identifier && i.lot == d.lot)
224+
{
222225
a.seen_history.extend(d.seen_history);
223226
} else {
224227
media.push(d)
@@ -235,9 +238,7 @@ pub async fn import(input: DeployTraktImportInput) -> Result<ImportResult> {
235238
})
236239
}
237240

238-
fn process_item(
239-
i: &ListItemResponse,
240-
) -> std::result::Result<ImportOrExportMediaItem, ImportFailedItem> {
241+
fn process_item(i: &ListItemResponse) -> Result<ImportOrExportMediaItem, ImportFailedItem> {
241242
let (source_id, identifier, lot) = if let Some(d) = i.movie.as_ref() {
242243
(d.ids.trakt, d.ids.tmdb, MediaLot::Movie)
243244
} else if let Some(d) = i.show.as_ref() {
@@ -251,10 +252,10 @@ fn process_item(
251252
});
252253
};
253254
match identifier {
254-
Some(i) => Ok(ImportOrExportMediaItem {
255+
Some(identifier) => Ok(ImportOrExportMediaItem {
255256
source_id: source_id.to_string(),
256257
lot,
257-
identifier: i.to_string(),
258+
identifier: identifier.to_string(),
258259
source: MediaSource::Tmdb,
259260
seen_history: vec![],
260261
reviews: vec![],

0 commit comments

Comments
 (0)