From df6aceaa96f20649b5d343c2f6c22cc5a4258cd2 Mon Sep 17 00:00:00 2001 From: Afonso Ramos Date: Mon, 7 Feb 2022 20:23:07 +0000 Subject: [PATCH] fix: rollback `imdb` option --- src/discord.rs | 10 ++++++++-- src/trakt.rs | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/discord.rs b/src/discord.rs index 02f47e0..7bd6592 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -57,7 +57,10 @@ impl Discord { .unwrap() ); media = "movies"; - link_imdb = format!("https://www.imdb.com/title/{}", movie.ids.imdb); + link_imdb = format!( + "https://www.imdb.com/title/{}", + movie.ids.imdb.as_ref().unwrap() + ); link_trakt = format!( "https://trakt.tv/{}/{}", media, @@ -70,7 +73,10 @@ impl Discord { details = show.title.to_string(); state = format!("S{}E{} - {}", episode.season, episode.number, episode.title); media = "shows"; - link_imdb = format!("https://www.imdb.com/title/{}", show.ids.imdb); + link_imdb = format!( + "https://www.imdb.com/title/{}", + show.ids.imdb.as_ref().unwrap() + ); link_trakt = format!( "https://trakt.tv/{}/{}", media, diff --git a/src/trakt.rs b/src/trakt.rs index 9db2232..1b1b7ab 100644 --- a/src/trakt.rs +++ b/src/trakt.rs @@ -29,7 +29,7 @@ pub struct TraktIds { pub trakt: u32, pub slug: Option, pub tvdb: Option, - pub imdb: String, + pub imdb: Option, pub tmdb: Option, pub tvrage: Option, } @@ -86,9 +86,14 @@ impl Trakt { .into_string() .unwrap(); + println!("{}", response); + match serde_json::from_str(&response) { Ok(response) => Some(response), - Err(_) => None, + Err(err) => { + println!("{}", err); + None + } } }