Пример #1
0
        public async Task<Series> convertToFullSeries(SeriesSummary basic) {
            
            Series result = new Series(basic);

            HttpClient httpClient = new HttpClient();       
            int season = 1;
            int episode = 1;
            string baseAddress = "http://api.rovicorp.com/data/v1/video/season/{0}/episode/{1}/info?cosmoid=" + basic.CosmoID + "&apikey=" + searchApiKey + "&sig=" + getRoviSearchSig() + "&include=synopsis";
            
            bool noMoreEpisodes = false;
            while (!noMoreEpisodes) {
                string addressToUse = String.Format(baseAddress, season, episode);
                string response = await httpClient.GetStringAsync(addressToUse);
                JsonObject json = JsonObject.Parse(response);
                int responseCode = (int)json.GetNamedNumber("code");

                if (responseCode == 200) {
                    JsonObject videoObject = json.GetNamedObject("video");
                    string cosmoIDString = videoObject.GetNamedObject("ids").GetNamedString("cosmoId");
                    int cosmoID = int.Parse(cosmoIDString);
                    string title = videoObject.GetNamedString("episodeTitle");
                    string synopsis = videoObject.GetNamedObject("synopsis").GetNamedString("synopsis");
                    Episode thisEpisode = new Episode(title, season, episode, synopsis, cosmoID);
                    result.AddEpisode(thisEpisode);
                    episode++;
                } else if (responseCode == 404) {
                    if (episode == 1) {
                        noMoreEpisodes = true;
                    }
                    else {
                        season++;
                        episode = 1;
                    }
                } else {
                    throw new PeanutsException("Unexpected response code when requesting episode information");
                }    
            }
            return result;
        }
Пример #2
0
 public Series(SeriesSummary inputSS)
     : base(inputSS)
 {
     episodes = new List<Episode>();
 }
Пример #3
0
 public SeriesSummary(SeriesSummary copy)
 {
     this.title = copy.Title;
     this.image = copy.Image;
     this.synopsis = copy.Synopsis;
     this.year = copy.Year;
     this.roviID = copy.RoviID;
     this.cosmoID = copy.cosmoID;
 }