diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5546331
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# tvdblib
+GitHub clone of SVN repo http://tvdblib.googlecode.com/svn/trunk/ (cloned by http://svn2github.com/)
+
+Changelog
+- TvdbSearchResult supports an AliasNames which was missing from the TvdbSearchResult class.
diff --git a/TvdbLib/Data/TvdbSearchResult.cs b/TvdbLib/Data/TvdbSearchResult.cs
index 75c75ef..c931d00 100644
--- a/TvdbLib/Data/TvdbSearchResult.cs
+++ b/TvdbLib/Data/TvdbSearchResult.cs
@@ -26,102 +26,106 @@
namespace TvdbLib.Data
{
- ///
- /// Class representing the result of a tvdb name query -> for further information
- /// visit http://thetvdb.com/wiki/index.php/API:GetSeries
- ///
- public class TvdbSearchResult
- {
///
- /// TvdbSearchResult constructor
+ /// Class representing the result of a tvdb name query -> for further information
+ /// visit http://thetvdb.com/wiki/index.php/API:GetSeries
///
- public TvdbSearchResult()
+ public class TvdbSearchResult
{
+ ///
+ /// TvdbSearchResult constructor
+ ///
+ public TvdbSearchResult()
+ {
- }
+ }
- ///
- /// TvdbSearchResult constructor
- ///
- /// Id of series
- public TvdbSearchResult(int _id)
- {
- m_id = _id;
- }
+ ///
+ /// TvdbSearchResult constructor
+ ///
+ /// Id of series
+ public TvdbSearchResult(int _id)
+ {
+ m_id = _id;
+ }
- #region private properties
- private int m_id;
- private String m_seriesName;
- private DateTime m_firstAired;
- private TvdbLanguage m_language;
- private String m_overview;
- private TvdbSeriesBanner m_banner;
- private String m_imdbId;
- #endregion
+ #region private properties
+ private int m_id;
+ private String m_seriesName;
+ private DateTime m_firstAired;
+ private TvdbLanguage m_language;
+ private String m_overview;
+ private TvdbSeriesBanner m_banner;
+ private String m_imdbId;
+ #endregion
- #region tvdb properties
- ///
- /// Id of the returned series
- ///
- public int Id
- {
- get { return m_id; }
- set { m_id = value; }
- }
+ #region tvdb properties
+ ///
+ /// Id of the returned series
+ ///
+ public int Id
+ {
+ get { return m_id; }
+ set { m_id = value; }
+ }
- ///
- /// Name of the returned series
- ///
- public String SeriesName
- {
- get { return m_seriesName; }
- set { m_seriesName = value; }
- }
+ ///
+ /// Name of the returned series
+ ///
+ public String SeriesName
+ {
+ get { return m_seriesName; }
+ set { m_seriesName = value; }
+ }
+ ///
+ /// AliasNames
+ ///
+ public List AliasNames { get; set; }
- ///
- /// When was the returned series aired first
- ///
- public DateTime FirstAired
- {
- get { return m_firstAired; }
- set { m_firstAired = value; }
- }
+ ///
+ /// When was the returned series aired first
+ ///
+ public DateTime FirstAired
+ {
+ get { return m_firstAired; }
+ set { m_firstAired = value; }
+ }
- ///
- /// Language of the returned series
- ///
- public TvdbLanguage Language
- {
- get { return m_language; }
- set { m_language = value; }
- }
+ ///
+ /// Language of the returned series
+ ///
+ public TvdbLanguage Language
+ {
+ get { return m_language; }
+ set { m_language = value; }
+ }
- ///
- /// Overview of the returned series
- ///
- public String Overview
- {
- get { return m_overview; }
- set { m_overview = value; }
- }
+ ///
+ /// Overview of the returned series
+ ///
+ public String Overview
+ {
+ get { return m_overview; }
+ set { m_overview = value; }
+ }
- ///
- /// Banner of the returned series
- ///
- public TvdbSeriesBanner Banner
- {
- get { return m_banner; }
- set { m_banner = value; }
- }
+ ///
+ /// Banner of the returned series
+ ///
+ public TvdbSeriesBanner Banner
+ {
+ get { return m_banner; }
+ set { m_banner = value; }
+ }
- ///
- /// Imdb id of the returned series
- ///
- public String ImdbId
- {
- get { return m_imdbId;}
- set { m_imdbId = value; }
+ ///
+ /// Imdb id of the returned series
+ ///
+ public String ImdbId
+ {
+ get { return m_imdbId; }
+ set { m_imdbId = value; }
+ }
+ #endregion
}
- #endregion
- }
}
diff --git a/TvdbLib/Xml/TvdbXmlReader.cs b/TvdbLib/Xml/TvdbXmlReader.cs
index 7b412e5..e455881 100644
--- a/TvdbLib/Xml/TvdbXmlReader.cs
+++ b/TvdbLib/Xml/TvdbXmlReader.cs
@@ -30,1015 +30,1017 @@
namespace TvdbLib.Xml
{
- ///
- /// Class for parsing the xml info from thetvdb
- ///
- internal class TvdbXmlReader
- {
///
- /// Base constructor for a TvdbXmlReader class
+ /// Class for parsing the xml info from thetvdb
///
- internal TvdbXmlReader()
+ internal class TvdbXmlReader
{
-
- }
-
- ///
- /// Extract a list of languages when the data has the format:
- ///
- ///
- ///
- /// Español
- /// es
- /// 16
- ///
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractLanguages(String _data)
- {
- XDocument xml = XDocument.Parse(_data);
-
- var allLanguages = from language in xml.Descendants("Language")
- select new
- {
- name = language.Element("name").Value,
- abbreviation = language.Element("abbreviation").Value,
- id = language.Element("id").Value
- };
-
- List retList = new List();
- foreach (var l in allLanguages)
- {
- TvdbLanguage lang = new TvdbLanguage();
- lang.Name = l.name;
- lang.Abbriviation = l.abbreviation;
- lang.Id = Util.Int32Parse(l.id);
-
- if (lang.Id != -99) retList.Add(lang);
- }
- return retList;
- }
-
- ///
- /// Extract a list of mirrors if the data has the format:
- ///
- ///
- ///
- /// 1
- /// http://thetvdb.com
- /// 7
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- [Obsolete("Not used any more, however if won't delete the class since it could be useful at some point")]
- internal List ExtractMirrors(String _data)
- {
- XDocument xml = XDocument.Parse(_data);
-
- var allLanguages = from language in xml.Descendants("Mirror")
- select new
- {
- typemask = language.Element("typemask").Value,
- mirrorpath = language.Element("mirrorpath").Value,
- id = language.Element("id").Value
- };
-
- List retList = new List();
- foreach (var l in allLanguages)
- {
- TvdbMirror lang = new TvdbMirror();
- lang.MirrorPath = new Uri(l.mirrorpath);
- lang.TypeMask = Util.Int32Parse(l.typemask);
- lang.Id = Util.Int32Parse(l.id);
-
- if (lang.Id != -99) retList.Add(lang);
- }
- return retList;
- }
-
- ///
- /// Extract a list of series in the format:
- ///
- ///
- ///
- /// 73739
- /// |Malcolm David Kelley|Jorge Garcia|Maggie Grace|...|
- /// Thursday
- /// 9:00 PM
- /// TV-14
- /// 2004-09-22
- /// |Action and Adventure|Drama|Science-Fiction|
- /// tt0411008
- /// en
- /// ABC
- /// After Oceanic Air flight 815...
- /// 8.9
- /// 60
- /// 24313
- /// Lost
- /// Continuing
- /// graphical/24313-g2.jpg
- /// fanart/original/73739-1.jpg
- /// 1205694666
- /// SH672362
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractSeries(String _data)
- {
-
- List tvdbInfo = ExtractSeriesFields(_data);
- List retList = new List();
- foreach (TvdbSeriesFields s in tvdbInfo)
- {
- TvdbSeries series = new TvdbSeries(s);
-
- if (!series.BannerPath.Equals(""))
+ ///
+ /// Base constructor for a TvdbXmlReader class
+ ///
+ internal TvdbXmlReader()
{
- series.Banners.Add(new TvdbSeriesBanner(series.Id, series.BannerPath, series.Language, TvdbSeriesBanner.Type.graphical));
+
}
- if (!series.FanartPath.Equals(""))
+ ///
+ /// Extract a list of languages when the data has the format:
+ ///
+ ///
+ ///
+ /// Español
+ /// es
+ /// 16
+ ///
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractLanguages(String _data)
{
- series.Banners.Add(new TvdbFanartBanner(series.Id, series.FanartPath, series.Language));
+ XDocument xml = XDocument.Parse(_data);
+
+ var allLanguages = from language in xml.Descendants("Language")
+ select new
+ {
+ name = language.Element("name").Value,
+ abbreviation = language.Element("abbreviation").Value,
+ id = language.Element("id").Value
+ };
+
+ List retList = new List();
+ foreach (var l in allLanguages)
+ {
+ TvdbLanguage lang = new TvdbLanguage();
+ lang.Name = l.name;
+ lang.Abbriviation = l.abbreviation;
+ lang.Id = Util.Int32Parse(l.id);
+
+ if (lang.Id != -99) retList.Add(lang);
+ }
+ return retList;
}
- if (!series.PosterPath.Equals(""))
+ ///
+ /// Extract a list of mirrors if the data has the format:
+ ///
+ ///
+ ///
+ /// 1
+ /// http://thetvdb.com
+ /// 7
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ [Obsolete("Not used any more, however if won't delete the class since it could be useful at some point")]
+ internal List ExtractMirrors(String _data)
{
- series.Banners.Add(new TvdbPosterBanner(series.Id, series.PosterPath, series.Language));
+ XDocument xml = XDocument.Parse(_data);
+
+ var allLanguages = from language in xml.Descendants("Mirror")
+ select new
+ {
+ typemask = language.Element("typemask").Value,
+ mirrorpath = language.Element("mirrorpath").Value,
+ id = language.Element("id").Value
+ };
+
+ List retList = new List();
+ foreach (var l in allLanguages)
+ {
+ TvdbMirror lang = new TvdbMirror();
+ lang.MirrorPath = new Uri(l.mirrorpath);
+ lang.TypeMask = Util.Int32Parse(l.typemask);
+ lang.Id = Util.Int32Parse(l.id);
+
+ if (lang.Id != -99) retList.Add(lang);
+ }
+ return retList;
}
- retList.Add(series);
- }
- return retList;
- }
-
- ///
- /// Extract all the series fields that are available on thetvdb
- ///
- ///
- ///
- /// 73739
- /// |Malcolm David Kelley|Jorge Garcia|Maggie Grace|...|
- /// Thursday
- /// 9:00 PM
- /// TV-14
- /// 2004-09-22
- /// |Action and Adventure|Drama|Science-Fiction|
- /// tt0411008
- /// en
- /// ABC
- /// After Oceanic Air flight 815...
- /// 8.9
- /// 60
- /// 24313
- /// Lost
- /// Continuing
- /// graphical/24313-g2.jpg
- /// fanart/original/73739-1.jpg
- /// 1205694666
- /// SH672362
- ///
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractSeriesFields(String _data)
- {
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
- XDocument xml = XDocument.Parse(_data);
-
- var allSeries = from series in xml.Descendants("Series")
- select new
- {
- Id = series.Element("id").Value,
- Actors = series.Element("Actors").Value,
- Airs_DayOfWeek = series.Element("Airs_DayOfWeek").Value,
- Airs_Time = series.Element("Airs_Time").Value,
- ContentRating = series.Element("ContentRating").Value,
- FirstAired = series.Element("FirstAired").Value,
- Genre = series.Element("Genre").Value,
- IMDB_ID = series.Element("IMDB_ID").Value,
- Language = series.Element("Language").Value,
- Network = series.Element("Network").Value,
- Overview = series.Element("Overview").Value,
- Rating = series.Element("Rating").Value,
- Runtime = series.Element("Runtime").Value,
- SeriesID = series.Element("SeriesID").Value,
- SeriesName = series.Element("SeriesName").Value,
- Status = series.Element("Status").Value,
- banner = series.Elements("banner").Count() == 1 ? series.Element("banner").Value : "",
- fanart = series.Elements("fanart").Count() == 1 ? series.Element("fanart").Value : "",
- poster = series.Elements("poster").Count() == 1 ? series.Element("poster").Value : "",
- lastupdated = series.Element("lastupdated").Value,
- zap2it_id = series.Element("zap2it_id").Value
- };
-
- List retList = new List();
- foreach (var s in allSeries)
- {
- TvdbSeriesFields series = new TvdbSeriesFields();
- series.Id = Util.Int32Parse(s.Id);
- series.Actors = Util.SplitTvdbString(s.Actors);
- series.AirsDayOfWeek = Util.GetDayOfWeek(s.Airs_DayOfWeek);
- series.AirsTime = s.Airs_Time;
- series.ContentRating = s.ContentRating;
- series.FirstAired = Util.ParseDateTime(s.FirstAired);
- series.Genre = Util.SplitTvdbString(s.Genre);
- series.ImdbId = s.IMDB_ID;
- series.Language = Util.ParseLanguage(s.Language);
- series.Network = s.Network;
- series.Overview = s.Overview;
- series.Rating = Util.DoubleParse(s.Rating);
- series.Runtime = Util.DoubleParse(s.Runtime);
- series.TvDotComId = Util.Int32Parse(s.SeriesID);
- series.SeriesName = s.SeriesName;
- series.Status = s.Status;
- series.BannerPath = s.banner;
- series.FanartPath = s.fanart;
- series.PosterPath = s.poster;
- series.LastUpdated = Util.UnixToDotNet(s.lastupdated);
- series.Zap2itId = s.zap2it_id;
- if (series.Id != -99) retList.Add(series);
- }
-
- //watch.Stop();
- //Log.Debug("Extracted " + retList.Count + " series in " + watch.ElapsedMilliseconds + " milliseconds");
- return retList;
- }
- ///
- /// Extract a list of episodes from the given data when the data has the following format:
- ///
- ///
- /// 332179
- ///
- ///
- ///
- ///
- /// |Joseph McGinty Nichol|
- /// Chuck Versus the World
- /// 1
- /// 2007-09-24
- /// |Julia Ling|Vik Sahay|Mieko Hillman|
- ///
- /// English
- /// Chuck Bartowski is an average computer geek...
- ///
- /// 9.0
- /// 1
- /// |Josh Schwartz|Chris Fedak|
- ///
- ///
- ///
- ///
- /// episodes/80348-332179.jpg
- /// 1201292806
- /// 27985
- /// 80348
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractEpisodes(String _data)
- {
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
- XDocument xml = XDocument.Parse(_data);
- var allEpisodes = from episode in xml.Descendants("Episode")
- select new
- {
- Id = episode.Element("id").Value,
- Combined_episodenumber = episode.Elements("Combined_episodenumber").Count() == 1
- ? episode.Element("Combined_episodenumber").Value : "0",
- Combined_season = episode.Elements("Combined_season").Count() == 1
- ? episode.Element("Combined_season").Value : "0",
- DVD_chapter = episode.Element("DVD_chapter").Value,
- DVD_discid = episode.Element("DVD_discid").Value,
- DVD_episodenumber = episode.Element("DVD_episodenumber").Value,
- DVD_season = episode.Elements("DVD_season").Count() == 1
- ? episode.Element("DVD_season").Value : episode.Element("DVD_Season").Value,
- Director = episode.Element("Director").Value,
- EpisodeName = episode.Element("EpisodeName").Value,
- EpisodeNumber = episode.Element("EpisodeNumber").Value,
- FirstAired = episode.Element("FirstAired").Value,
- GuestStars = episode.Element("GuestStars").Value,
- IMDB_ID = episode.Element("IMDB_ID").Value,
- Language = episode.Elements("Language").Count() == 1
- ? episode.Element("Language").Value : "en",
- Overview = episode.Element("Overview").Value,
- ProductionCode = episode.Element("ProductionCode").Value,
- Rating = episode.Element("Rating").Value,
- SeasonNumber = episode.Element("SeasonNumber").Value,
- Writer = episode.Element("Writer").Value,
- absolute_number = episode.Element("absolute_number").Value,
- filename = episode.Element("filename").Value,
- lastupdated = episode.Element("lastupdated").Value,
- seasonid = episode.Element("seasonid").Value,
- seriesid = episode.Element("seriesid").Value,
- airsafter_season = episode.Elements("airsafter_season").Count() == 1
- ? episode.Element("airsafter_season").Value : "-99",
- airsbefore_episode = episode.Elements("airsbefore_episode").Count() == 1
- ? episode.Element("airsbefore_episode").Value : "-99",
- airsbefore_season = episode.Elements("airsbefore_season").Count() == 1
- ? episode.Element("airsbefore_season").Value : "-99"
- };
- //Log.Debug("Parsed xml file in " + watch.ElapsedMilliseconds + " milliseconds");
- List retList = new List();
- foreach (var e in allEpisodes)
- {
- TvdbEpisode ep = new TvdbEpisode();
- ep.Id = Util.Int32Parse(e.Id);
- ep.CombinedEpisodeNumber = Util.DoubleParse(e.Combined_episodenumber);
- ep.CombinedSeason = Util.DoubleParse(e.Combined_season);
- ep.DvdChapter = Util.Int32Parse(e.DVD_chapter);
- ep.DvdDiscId = Util.Int32Parse(e.DVD_discid);
- ep.DvdEpisodeNumber = Util.DoubleParse(e.DVD_episodenumber);
- ep.DvdSeason = Util.Int32Parse(e.DVD_season);
- ep.Directors = Util.SplitTvdbString(e.Director);
- ep.EpisodeName = e.EpisodeName;
- ep.EpisodeNumber = Util.Int32Parse(e.EpisodeNumber);
- ep.AirsAfterSeason = Util.Int32Parse(e.airsafter_season);
- ep.AirsBeforeEpisode = Util.Int32Parse(e.airsbefore_episode);
- ep.AirsBeforeSeason = Util.Int32Parse(e.airsbefore_season);
- try
+ ///
+ /// Extract a list of series in the format:
+ ///
+ ///
+ ///
+ /// 73739
+ /// |Malcolm David Kelley|Jorge Garcia|Maggie Grace|...|
+ /// Thursday
+ /// 9:00 PM
+ /// TV-14
+ /// 2004-09-22
+ /// |Action and Adventure|Drama|Science-Fiction|
+ /// tt0411008
+ /// en
+ /// ABC
+ /// After Oceanic Air flight 815...
+ /// 8.9
+ /// 60
+ /// 24313
+ /// Lost
+ /// Continuing
+ /// graphical/24313-g2.jpg
+ /// fanart/original/73739-1.jpg
+ /// 1205694666
+ /// SH672362
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractSeries(String _data)
{
- ep.FirstAired = e.FirstAired.Equals("") ? new DateTime(1, 1, 1) : DateTime.Parse(e.FirstAired);
+
+ List tvdbInfo = ExtractSeriesFields(_data);
+ List retList = new List();
+ foreach (TvdbSeriesFields s in tvdbInfo)
+ {
+ TvdbSeries series = new TvdbSeries(s);
+
+ if (!series.BannerPath.Equals(""))
+ {
+ series.Banners.Add(new TvdbSeriesBanner(series.Id, series.BannerPath, series.Language, TvdbSeriesBanner.Type.graphical));
+ }
+
+ if (!series.FanartPath.Equals(""))
+ {
+ series.Banners.Add(new TvdbFanartBanner(series.Id, series.FanartPath, series.Language));
+ }
+
+ if (!series.PosterPath.Equals(""))
+ {
+ series.Banners.Add(new TvdbPosterBanner(series.Id, series.PosterPath, series.Language));
+ }
+ retList.Add(series);
+ }
+ return retList;
}
- catch (Exception)
+
+ ///
+ /// Extract all the series fields that are available on thetvdb
+ ///
+ ///
+ ///
+ /// 73739
+ /// |Malcolm David Kelley|Jorge Garcia|Maggie Grace|...|
+ /// Thursday
+ /// 9:00 PM
+ /// TV-14
+ /// 2004-09-22
+ /// |Action and Adventure|Drama|Science-Fiction|
+ /// tt0411008
+ /// en
+ /// ABC
+ /// After Oceanic Air flight 815...
+ /// 8.9
+ /// 60
+ /// 24313
+ /// Lost
+ /// Continuing
+ /// graphical/24313-g2.jpg
+ /// fanart/original/73739-1.jpg
+ /// 1205694666
+ /// SH672362
+ ///
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractSeriesFields(String _data)
{
- ep.FirstAired = new DateTime();
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
+ XDocument xml = XDocument.Parse(_data);
+
+ var allSeries = from series in xml.Descendants("Series")
+ select new
+ {
+ Id = series.Element("id").Value,
+ Actors = series.Element("Actors").Value,
+ Airs_DayOfWeek = series.Element("Airs_DayOfWeek").Value,
+ Airs_Time = series.Element("Airs_Time").Value,
+ ContentRating = series.Element("ContentRating").Value,
+ FirstAired = series.Element("FirstAired").Value,
+ Genre = series.Element("Genre").Value,
+ IMDB_ID = series.Element("IMDB_ID").Value,
+ Language = series.Element("Language").Value,
+ Network = series.Element("Network").Value,
+ Overview = series.Element("Overview").Value,
+ Rating = series.Element("Rating").Value,
+ Runtime = series.Element("Runtime").Value,
+ SeriesID = series.Element("SeriesID").Value,
+ SeriesName = series.Element("SeriesName").Value,
+ Status = series.Element("Status").Value,
+ banner = series.Elements("banner").Count() == 1 ? series.Element("banner").Value : "",
+ fanart = series.Elements("fanart").Count() == 1 ? series.Element("fanart").Value : "",
+ poster = series.Elements("poster").Count() == 1 ? series.Element("poster").Value : "",
+ lastupdated = series.Element("lastupdated").Value,
+ zap2it_id = series.Element("zap2it_id").Value
+ };
+
+ List retList = new List();
+ foreach (var s in allSeries)
+ {
+ TvdbSeriesFields series = new TvdbSeriesFields();
+ series.Id = Util.Int32Parse(s.Id);
+ series.Actors = Util.SplitTvdbString(s.Actors);
+ series.AirsDayOfWeek = Util.GetDayOfWeek(s.Airs_DayOfWeek);
+ series.AirsTime = s.Airs_Time;
+ series.ContentRating = s.ContentRating;
+ series.FirstAired = Util.ParseDateTime(s.FirstAired);
+ series.Genre = Util.SplitTvdbString(s.Genre);
+ series.ImdbId = s.IMDB_ID;
+ series.Language = Util.ParseLanguage(s.Language);
+ series.Network = s.Network;
+ series.Overview = s.Overview;
+ series.Rating = Util.DoubleParse(s.Rating);
+ series.Runtime = Util.DoubleParse(s.Runtime);
+ series.TvDotComId = Util.Int32Parse(s.SeriesID);
+ series.SeriesName = s.SeriesName;
+ series.Status = s.Status;
+ series.BannerPath = s.banner;
+ series.FanartPath = s.fanart;
+ series.PosterPath = s.poster;
+ series.LastUpdated = Util.UnixToDotNet(s.lastupdated);
+ series.Zap2itId = s.zap2it_id;
+ if (series.Id != -99) retList.Add(series);
+ }
+
+ //watch.Stop();
+ //Log.Debug("Extracted " + retList.Count + " series in " + watch.ElapsedMilliseconds + " milliseconds");
+ return retList;
}
- ep.GuestStars = Util.SplitTvdbString(e.GuestStars);
- ep.ImdbId = e.IMDB_ID;
- ep.Language = Util.ParseLanguage(e.Language);
- ep.Overview = e.Overview;
- ep.ProductionCode = e.ProductionCode;
- ep.Rating = Util.DoubleParse(e.Rating);
- ep.SeasonNumber = Util.Int32Parse(e.SeasonNumber);
- ep.Writer = Util.SplitTvdbString(e.Writer);
- ep.AbsoluteNumber = Util.Int32Parse(e.absolute_number);
- ep.BannerPath = e.filename;
- ep.Banner = new TvdbEpisodeBanner(ep.Id, ep.BannerPath);
- ep.LastUpdated = Util.UnixToDotNet(e.lastupdated);
- ep.SeasonId = Util.Int32Parse(e.seasonid);
- ep.SeriesId = Util.Int32Parse(e.seriesid);
-
- if (ep.Id != -99) retList.Add(ep);
- }
-
- //watch.Stop();
- //Log.Debug("Extracted " + retList.Count + " Episodes in " + watch.ElapsedMilliseconds + " milliseconds");
- return retList;
-
- }
- ///
- /// Extract list of updated series
- ///
- ///
- ///
- /// 71969
- ///
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractSeriesUpdates(String _data)
- {
+ ///
+ /// Extract a list of episodes from the given data when the data has the following format:
+ ///
+ ///
+ /// 332179
+ ///
+ ///
+ ///
+ ///
+ /// |Joseph McGinty Nichol|
+ /// Chuck Versus the World
+ /// 1
+ /// 2007-09-24
+ /// |Julia Ling|Vik Sahay|Mieko Hillman|
+ ///
+ /// English
+ /// Chuck Bartowski is an average computer geek...
+ ///
+ /// 9.0
+ /// 1
+ /// |Josh Schwartz|Chris Fedak|
+ ///
+ ///
+ ///
+ ///
+ /// episodes/80348-332179.jpg
+ /// 1201292806
+ /// 27985
+ /// 80348
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractEpisodes(String _data)
+ {
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
+ XDocument xml = XDocument.Parse(_data);
+ var allEpisodes = from episode in xml.Descendants("Episode")
+ select new
+ {
+ Id = episode.Element("id").Value,
+ Combined_episodenumber = episode.Elements("Combined_episodenumber").Count() == 1
+ ? episode.Element("Combined_episodenumber").Value : "0",
+ Combined_season = episode.Elements("Combined_season").Count() == 1
+ ? episode.Element("Combined_season").Value : "0",
+ DVD_chapter = episode.Element("DVD_chapter").Value,
+ DVD_discid = episode.Element("DVD_discid").Value,
+ DVD_episodenumber = episode.Element("DVD_episodenumber").Value,
+ DVD_season = episode.Elements("DVD_season").Count() == 1
+ ? episode.Element("DVD_season").Value : episode.Element("DVD_Season").Value,
+ Director = episode.Element("Director").Value,
+ EpisodeName = episode.Element("EpisodeName").Value,
+ EpisodeNumber = episode.Element("EpisodeNumber").Value,
+ FirstAired = episode.Element("FirstAired").Value,
+ GuestStars = episode.Element("GuestStars").Value,
+ IMDB_ID = episode.Element("IMDB_ID").Value,
+ Language = episode.Elements("Language").Count() == 1
+ ? episode.Element("Language").Value : "en",
+ Overview = episode.Element("Overview").Value,
+ ProductionCode = episode.Element("ProductionCode").Value,
+ Rating = episode.Element("Rating").Value,
+ SeasonNumber = episode.Element("SeasonNumber").Value,
+ Writer = episode.Element("Writer").Value,
+ absolute_number = episode.Element("absolute_number").Value,
+ filename = episode.Element("filename").Value,
+ lastupdated = episode.Element("lastupdated").Value,
+ seasonid = episode.Element("seasonid").Value,
+ seriesid = episode.Element("seriesid").Value,
+ airsafter_season = episode.Elements("airsafter_season").Count() == 1
+ ? episode.Element("airsafter_season").Value : "-99",
+ airsbefore_episode = episode.Elements("airsbefore_episode").Count() == 1
+ ? episode.Element("airsbefore_episode").Value : "-99",
+ airsbefore_season = episode.Elements("airsbefore_season").Count() == 1
+ ? episode.Element("airsbefore_season").Value : "-99"
+ };
+ //Log.Debug("Parsed xml file in " + watch.ElapsedMilliseconds + " milliseconds");
+ List retList = new List();
+ foreach (var e in allEpisodes)
+ {
+ TvdbEpisode ep = new TvdbEpisode();
+ ep.Id = Util.Int32Parse(e.Id);
+ ep.CombinedEpisodeNumber = Util.DoubleParse(e.Combined_episodenumber);
+ ep.CombinedSeason = Util.DoubleParse(e.Combined_season);
+ ep.DvdChapter = Util.Int32Parse(e.DVD_chapter);
+ ep.DvdDiscId = Util.Int32Parse(e.DVD_discid);
+ ep.DvdEpisodeNumber = Util.DoubleParse(e.DVD_episodenumber);
+ ep.DvdSeason = Util.Int32Parse(e.DVD_season);
+ ep.Directors = Util.SplitTvdbString(e.Director);
+ ep.EpisodeName = e.EpisodeName;
+ ep.EpisodeNumber = Util.Int32Parse(e.EpisodeNumber);
+ ep.AirsAfterSeason = Util.Int32Parse(e.airsafter_season);
+ ep.AirsBeforeEpisode = Util.Int32Parse(e.airsbefore_episode);
+ ep.AirsBeforeSeason = Util.Int32Parse(e.airsbefore_season);
+ try
+ {
+ ep.FirstAired = e.FirstAired.Equals("") ? new DateTime(1, 1, 1) : DateTime.Parse(e.FirstAired);
+ }
+ catch (Exception)
+ {
+ ep.FirstAired = new DateTime();
+ }
+ ep.GuestStars = Util.SplitTvdbString(e.GuestStars);
+ ep.ImdbId = e.IMDB_ID;
+ ep.Language = Util.ParseLanguage(e.Language);
+ ep.Overview = e.Overview;
+ ep.ProductionCode = e.ProductionCode;
+ ep.Rating = Util.DoubleParse(e.Rating);
+ ep.SeasonNumber = Util.Int32Parse(e.SeasonNumber);
+ ep.Writer = Util.SplitTvdbString(e.Writer);
+ ep.AbsoluteNumber = Util.Int32Parse(e.absolute_number);
+ ep.BannerPath = e.filename;
+ ep.Banner = new TvdbEpisodeBanner(ep.Id, ep.BannerPath);
+ ep.LastUpdated = Util.UnixToDotNet(e.lastupdated);
+ ep.SeasonId = Util.Int32Parse(e.seasonid);
+ ep.SeriesId = Util.Int32Parse(e.seriesid);
+
+ if (ep.Id != -99) retList.Add(ep);
+ }
+
+ //watch.Stop();
+ //Log.Debug("Extracted " + retList.Count + " Episodes in " + watch.ElapsedMilliseconds + " milliseconds");
+ return retList;
- XDocument xml = XDocument.Parse(_data);
+ }
- var allSeries = from series in xml.Descendants("Series")
- where series.HasElements == true
- select new TvdbSeries
- {
- Id = Util.Int32Parse(series.Element("id").Value),
- LastUpdated = Util.UnixToDotNet(series.Element("time").Value)
- };
+ ///
+ /// Extract list of updated series
+ ///
+ ///
+ ///
+ /// 71969
+ ///
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractSeriesUpdates(String _data)
+ {
- List retList = new List();
- foreach (TvdbSeries s in allSeries)
- {
- if (s != null && s.Id != -99) retList.Add(s);
- }
+ XDocument xml = XDocument.Parse(_data);
- return retList;
- }
+ var allSeries = from series in xml.Descendants("Series")
+ where series.HasElements == true
+ select new TvdbSeries
+ {
+ Id = Util.Int32Parse(series.Element("id").Value),
+ LastUpdated = Util.UnixToDotNet(series.Element("time").Value)
+ };
- ///
- /// Extract the results of a series search with format:
- ///
- ///
- ///
- /// 73739
- /// en
- /// Lost
- /// graphical/24313-g2.jpg
- /// After Oceanic Air flight 815...
- /// 2004-09-22
- /// tt0411008
- /// SH672362
- /// 73739
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractSeriesSearchResults(String _data)
- {
+ List retList = new List();
+ foreach (TvdbSeries s in allSeries)
+ {
+ if (s != null && s.Id != -99) retList.Add(s);
+ }
- XDocument xml = XDocument.Parse(_data);
-
- var allSeries = from series in xml.Descendants("Series")
- where series.HasElements == true
- select new
- {
- Id = Util.Int32Parse(series.Element("seriesid").Value),
- FirstAired = series.Element("FirstAired") != null ? series.Element("FirstAired").Value : "",
- Language = series.Element("language") != null ? series.Element("language").Value : "",
- Overview = series.Element("Overview") != null ? series.Element("Overview").Value : "",
- SeriesName = series.Element("SeriesName") != null ? series.Element("SeriesName").Value : "",
- IMDB_ID = series.Element("IMDB_ID") != null ? series.Element("IMDB_ID").Value : "",
- BannerPath = series.Element("banner") != null ? series.Element("banner").Value : ""
- };
-
- List retList = new List();
- foreach (var s in allSeries)
- {
- TvdbSearchResult res = new TvdbSearchResult();
- res.Id = s.Id;
- res.ImdbId = s.IMDB_ID;
- if (!s.FirstAired.Equals("")) res.FirstAired = DateTime.Parse(s.FirstAired);
- if (!s.Language.Equals("")) res.Language = Util.ParseLanguage(s.Language);
- res.SeriesName = s.SeriesName;
- res.Overview = s.Overview;
- if (!s.BannerPath.Equals(""))
- {
- res.Banner = new TvdbSeriesBanner(0, s.BannerPath, null, TvdbSeriesBanner.Type.none);
+ return retList;
}
- else
- {
- res.Banner = new TvdbSeriesBanner(s.Id, null, null, TvdbSeriesBanner.Type.none);
- }
- retList.Add(res);
- }
- return retList;
- }
+ ///
+ /// Extract the results of a series search with format:
+ ///
+ ///
+ ///
+ /// 73739
+ /// en
+ /// Lost
+ /// graphical/24313-g2.jpg
+ /// After Oceanic Air flight 815...
+ /// 2004-09-22
+ /// tt0411008
+ /// SH672362
+ /// 73739
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractSeriesSearchResults(String _data)
+ {
- ///
- /// Exctract the series favorites
- ///
- ///
- /// 73067
- /// 78957
- /// 75340
- /// 72218
- /// 73244
- /// 75397
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractSeriesFavorites(String _data)
- {
+ XDocument xml = XDocument.Parse(_data);
+
+ var allSeries = from series in xml.Descendants("Series")
+ where series.HasElements == true
+ select new
+ {
+ Id = Util.Int32Parse(series.Element("seriesid").Value),
+ FirstAired = series.Element("FirstAired") != null ? series.Element("FirstAired").Value : "",
+ Language = series.Element("language") != null ? series.Element("language").Value : "",
+ Overview = series.Element("Overview") != null ? series.Element("Overview").Value : "",
+ SeriesName = series.Element("SeriesName") != null ? series.Element("SeriesName").Value : "",
+ IMDB_ID = series.Element("IMDB_ID") != null ? series.Element("IMDB_ID").Value : "",
+ BannerPath = series.Element("banner") != null ? series.Element("banner").Value : "",
+ AliasNames = series.Element("AliasNames") != null ? Util.SplitTvdbString(series.Element("AliasNames").Value) : new List(0)
+ };
+
+ List retList = new List();
+ foreach (var s in allSeries)
+ {
+ TvdbSearchResult res = new TvdbSearchResult();
+ res.Id = s.Id;
+ res.ImdbId = s.IMDB_ID;
+ if (!s.FirstAired.Equals("")) res.FirstAired = DateTime.Parse(s.FirstAired);
+ if (!s.Language.Equals("")) res.Language = Util.ParseLanguage(s.Language);
+ res.SeriesName = s.SeriesName;
+ res.Overview = s.Overview;
+ res.AliasNames = s.AliasNames;
+ if (!s.BannerPath.Equals(""))
+ {
+ res.Banner = new TvdbSeriesBanner(0, s.BannerPath, null, TvdbSeriesBanner.Type.none);
+ }
+ else
+ {
+ res.Banner = new TvdbSeriesBanner(s.Id, null, null, TvdbSeriesBanner.Type.none);
+ }
+ retList.Add(res);
+ }
+
+ return retList;
+ }
- XDocument xml = XDocument.Parse(_data);
+ ///
+ /// Exctract the series favorites
+ ///
+ ///
+ /// 73067
+ /// 78957
+ /// 75340
+ /// 72218
+ /// 73244
+ /// 75397
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractSeriesFavorites(String _data)
+ {
- var allSeries = from series in xml.Descendants("Series")
- select new
- {
- Id = Util.Int32Parse(series.Value),
- };
+ XDocument xml = XDocument.Parse(_data);
- List retList = new List();
- foreach (var s in allSeries)
- {
- if (s.Id != -99) retList.Add(s.Id);
- }
+ var allSeries = from series in xml.Descendants("Series")
+ select new
+ {
+ Id = Util.Int32Parse(series.Value),
+ };
- return retList;
- }
+ List retList = new List();
+ foreach (var s in allSeries)
+ {
+ if (s.Id != -99) retList.Add(s.Id);
+ }
- ///
- /// Extract a rating from the data in the format
- ///
- ///
- ///
- /// 7.5
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal double ExtractRating(String _data)
- {
- XDocument xml = XDocument.Parse(_data);
+ return retList;
+ }
- var ratings = from series in xml.Descendants("Rating")
- select new
- {
- rating = series.Value
- };
- if (ratings.Count() == 1 && ratings.ElementAt(0).rating != null)
- {
- return Util.DoubleParse(ratings.ElementAt(0).rating);
- }
- else
- {
- return -99;
- }
- }
+ ///
+ /// Extract a rating from the data in the format
+ ///
+ ///
+ ///
+ /// 7.5
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal double ExtractRating(String _data)
+ {
+ XDocument xml = XDocument.Parse(_data);
+
+ var ratings = from series in xml.Descendants("Rating")
+ select new
+ {
+ rating = series.Value
+ };
+ if (ratings.Count() == 1 && ratings.ElementAt(0).rating != null)
+ {
+ return Util.DoubleParse(ratings.ElementAt(0).rating);
+ }
+ else
+ {
+ return -99;
+ }
+ }
- ///
- /// Extract the updated episodes from the data in the format:
- ///
- ///
- ///
- ///
- /// 326268
- ///
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractEpisodeUpdates(String _data)
- {
- XDocument xml = XDocument.Parse(_data);
- var allEpisodes = from episode in xml.Descendants("Episode")
- select new TvdbEpisode
- {
- Id = Util.Int32Parse(episode.Element("id").Value),
- LastUpdated = Util.UnixToDotNet(episode.Element("time").Value),
- SeriesId = Util.Int32Parse(episode.Element("Series").Value)
- };
-
- List retList = new List();
- foreach (TvdbEpisode e in allEpisodes)
- {
- if (e.Id != -99) retList.Add(e);
- }
-
- return retList;
+ ///
+ /// Extract the updated episodes from the data in the format:
+ ///
+ ///
+ ///
+ ///
+ /// 326268
+ ///
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractEpisodeUpdates(String _data)
+ {
+ XDocument xml = XDocument.Parse(_data);
+ var allEpisodes = from episode in xml.Descendants("Episode")
+ select new TvdbEpisode
+ {
+ Id = Util.Int32Parse(episode.Element("id").Value),
+ LastUpdated = Util.UnixToDotNet(episode.Element("time").Value),
+ SeriesId = Util.Int32Parse(episode.Element("Series").Value)
+ };
- }
+ List retList = new List();
+ foreach (TvdbEpisode e in allEpisodes)
+ {
+ if (e.Id != -99) retList.Add(e);
+ }
- ///
- /// Extract the data of updated banners
- ///
- ///
- ///
- ///
- /// 1
- /// 79302
- /// standard
- /// en
- /// seasons/79302-1.jpg
- /// season
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractBannerUpdates(String _data)
- {
- //todo: banner update -> problem is update.xml doesn't contain all information for fanart
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
-
- XDocument xml = XDocument.Parse(_data);
- List retList = new List();
-
- //Extract the fanart banners
- var allEpisodes = from banner in xml.Descendants("Banner")
- where banner.Element("type").Value.Equals("fanart")
- select new TvdbFanartBanner
- {
- Id = banner.Element("path").Value.GetHashCode(),// -99,//Util.Int32Parse(episode.Element("Series").Value),
- BannerPath = banner.Element("path").Value,
- VignettePath = banner.Element("path").Value.Replace("/original/", "/vignette/"),
- ThumbPath = "_cache/" + banner.Element("path").Value,
- Resolution = Util.ParseResolution(banner.Element("format").Value),
- //Colors = Util.ParseColors(episode.Element("Colors").Value),
- //Language = Util.ParseLanguage(episode.Element("Language").Value)
- SeriesId = Util.Int32Parse(banner.Element("Series").Value),
- LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
- };
-
- foreach (TvdbBanner e in allEpisodes)
- {
- retList.Add(e);
- }
-
- //Extract the season banners
- var allBanners = from banner in xml.Descendants("Banner")
- where banner.Element("type").Value.Equals("season")
- select new TvdbSeasonBanner
- {
- Id = banner.Element("path").Value.GetHashCode(),
- BannerPath = banner.Element("path").Value,
- Season = Util.Int32Parse(banner.Element("SeasonNum").Value),
- BannerType = Util.ParseSeasonBannerType(banner.Element("format").Value),
- Language = Util.ParseLanguage(banner.Element("language").Value),
- SeriesId = Util.Int32Parse(banner.Element("Series").Value),
- LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
- };
-
- foreach (TvdbBanner e in allBanners)
- {
- retList.Add(e);
- }
-
- //Extract the series banners
- var allBanners2 = from banner in xml.Descendants("Banner")
- where banner.Element("type").Value.Equals("series")
- select new TvdbSeriesBanner
- {
- Id = banner.Element("path").Value.GetHashCode(),
- BannerPath = banner.Element("path").Value,
- BannerType = Util.ParseSeriesBannerType(banner.Element("format").Value),
- Language = Util.ParseLanguage(banner.Element("language").Value),
- SeriesId = Util.Int32Parse(banner.Element("Series").Value),
- LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
- };
-
- foreach (TvdbBanner e in allBanners2)
- {
- retList.Add(e);
- }
-
- //Extract the poster banners
- var allPosters = from banner in xml.Descendants("Banner")
- where banner.Element("type").Value.Equals("poster")
- select new TvdbPosterBanner
- {
- Id = banner.Element("path").Value.GetHashCode(),
- BannerPath = banner.Element("path").Value,
- Resolution = Util.ParseResolution(banner.Element("format").Value),
- Language = TvdbLanguage.UniversalLanguage,
- SeriesId = Util.Int32Parse(banner.Element("Series").Value),
- LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
- };
-
- foreach (TvdbPosterBanner e in allPosters)
- {
- retList.Add(e);
- }
- //watch.Stop();
- //Log.Debug("Extracted " + retList.Count + " bannerupdates in " + watch.ElapsedMilliseconds + " milliseconds");
- return retList;
- }
+ return retList;
- ///
- /// Extract the update time from data
- ///
- ///
- ///
- internal DateTime ExtractUpdateTime(string _data)
- {
- XDocument xml = XDocument.Parse(_data);
- var updateTime = from episode in xml.Descendants("Data")
- select new
- {
- time = episode.Attribute("time").Value
- };
- foreach (var d in updateTime)
- {
- if (d.time != "")
- {
- return Util.UnixToDotNet(d.time);
}
- }
- return new DateTime(1, 1, 1);
- }
+ ///
+ /// Extract the data of updated banners
+ ///
+ ///
+ ///
+ ///
+ /// 1
+ /// 79302
+ /// standard
+ /// en
+ /// seasons/79302-1.jpg
+ /// season
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractBannerUpdates(String _data)
+ {
+ //todo: banner update -> problem is update.xml doesn't contain all information for fanart
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
- ///
- /// Extract a list of banners from the data when the data has the format:
- ///
- ///
- ///
- /// 20106
- /// fanart/original/73739-1.jpg
- /// fanart/vignette/73739-1.jpg
- /// _cache/fanart/original/73739-1.jpg
- /// fanart
- /// 1920x1080
- /// |68,69,59|69,70,58|78,78,68|
- /// en
- ///
- ///
- /// 18953
- /// seasons/73739-2-2.jpg
- /// season
- /// season
- /// es
- /// 2
- ///
- ///
- /// 9529
- /// graphical/73739-g.jpg
- /// series
- /// graphical
- /// en
- ///
- ///
- /// ]]>
- ///
- ///
- ///
- internal List ExtractBanners(String _data)
- {
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
-
- XDocument xml = XDocument.Parse(_data);
- List retList = new List();
+ XDocument xml = XDocument.Parse(_data);
+ List retList = new List();
- //Extract the fanart banners
- var allFanartBanners = from banner in xml.Descendants("Banner")
- where banner.Element("BannerType").Value.Equals("fanart")
+ //Extract the fanart banners
+ var allEpisodes = from banner in xml.Descendants("Banner")
+ where banner.Element("type").Value.Equals("fanart")
select new TvdbFanartBanner
{
- Id = banner.Element("id") != null ? Util.Int32Parse(banner.Element("id").Value) : -99,
- BannerPath = banner.Element("BannerPath") != null ? banner.Element("BannerPath").Value : "",
- VignettePath = banner.Element("id") != null ? banner.Element("VignettePath").Value : "",
- ThumbPath = banner.Element("ThumbnailPath") != null ? banner.Element("ThumbnailPath").Value : "",
- Resolution = banner.Element("BannerType2") != null ?
- Util.ParseResolution(banner.Element("BannerType2").Value) : new Point(),
- Colors = banner.Element("Colors") != null ? Util.ParseColors(banner.Element("Colors").Value) : null,
- Language = banner.Element("Language") != null ?
- Util.ParseLanguage(banner.Element("Language").Value) : TvdbLanguage.DefaultLanguage,
- ContainsSeriesName = banner.Element("SeriesName") != null ?
- Util.ParseBoolean(banner.Element("SeriesName").Value) : false,
- LastUpdated = banner.Element("LastUpdated") != null ?
- Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ Id = banner.Element("path").Value.GetHashCode(),// -99,//Util.Int32Parse(episode.Element("Series").Value),
+ BannerPath = banner.Element("path").Value,
+ VignettePath = banner.Element("path").Value.Replace("/original/", "/vignette/"),
+ ThumbPath = "_cache/" + banner.Element("path").Value,
+ Resolution = Util.ParseResolution(banner.Element("format").Value),
+ //Colors = Util.ParseColors(episode.Element("Colors").Value),
+ //Language = Util.ParseLanguage(episode.Element("Language").Value)
+ SeriesId = Util.Int32Parse(banner.Element("Series").Value),
+ LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
};
- foreach (TvdbBanner e in allFanartBanners)
- {
- if (e.Id != -99) retList.Add(e);
- }
+ foreach (TvdbBanner e in allEpisodes)
+ {
+ retList.Add(e);
+ }
- //Extract the season banners
- var allSeasonBanners = from banner in xml.Descendants("Banner")
- where banner.Element("BannerType").Value.Equals("season")
+ //Extract the season banners
+ var allBanners = from banner in xml.Descendants("Banner")
+ where banner.Element("type").Value.Equals("season")
select new TvdbSeasonBanner
{
- Id = Util.Int32Parse(banner.Element("id").Value),
- BannerPath = banner.Element("BannerPath").Value,
- Season = Util.Int32Parse(banner.Element("Season").Value),
- BannerType = Util.ParseSeasonBannerType(banner.Element("BannerType2").Value),
- Language = Util.ParseLanguage(banner.Element("Language").Value),
- LastUpdated = banner.Element("LastUpdated") != null ?
- Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ Id = banner.Element("path").Value.GetHashCode(),
+ BannerPath = banner.Element("path").Value,
+ Season = Util.Int32Parse(banner.Element("SeasonNum").Value),
+ BannerType = Util.ParseSeasonBannerType(banner.Element("format").Value),
+ Language = Util.ParseLanguage(banner.Element("language").Value),
+ SeriesId = Util.Int32Parse(banner.Element("Series").Value),
+ LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
};
- foreach (TvdbBanner e in allSeasonBanners)
- {
- if (e.Id != -99) retList.Add(e);
- }
+ foreach (TvdbBanner e in allBanners)
+ {
+ retList.Add(e);
+ }
- //Extract the series banners
- var allSeriesBanners = from banner in xml.Descendants("Banner")
- where banner.Element("BannerType").Value.Equals("series")
+ //Extract the series banners
+ var allBanners2 = from banner in xml.Descendants("Banner")
+ where banner.Element("type").Value.Equals("series")
select new TvdbSeriesBanner
{
- Id = Util.Int32Parse(banner.Element("id").Value),
- BannerPath = banner.Element("BannerPath").Value,
- BannerType = Util.ParseSeriesBannerType(banner.Element("BannerType2").Value),
- Language = Util.ParseLanguage(banner.Element("Language").Value),
- LastUpdated = banner.Element("LastUpdated") != null ?
- Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ Id = banner.Element("path").Value.GetHashCode(),
+ BannerPath = banner.Element("path").Value,
+ BannerType = Util.ParseSeriesBannerType(banner.Element("format").Value),
+ Language = Util.ParseLanguage(banner.Element("language").Value),
+ SeriesId = Util.Int32Parse(banner.Element("Series").Value),
+ LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
};
- foreach (TvdbBanner e in allSeriesBanners)
- {
- if (e.Id != -99) retList.Add(e);
- }
+ foreach (TvdbBanner e in allBanners2)
+ {
+ retList.Add(e);
+ }
- //Extract the poster banners
- var allPosterBanners = from banner in xml.Descendants("Banner")
- where banner.Element("BannerType").Value.Equals("poster")
+ //Extract the poster banners
+ var allPosters = from banner in xml.Descendants("Banner")
+ where banner.Element("type").Value.Equals("poster")
select new TvdbPosterBanner
{
+ Id = banner.Element("path").Value.GetHashCode(),
+ BannerPath = banner.Element("path").Value,
+ Resolution = Util.ParseResolution(banner.Element("format").Value),
+ Language = TvdbLanguage.UniversalLanguage,
+ SeriesId = Util.Int32Parse(banner.Element("Series").Value),
+ LastUpdated = Util.UnixToDotNet(banner.Element("time").Value)
+ };
+
+ foreach (TvdbPosterBanner e in allPosters)
+ {
+ retList.Add(e);
+ }
+ //watch.Stop();
+ //Log.Debug("Extracted " + retList.Count + " bannerupdates in " + watch.ElapsedMilliseconds + " milliseconds");
+ return retList;
+ }
- Id = Util.Int32Parse(banner.Element("id").Value),
- BannerPath = banner.Element("BannerPath").Value,
- Resolution = Util.ParseResolution(banner.Element("BannerType2").Value),
- Language = Util.ParseLanguage(banner.Element("Language").Value),
- LastUpdated = banner.Element("LastUpdated") != null ?
- Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ ///
+ /// Extract the update time from data
+ ///
+ ///
+ ///
+ internal DateTime ExtractUpdateTime(string _data)
+ {
+ XDocument xml = XDocument.Parse(_data);
+ var updateTime = from episode in xml.Descendants("Data")
+ select new
+ {
+ time = episode.Attribute("time").Value
};
+ foreach (var d in updateTime)
+ {
+ if (d.time != "")
+ {
+ return Util.UnixToDotNet(d.time);
+ }
+ }
+ return new DateTime(1, 1, 1);
+ }
- foreach (TvdbPosterBanner e in allPosterBanners)
- {
- if (e.Id != -99) retList.Add(e);
- }
- //watch.Stop();
- //Log.Debug("Extracted " + retList.Count + " banners in " + watch.ElapsedMilliseconds + " milliseconds");
- return retList;
- }
- ///
- /// Extract a list of actors when the data has the format:
- ///
- ///
- ///
- /// 22017
- /// actors/22017.jpg
- /// Zachary Levi
- /// Chuck Bartowski
- /// 0
- ///
- ///
- /// ]]>
- ///
- /// data
- /// List of actors
- internal List ExtractActors(String _data)
- {
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
-
- XDocument xml = XDocument.Parse(_data);
- List retList = new List();
- var allActors = from episode in xml.Descendants("Actor")
- select new
- {
-
- Id = episode.Element("id").Value,
- Image = episode.Element("Image").Value,
- Name = episode.Element("Name").Value,
- Role = episode.Element("Role").Value,
- SortOrder = episode.Element("SortOrder").Value
- };
- List actorList = new List();
- foreach (var a in allActors)
- {
- TvdbActor actor = new TvdbActor();
- actor.Id = Util.Int32Parse(a.Id);
- actor.Name = a.Name;
- actor.Role = a.Role;
- actor.SortOrder = Util.Int32Parse(a.SortOrder);
-
- TvdbActorBanner banner = new TvdbActorBanner();
- banner.Id = actor.Id;
- banner.BannerPath = a.Image;
- actor.ActorImage = banner;
- if (actor.Id != -99)
+ ///
+ /// Extract a list of banners from the data when the data has the format:
+ ///
+ ///
+ ///
+ /// 20106
+ /// fanart/original/73739-1.jpg
+ /// fanart/vignette/73739-1.jpg
+ /// _cache/fanart/original/73739-1.jpg
+ /// fanart
+ /// 1920x1080
+ /// |68,69,59|69,70,58|78,78,68|
+ /// en
+ ///
+ ///
+ /// 18953
+ /// seasons/73739-2-2.jpg
+ /// season
+ /// season
+ /// es
+ /// 2
+ ///
+ ///
+ /// 9529
+ /// graphical/73739-g.jpg
+ /// series
+ /// graphical
+ /// en
+ ///
+ ///
+ /// ]]>
+ ///
+ ///
+ ///
+ internal List ExtractBanners(String _data)
{
- actorList.Add(actor);
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
+
+ XDocument xml = XDocument.Parse(_data);
+ List retList = new List();
+
+ //Extract the fanart banners
+ var allFanartBanners = from banner in xml.Descendants("Banner")
+ where banner.Element("BannerType").Value.Equals("fanart")
+ select new TvdbFanartBanner
+ {
+ Id = banner.Element("id") != null ? Util.Int32Parse(banner.Element("id").Value) : -99,
+ BannerPath = banner.Element("BannerPath") != null ? banner.Element("BannerPath").Value : "",
+ VignettePath = banner.Element("id") != null ? banner.Element("VignettePath").Value : "",
+ ThumbPath = banner.Element("ThumbnailPath") != null ? banner.Element("ThumbnailPath").Value : "",
+ Resolution = banner.Element("BannerType2") != null ?
+ Util.ParseResolution(banner.Element("BannerType2").Value) : new Point(),
+ Colors = banner.Element("Colors") != null ? Util.ParseColors(banner.Element("Colors").Value) : null,
+ Language = banner.Element("Language") != null ?
+ Util.ParseLanguage(banner.Element("Language").Value) : TvdbLanguage.DefaultLanguage,
+ ContainsSeriesName = banner.Element("SeriesName") != null ?
+ Util.ParseBoolean(banner.Element("SeriesName").Value) : false,
+ LastUpdated = banner.Element("LastUpdated") != null ?
+ Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ };
+
+ foreach (TvdbBanner e in allFanartBanners)
+ {
+ if (e.Id != -99) retList.Add(e);
+ }
+
+ //Extract the season banners
+ var allSeasonBanners = from banner in xml.Descendants("Banner")
+ where banner.Element("BannerType").Value.Equals("season")
+ select new TvdbSeasonBanner
+ {
+ Id = Util.Int32Parse(banner.Element("id").Value),
+ BannerPath = banner.Element("BannerPath").Value,
+ Season = Util.Int32Parse(banner.Element("Season").Value),
+ BannerType = Util.ParseSeasonBannerType(banner.Element("BannerType2").Value),
+ Language = Util.ParseLanguage(banner.Element("Language").Value),
+ LastUpdated = banner.Element("LastUpdated") != null ?
+ Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ };
+
+ foreach (TvdbBanner e in allSeasonBanners)
+ {
+ if (e.Id != -99) retList.Add(e);
+ }
+
+ //Extract the series banners
+ var allSeriesBanners = from banner in xml.Descendants("Banner")
+ where banner.Element("BannerType").Value.Equals("series")
+ select new TvdbSeriesBanner
+ {
+ Id = Util.Int32Parse(banner.Element("id").Value),
+ BannerPath = banner.Element("BannerPath").Value,
+ BannerType = Util.ParseSeriesBannerType(banner.Element("BannerType2").Value),
+ Language = Util.ParseLanguage(banner.Element("Language").Value),
+ LastUpdated = banner.Element("LastUpdated") != null ?
+ Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ };
+
+ foreach (TvdbBanner e in allSeriesBanners)
+ {
+ if (e.Id != -99) retList.Add(e);
+ }
+
+ //Extract the poster banners
+ var allPosterBanners = from banner in xml.Descendants("Banner")
+ where banner.Element("BannerType").Value.Equals("poster")
+ select new TvdbPosterBanner
+ {
+
+ Id = Util.Int32Parse(banner.Element("id").Value),
+ BannerPath = banner.Element("BannerPath").Value,
+ Resolution = Util.ParseResolution(banner.Element("BannerType2").Value),
+ Language = Util.ParseLanguage(banner.Element("Language").Value),
+ LastUpdated = banner.Element("LastUpdated") != null ?
+ Util.UnixToDotNet(banner.Element("LastUpdated").Value) : DateTime.Now
+ };
+
+ foreach (TvdbPosterBanner e in allPosterBanners)
+ {
+ if (e.Id != -99) retList.Add(e);
+ }
+ //watch.Stop();
+ //Log.Debug("Extracted " + retList.Count + " banners in " + watch.ElapsedMilliseconds + " milliseconds");
+ return retList;
}
- }
- //watch.Stop();
- //Log.Debug("Extracted " + actorList.Count + " actors in " + watch.ElapsedMilliseconds + " milliseconds");
- return actorList;
- }
- ///
- /// Extract user data from
- ///
- ///
- ///
- internal List ExtractUser(String _data)
- {
- //Stopwatch watch = new Stopwatch();
- //watch.Start();
- XDocument xml = XDocument.Parse(_data);
- List retList = new List();
- var allUsers = from episode in xml.Descendants("User")
- select new
- {
-
- Identifier = episode.Element("Identifier").Value,
- Name = episode.Element("Name").Value,
- Favorites = episode.Element("Favorites"),
- Preferred = episode.Element("PreferredLanguage")
- };
-
- List userList = new List();
- foreach (var a in allUsers)
- {
- TvdbUser user = new TvdbUser();
- user.UserIdentifier = a.Identifier;
- user.UserName = a.Name;
- user.UserPreferredLanguage = a.Preferred.HasAttributes ?
- Util.ParseLanguage(a.Preferred.FirstAttribute.NextAttribute.Value) :
- TvdbLanguage.DefaultLanguage;
- List favList = new List();
- foreach (String f in a.Favorites.Value.Split(','))
+ ///
+ /// Extract a list of actors when the data has the format:
+ ///
+ ///
+ ///
+ /// 22017
+ /// actors/22017.jpg
+ /// Zachary Levi
+ /// Chuck Bartowski
+ /// 0
+ ///
+ ///
+ /// ]]>
+ ///
+ /// data
+ /// List of actors
+ internal List ExtractActors(String _data)
{
- int val;
- if (Int32.TryParse(f, out val))
- {
- favList.Add(val);
- }
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
+
+ XDocument xml = XDocument.Parse(_data);
+ List retList = new List();
+ var allActors = from episode in xml.Descendants("Actor")
+ select new
+ {
+
+ Id = episode.Element("id").Value,
+ Image = episode.Element("Image").Value,
+ Name = episode.Element("Name").Value,
+ Role = episode.Element("Role").Value,
+ SortOrder = episode.Element("SortOrder").Value
+ };
+ List actorList = new List();
+ foreach (var a in allActors)
+ {
+ TvdbActor actor = new TvdbActor();
+ actor.Id = Util.Int32Parse(a.Id);
+ actor.Name = a.Name;
+ actor.Role = a.Role;
+ actor.SortOrder = Util.Int32Parse(a.SortOrder);
+
+ TvdbActorBanner banner = new TvdbActorBanner();
+ banner.Id = actor.Id;
+ banner.BannerPath = a.Image;
+ actor.ActorImage = banner;
+ if (actor.Id != -99)
+ {
+ actorList.Add(actor);
+ }
+ }
+ //watch.Stop();
+ //Log.Debug("Extracted " + actorList.Count + " actors in " + watch.ElapsedMilliseconds + " milliseconds");
+ return actorList;
}
- user.UserFavorites = favList;
- userList.Add(user);
- }
- //watch.Stop();
- //Log.Debug("Extracted " + userList.Count + " actors in " + watch.ElapsedMilliseconds + " milliseconds");
- return userList;
- }
- ///
- /// Extract a list of series ratings
- ///
- /// The xml file is in the following format:
- ///
- ///
- ///
- /// 80344
- /// 7
- /// 8.3224
- ///
- ///
- /// 72227
- /// 8
- /// 8.3224
- ///
- ///
- /// ]]>
- ///
- /// The xml content
- /// The item type for the ratings
- ///
- internal Dictionary ExtractRatings(string _data, TvdbRating.ItemType _type)
- {
- XDocument xml = XDocument.Parse(_data);
- String itemType = null;
- String idDefinition = null;
- switch (_type)
- {
- case TvdbRating.ItemType.Episode:
- itemType = "Episode";
- idDefinition = "id";
- break;
- case TvdbRating.ItemType.Series:
- itemType = "Series";
- idDefinition = "seriesid";
- break;
- default:
- return null;
- }
-
- var allRatings = from episode in xml.Descendants(itemType)
- select new
- {
- SeriesId = Util.Int32Parse(episode.Element(idDefinition).Value),
- UserRating = Util.Int32Parse(episode.Element("UserRating").Value),
- CommunityRating = Util.DoubleParse(episode.Element("CommunityRating").Value)
- };
-
- Dictionary retList = new Dictionary();
- foreach (var r in allRatings)
- {
- TvdbRating rating = new TvdbRating();
- rating.UserRating = r.UserRating;
- rating.CommunityRating = r.CommunityRating;
- rating.RatingItemType = _type;
- if (r.SeriesId != -99 && !retList.ContainsKey(r.SeriesId)) retList.Add(r.SeriesId, rating);
- }
- return retList;
+ ///
+ /// Extract user data from
+ ///
+ ///
+ ///
+ internal List ExtractUser(String _data)
+ {
+ //Stopwatch watch = new Stopwatch();
+ //watch.Start();
+ XDocument xml = XDocument.Parse(_data);
+ List retList = new List();
+ var allUsers = from episode in xml.Descendants("User")
+ select new
+ {
+
+ Identifier = episode.Element("Identifier").Value,
+ Name = episode.Element("Name").Value,
+ Favorites = episode.Element("Favorites"),
+ Preferred = episode.Element("PreferredLanguage")
+ };
+
+ List userList = new List();
+ foreach (var a in allUsers)
+ {
+ TvdbUser user = new TvdbUser();
+ user.UserIdentifier = a.Identifier;
+ user.UserName = a.Name;
+ user.UserPreferredLanguage = a.Preferred.HasAttributes ?
+ Util.ParseLanguage(a.Preferred.FirstAttribute.NextAttribute.Value) :
+ TvdbLanguage.DefaultLanguage;
+ List favList = new List();
+ foreach (String f in a.Favorites.Value.Split(','))
+ {
+ int val;
+ if (Int32.TryParse(f, out val))
+ {
+ favList.Add(val);
+ }
+ }
+ user.UserFavorites = favList;
+ userList.Add(user);
+ }
+ //watch.Stop();
+ //Log.Debug("Extracted " + userList.Count + " actors in " + watch.ElapsedMilliseconds + " milliseconds");
+ return userList;
+ }
+
+ ///
+ /// Extract a list of series ratings
+ ///
+ /// The xml file is in the following format:
+ ///
+ ///
+ ///
+ /// 80344
+ /// 7
+ /// 8.3224
+ ///
+ ///
+ /// 72227
+ /// 8
+ /// 8.3224
+ ///
+ ///
+ /// ]]>
+ ///
+ /// The xml content
+ /// The item type for the ratings
+ ///
+ internal Dictionary ExtractRatings(string _data, TvdbRating.ItemType _type)
+ {
+ XDocument xml = XDocument.Parse(_data);
+ String itemType = null;
+ String idDefinition = null;
+ switch (_type)
+ {
+ case TvdbRating.ItemType.Episode:
+ itemType = "Episode";
+ idDefinition = "id";
+ break;
+ case TvdbRating.ItemType.Series:
+ itemType = "Series";
+ idDefinition = "seriesid";
+ break;
+ default:
+ return null;
+ }
+
+ var allRatings = from episode in xml.Descendants(itemType)
+ select new
+ {
+ SeriesId = Util.Int32Parse(episode.Element(idDefinition).Value),
+ UserRating = Util.Int32Parse(episode.Element("UserRating").Value),
+ CommunityRating = Util.DoubleParse(episode.Element("CommunityRating").Value)
+ };
+
+ Dictionary retList = new Dictionary();
+ foreach (var r in allRatings)
+ {
+ TvdbRating rating = new TvdbRating();
+ rating.UserRating = r.UserRating;
+ rating.CommunityRating = r.CommunityRating;
+ rating.RatingItemType = _type;
+ if (r.SeriesId != -99 && !retList.ContainsKey(r.SeriesId)) retList.Add(r.SeriesId, rating);
+ }
+ return retList;
+ }
}
- }
}