public CalendarController()
        {
            Episode e1 = new Episode();
            e1.EpisodeNumber = 1;
            e1.ImageURI = "http://www.birdsong-peanuts.com/images/peanuts.jpg";
            e1.SeasonNumber = 6;
            e1.Synopsis = "Stefan goes out for drinks and is ordered by his boss to buy peanuts for everybody.";
            e1.Title = "The peanuts incident";

            Series s1 = new Series();
            s1.RoviID = "1234";
            s1.Channel = "Brentwood TV";
            s1.Episodes = new List<Episode>();
            s1.AddEpisode(e1);
            s1.Title = "Grads gone wild.";

            Episode e2 = new Episode();
            e2.EpisodeNumber = 4;
            e2.ImageURI = "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Peanutjar.jpg/220px-Peanutjar.jpg";
            e2.SeasonNumber = 3;
            e2.Synopsis = "Stefan gets beaten up by an angry lamppost.";
            e2.Title = "The lamppost";

            Series s2 = new Series();
            s2.RoviID = "666";
            s2.Channel = "Brentwood TV";
            s2.Episodes = new List<Episode>();
            s2.AddEpisode(e2);
            s2.Title = "The humble Bulgarian";

            bool canAdd = true;
            foreach (Series s in Calendar.GetCalendarSeries())
            {
                if (s.Equals(s1) || s.Equals(s2))
                {
                    canAdd = false;
                    break;
                }
            }
            if (canAdd)
            {
                Calendar.AddSeries(s1);
                Calendar.AddSeries(s2);
                Serialization.SeriesSerializer.SerializeSeries(s1);
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
 private void SetNextEpisode()
 {
     nextEpisode = Episodes.First();
 }
Exemplo n.º 4
0
 public void AddEpisode(Episode episode)
 {
     episodes.Add(episode);
 }