rvs76 / tvdblib

Automatically exported from code.google.com/p/tvdblib
0 stars 0 forks source link

Calling GetEpisode causes null point exception #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm using the latest 0.60 release and there is a nullpointer exception
thrown when i call GetEpisode(). This can be reproduced with one of the
code samples (TestForm.cs) also.

I tracked alleged bug down to function called  internal List<TvdbEpisode>
ExtractEpisodes(String _data). It looks like the
episode.Element("something") returns null and when you call .Value or
someother method the exception is thrown. 

Here is how i fix it: 
Combined_episodenumber = (episode.Element("Combined_episodenumber")!=null)
? (episode.Element("Combined_episodenumber").Value) : "",
Combined_season = episode.Element("Combined_season") != null ?
episode.Element("Combined_season").Value : "",
DVD_chapter = episode.Element("DVD_chapter") != null ?
episode.Element("DVD_chapter").Value : "",
DVD_discid = episode.Element("DVD_discid") != null ?
episode.Element("DVD_discid").Value : "",
DVD_episodenumber = episode.Element("DVD_episodenumber").Value,
DVD_season = episode.Elements("DVD_season") != null ?
episode.Elements("DVD_season").Count() == 1 ?
episode.Element("DVD_season").Value : episode.Element("DVD_Season").Value : "",
Director = episode.Element("Director") != null ?
episode.Element("Director").Value : "",
EpisodeName = episode.Element("EpisodeName") != null ?
episode.Element("EpisodeName").Value : "" ,
EpisodeNumber = episode.Element("EpisodeNumber") != null ?
episode.Element("EpisodeNumber").Value : "",
FirstAired = episode.Element("FirstAired") != null ?  
episode.Element("FirstAired").Value : "",
GuestStars = episode.Element("GuestStars") != null ?
episode.Element("GuestStars").Value : "",
IMDB_ID = episode.Element("IMDB_ID") !=null  ?
episode.Element("IMDB_ID").Value : "" ,
Language = episode.Elements("Language") != null ?
episode.Elements("Language").Count() == 1
? episode.Element("Language").Value : "en": "en",
Overview = episode.Element("Overview") != null ?
episode.Element("Overview").Value : "",
ProductionCode = episode.Element("ProductionCode")!= null ?
episode.Element("ProductionCode").Value : "",
Rating = episode.Element("Rating") != null ?
episode.Element("Rating").Value : "", 
SeasonNumber = episode.Element("SeasonNumber") != null ?
episode.Element("SeasonNumber").Value : "",
Writer = episode.Element("Writer") != null ?
episode.Element("Writer").Value : "",
absolute_number = episode.Element("absolute_number") != null ?
episode.Element("absolute_number").Value : "",
filename = episode.Element("filename") != null ?
episode.Element("filename").Value : "",
lastupdated = episode.Element("lastupdated") != null ?
episode.Element("lastupdated").Value :"",
seasonid = episode.Element("seasonid") != null ?
episode.Element("seasonid").Value : "",
seriesid = episode.Element("seriesid") != null ?
episode.Element("seriesid").Value : "",
airsafter_season = episode.Elements("airsafter_season") != null ?
episode.Elements("airsafter_season").Count() == 1
? episode.Element("airsafter_season").Value : "-99" : "-99",
airsbefore_episode = episode.Elements("airsbefore_episode") != null ?
episode.Elements("airsbefore_episode").Count() == 1
? episode.Element("airsbefore_episode").Value : "-99" : "-99",
airsbefore_season = episode.Elements("airsbefore_season") != null ?
episode.Elements("airsbefore_season").Count() == 1

ofcourse it could be something else and "fix" is not really a fix for it. 

Original issue reported on code.google.com by malep...@gmail.com on 7 Jun 2009 at 8:18

GoogleCodeExporter commented 9 years ago
this was fixed in svn a while ago, I just never got around creating a new 
version...

I fixed a few minor things in the current svn now, so I'll release a new version
today or tomorrow.

Original comment by bgmei...@gmail.com on 17 Jun 2009 at 4:06