public Collection<ApiTvSeason> GetTvSeasons()
        {
            var seasons = new Collection<ApiTvSeason>();
            if (!_parent.IsConnected())
                return seasons;
            var dblines = _parent.IPimpDBCommand(new CommandInfoIPimp { Action = "getallseasons" }, "seasons");
            if (dblines == null) return seasons;

            foreach (JsonObject dbline in dblines)
            {
                var tvSeason = new ApiTvSeason
                {
                    Fanart = (string)dbline["fanart"],
                    Hash = MediaPortal.Hash((string)dbline["id"]),
                    IdShow = 0,
                    Thumb = (string)dbline["thumb"],
                    EpisodeCount = Convert.ToInt32(dbline["episodecount"], CultureInfo.InvariantCulture),
                    SeasonNumber =  Convert.ToInt32(dbline["seasonnumber"], CultureInfo.InvariantCulture),
                    Show = (string)dbline["show"]
                };

                seasons.Add(tvSeason);
            }

            return seasons;
        }
示例#2
0
        public Collection<ApiTvSeason> GetTvSeasons()
        {
            var seasons = new Collection<ApiTvSeason>();
            const string req = "SELECT idShow, COUNT(idShow), c12, strPath,strTitle FROM episodeview GROUP BY idShow,c12";

            var dblines = _parent.DBCommand("video", req);
            if (dblines == null) return seasons;
            foreach (var dbline in dblines)
            {
                if (dbline.Length < 4)
                {
                    _parent.Log("Invalid request DATA : " + dbline);
                    continue;
                }
                var season = new ApiTvSeason
                {
                    EpisodeCount = Xbmc.StringToNumber(dbline[1]),
                    IdShow = Xbmc.StringToNumber(dbline[0]),
                    SeasonNumber = Xbmc.StringToNumber(dbline[2]),
                    Show = dbline[4]
                };

                var temp = dbline[3];
                season.Fanart = @"special://profile/Thumbnails/Video/Fanart/" + Xbmc.Hash(temp) + ".tbn";
                char[] charsToTrim = { '/' };
                temp = temp.TrimEnd(charsToTrim);
                var hash = Xbmc.Hash("season" + temp);
                season.Thumb = @"special://profile/Thumbnails/Video/" + hash[0] + "/" + hash + ".tbn";
                season.Hash = temp;
                seasons.Add(season);
            }
            return seasons;
        }
示例#3
0
    public Collection<ApiTvSeason> GetTvSeasons()
    {
      var seasons = new Collection<ApiTvSeason>();

      var properties = new JsonArray(new[] { "title" });
      var param = new JsonObject();
      param["properties"] = properties;
      var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
      if (result != null)
      {
        if (result.Contains("tvshows"))
        {
          foreach (JsonObject show in (JsonArray)result["tvshows"])
          {
            var properties2 =
              new JsonArray(new[] { "tvshowid", "fanart", "thumbnail", "season", "showtitle", "episode" });
            var param2 = new JsonObject();
            param2["properties"] = properties2;
            param2["tvshowid"] = (long)(JsonNumber)show["tvshowid"];
            var result2 = (JsonObject)_parent.JsonCommand("VideoLibrary.GetSeasons", param2);
            if (result2 == null) continue;
            if (!result2.Contains("seasons")) continue;
            foreach (JsonObject genre in (JsonArray)result2["seasons"])
            {
              try
              {
                var tvShow = new ApiTvSeason
                  {
                    SeasonNumber = (long)(JsonNumber)genre["season"],
                    IdShow = (long)(JsonNumber)genre["tvshowid"],
                    Show = genre["showtitle"].ToString(),
                    Thumb = genre["thumbnail"].ToString(),
                    EpisodeCount = (long)(JsonNumber)genre["episode"],
                    Fanart = genre["fanart"].ToString(),
                    Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                  };
                seasons.Add(tvShow);
              }
              catch (Exception)
              {
              }
            }
          }
        }
      }
      return seasons;
    }
示例#4
0
 public Yatse2TvSeason(ApiTvSeason apiTvSeason)
 {
     if (apiTvSeason == null)
         return;
     IdShow = apiTvSeason.IdShow;
     SeasonNumber = apiTvSeason.SeasonNumber;
     Thumb = apiTvSeason.Thumb;
     Fanart = apiTvSeason.Fanart;
     EpisodeCount = apiTvSeason.EpisodeCount;
     Hash = apiTvSeason.Hash;
     Show = apiTvSeason.Show;
 }
示例#5
0
 public ApiTvSeason ToApi()
 {
     var api = new ApiTvSeason
     {
         Fanart = Fanart,
         Hash = Hash,
         Show = Show,
         Thumb = Thumb,
         IdShow = IdShow,
         EpisodeCount = EpisodeCount,
         SeasonNumber = SeasonNumber
     };
     return api;
 }
