Could use some better error handling for TVDB messups

Currently, Naruto Shippuuden is broken on the TVDB. Someone has created a new season 16 and put a bunch of episodes that already existed in season 15 in there without removing those episodes from season 15. Now when I search for the episode that came out today, 4 reports are found on my indexer. However, none of them start downloading or even show up if I do a manual search. In the logs I found “Sequence contains more than one matching element” which seems to indicate that Drone is confused about the multiple episodes with the same absolute number.

I don’t know if it’s worth doing so but maybe you can detect this and notify the user that this error occurred to prevent them from trying again and again when searching can never work this way.

The following is what my log says. I’m sorry, I can’t run mono in debug mode as long as I’m using the SynoCommunity package for it but I hope this will be enough info anyway.

14-6-19 17:46:32.7|Info|NzbSearchService|Searching 1 indexers for [Naruto Shippuuden : 366]
14-6-19 17:46:33.5|Info|FetchFeedService|Finished searching NZBS.in for [Naruto Shippuuden : 366]. Found 4
14-6-19 17:46:33.6|Info|DownloadDecisionMaker|Processing 4 reports
14-6-19 17:46:33.8|Error|Owin|System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in :0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in :0
14-6-19 17:46:33.9|Error|Owin|The page cannot be displayed because an internal server error has occurred.
14-6-19 17:46:34.0|Error|Owin|Exceptron.Client.ExceptronApiException: The page cannot be displayed because an internal server error has occurred. —> System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus (System.Net.WebAsyncResult result) [0x00000] in :0
at System.Net.HttpWebRequest.SetResponseData (System.Net.WebConnectionData data) [0x00000] in :0
— End of inner exception stack trace —
at Exceptron.Client.RestClient.Put[ExceptionResponse] (System.String url, System.Object content) [0x00000] in :0
at Exceptron.Client.ExceptronClient.SubmitException (Exceptron.Client.ExceptionData exceptionData) [0x00000] in :0 : Unable to submit exception to exceptron.
14-6-19 17:46:33.7|Error|DownloadDecisionMaker|Couldn’t process report.

System.InvalidOperationException: Sequence contains more than one matching element
at System.Linq.Enumerable.Single[Episode] (IEnumerable1 source, System.Func2 predicate, Fallback fallback) [0x00000] in :0
at System.Linq.Enumerable.SingleOrDefault[Episode] (IEnumerable`1 source) [0x00000] in :0
at NzbDrone.Core.Tv.EpisodeRepository.Find (Int32 seriesId, Int32 absoluteEpisodeNumber) [0x00000] in :0
at NzbDrone.Core.Tv.EpisodeService.FindEpisode (Int32 seriesId, Int32 absoluteEpisodeNumber) [0x00000] in :0
at NzbDrone.Core.Parser.ParsingService.GetEpisodes (NzbDrone.Core.Parser.Model.ParsedEpisodeInfo parsedEpisodeInfo, NzbDrone.Core.Tv.Series series, Boolean sceneSource, NzbDrone.Core.IndexerSearch.Definitions.SearchCriteriaBase searchCriteria) [0x00000] in :0
at NzbDrone.Core.Parser.ParsingService.Map (NzbDrone.Core.Parser.Model.ParsedEpisodeInfo parsedEpisodeInfo, Int32 tvRageId, NzbDrone.Core.IndexerSearch.Definitions.SearchCriteriaBase searchCriteria) [0x00000] in :0
at NzbDrone.Core.DecisionEngine.DownloadDecisionMaker+d__0.MoveNext () [0x00000] in :0

Oh TVDB… this is one of the reasons I didn’t want to use them for absolute numbering, but was forced to because specials can have absolute numbers (and not all of them do AFAIK).

Not sure how we want to handle this, so I’ll give it some thought.

It seems that the episodes in question had their absolute numbers removed from the season from which they are likely to be removed. Not sure if that is relevant to the problem but I thought I should mention it just in case it is.

It’s an edge case and as such not something that happens every day. I’ve seen it happen to Naruto 3 times now though, so it does happen from time to time.

As for solutions, I guess that catching the exception (and any other exception that might show up and break the search) and showing an error message that tells the user something is wrong with the episode/series and it can therefor not be searched for would do. Maybe with the suggestion to update the series info since the fix may already be on the TVDB by the time you get the error. However, I don’t think that would fit in the current error toasts, so I guess stuff like that would need a dialog.