示例#6
0
    public Collection<ApiTvSeason> GetTvSeasonsRefresh()
    {
        var seasons = new Collection<ApiTvSeason>();

        var properties = new JsonArray(new[] { "title" });
        var param = new JsonObject();
        param["properties"] = properties;

        // First 100 Date sorted
        var param2 = new JsonObject();
        param2.Add("start", 0);
        param2.Add("end", 10);
        var param3 = new JsonObject();
        param3.Add("order", "descending");
        param3.Add("method", "dateadded");
        param.Add("sort", param3);
        param.Add("limits", param2);

        var result = (JsonObject)_parent.JsonCommand("VideoLibrary.GetTVShows", param);
        if (result != null)
        {
            if (result.Contains("tvshows"))
            {
                foreach (JsonObject show in (JsonArray)result["tvshows"])
                {
                    var properties2 =
                      new JsonArray(new[] { "tvshowid", "fanart", "thumbnail", "season", "showtitle", "episode" });
                    var param22 = new JsonObject();
                    param22["properties"] = properties2;
                    param22["tvshowid"] = (long)(JsonNumber)show["tvshowid"];

                    var result2 = (JsonObject)_parent.JsonCommand("VideoLibrary.GetSeasons", param22);
                    if (result2 == null) continue;
                    if (!result2.Contains("seasons")) continue;
                    foreach (JsonObject genre in (JsonArray)result2["seasons"])
                    {
                        try
                        {

                            _parent.Trace("Kodi QuickRefresh Seasons:  SeasonNumber:" + (long)(JsonNumber)genre["season"]);
                            _parent.Trace("Kodi QuickRefresh Seasons:  IdShow:" + (long)(JsonNumber)genre["tvshowid"]);
                            _parent.Trace("Kodi QuickRefresh Seasons:  Show:" + genre["showtitle"].ToString());
                            _parent.Trace("Kodi QuickRefresh Seasons:  Thumb:" + genre["thumbnail"].ToString());
                            _parent.Trace("Kodi QuickRefresh Seasons:  EpisodeCount:" + (long)(JsonNumber)genre["episode"]);
                            _parent.Trace("Kodi QuickRefresh Seasons:  Fanart:" + genre["fanart"].ToString());
                            _parent.Trace("Kodi QuickRefresh Seasons:  Hash:" + genre["thumbnail"].ToString());

                            var tvShow = new ApiTvSeason
                            {
                                SeasonNumber = (long)(JsonNumber)genre["season"],
                                IdShow = (long)(JsonNumber)genre["tvshowid"],
                                Show = genre["showtitle"].ToString(),
                                Thumb = genre["thumbnail"].ToString(),
                                EpisodeCount = (long)(JsonNumber)genre["episode"],
                                Fanart = genre["fanart"].ToString(),
                                Hash = Xbmc.Hash(genre["thumbnail"].ToString())
                            };
                            seasons.Add(tvShow);
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
        }
        return seasons;
    }
示例#7
0
        public Collection<ApiTvSeason> GetTvSeasonsRefresh()
        {
            var seasons = new Collection<ApiTvSeason>();

            try
            {


                _parent.Trace("Getting TV Seasons from New TV Episodes Somehow:" + _parent.IP);
                //          string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Limit=30&Recursive=true&ExcludeLocationTypes=Virtual&SortBy=DateCreated&SortOrder=Descending&IncludeItemTypes=Season";
                string NPurl = "http://" + _parent.IP + ":" + _parent.Port + "/emby/Users/" + Globals.CurrentUserID + "/Items?Limit=30&Recursive=true&ExcludeLocationTypes=Virtual&SortBy=DateCreated&SortOrder=Descending&IncludeItemTypes=Episode";

                var request = WebRequest.CreateHttp(NPurl);

                request.Method = "get";
                request.Timeout = 150000;
                _parent.Trace("Single TV Season from TV Episodes NEW: Selection: " + _parent.IP + ":" + _parent.Port);

                var authString = _parent.GetAuthString();

                request.Headers.Add("X-MediaBrowser-Token", Globals.EmbyAuthToken);
                request.Headers.Add("X-Emby-Authorization", authString);
                request.ContentType = "application/json; charset=utf-8";
                request.Accept = "application/json; charset=utf-8";

                var response = request.GetResponse();

                if (((HttpWebResponse)response).StatusCode == HttpStatusCode.OK)
                {

                    System.IO.Stream dataStream = response.GetResponseStream();

                    using (var sr = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        string json = sr.ReadToEnd();
                        _parent.Trace("--------------GETTING Single TV Season RefreshTVSeasons Selection Result ------" + json);

                        var deserializer = new JavaScriptSerializer();

                        var ItemData = deserializer.Deserialize<TVEpisodes.Rootobject>(json);
                        //   _parent.Trace("---------------Get Single TV Season Selection:  Issue: Results.Taglines: " + ItemData.TotalRecordCount);

                        foreach (var genre in ItemData.Items)
                        {
                            try
                            {

                                // var SingleTVData = GetSingleTVFromSeries(genre.Id);
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Season Number:" + genre.ParentIndexNumber);
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- ID Show:" + Xbmc.IDtoNumber(genre.SeriesId));
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Series Name:" + genre.SeriesName);
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Thumb:" + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Primary" ?? "");
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Child Count:" + (long)(int)genre.IndexNumber);
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Fanart:" + "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Backdrop" ?? "");
                                _parent.Trace("---Emby QuickRefresh GetTVSeasons--- Hash:" + Xbmc.Hash(genre.SeasonId));

                                var tvShow = new ApiTvSeason
                                {
                                    SeasonNumber = genre.ParentIndexNumber,
                                    IdShow = Xbmc.IDtoNumber(genre.SeriesId),
                                    Show = genre.SeriesName ?? "",
                                    Thumb = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Primary" ?? "",
                                    EpisodeCount = (long)(int)genre.IndexNumber,   //bit of a hack but if date sorted - latest episode should be highest - so for most should be right.
                                    Fanart = "http://" + _parent.IP + ":" + _parent.Port + "/Items/" + genre.SeriesId + "/Images/Backdrop" ?? "",
                                    Hash = Xbmc.Hash(genre.SeasonId)
                                };
                                seasons.Add(tvShow);

                            }
                            catch (Exception ex)
                            {
                                _parent.Trace("TV Shows Exception Caught " + ex);
                            }
                        }

                    }
                }
            }
            catch (Exception Ex)
            {
                _parent.Trace("Another tV SHows exception" + Ex);
            }



            return seasons;
        }