Example #1
0
 private static void WriteGenres(xtvdResponse response, string filename)
 {
     Debug.WriteLine(String.Format("Writing genres to : {0}", filename));
     File.Delete(filename);
     using (StreamWriter sw = new StreamWriter(filename))
     {
         sw.WriteLine("Program;GenreClass;GenreRelevance");
         try
         {
             foreach (genresProgramGenre genresProgramGenre in response.xtvd.genres)
             {
                 genresProgramGenreGenre[] genreGenres = genresProgramGenre.genre;
                 foreach (genresProgramGenreGenre genresProgramGenreGenre in genreGenres)
                 {
                     sw.WriteLine(String.Format("{0};{1};{2}",
                                             String.IsNullOrEmpty(genresProgramGenre.program) ? "-" : genresProgramGenre.program,
                                             String.IsNullOrEmpty(genresProgramGenreGenre.@class) ? "-" : genresProgramGenreGenre.@class,
                                             genresProgramGenreGenre.relevance));
                 }
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(String.Format("An exception occured : {0}", ex.Message));
         }
     }
     Debug.WriteLine("Done writing genres");
 }
Example #2
0
        public static void DumpResponse(xtvdResponse response, string fileName)
        {
            string fileNamePrefix = fileName.Substring(0, fileName.LastIndexOf('.'));
            string fileExtension = Path.GetExtension(fileName);

            WritePrograms(response, String.Format("{0}{1}.{2}", fileNamePrefix, "_programs", fileExtension) );
            WriteSchedules(response, String.Format("{0}{1}.{2}", fileNamePrefix, "_schedules", fileExtension));
            WriteStations(response, String.Format("{0}{1}.{2}", fileNamePrefix, "_stations", fileExtension));
            WriteGenres(response, String.Format("{0}{1}.{2}", fileNamePrefix, "_genres", fileExtension));
            WriteLineUps(response, String.Format("{0}{1}.{2}", fileNamePrefix, "_lineups", fileExtension));
        }
Example #3
0
        private static void WritePrograms(xtvdResponse response, string filename)
        {
            Debug.WriteLine(String.Format("Writing programs to : {0}", filename));
            File.Delete(filename);

            using (StreamWriter sw = new StreamWriter(filename))
            {
                sw.WriteLine("Id;Title;SubTitle;StarRating;ShowType;Series;ColorCodeSpecified;ColorCode;MpaaRatingSpecified;MpaaRating;OriginalAirDateSpecified;OriginalAirDate;SyndicatedEpisodeNumber;Year;Description");
                try
                {
                    foreach (programsProgram programsProgram in response.xtvd.programs)
                    {
                        sw.WriteLine(String.Format("'{0}';'{1}';'{2}';'{3}';'{4}';'{5}';'{6}';'{7}';'{8}';'{9}';'{10}';'{11}';'{12}';'{13}';'{14}';",
                                                programsProgram.id,
                                                String.IsNullOrEmpty(programsProgram.title) ? "-" : CleanContent(programsProgram.title),
                                                String.IsNullOrEmpty(programsProgram.subtitle) ? "-" : CleanContent(programsProgram.subtitle),
                                                String.IsNullOrEmpty(programsProgram.starRating.ToString()) ? "-" : programsProgram.starRating.ToString(),
                                                String.IsNullOrEmpty(programsProgram.showType) ? "-" : programsProgram.showType,
                                                String.IsNullOrEmpty(programsProgram.series) ? "-" : programsProgram.series,
                                                programsProgram.colorCodeSpecified.ToString(),
                                                programsProgram.colorCode.ToString(),
                                                programsProgram.mpaaRatingSpecified.ToString(),
                                                programsProgram.mpaaRating.ToString(),
                                                programsProgram.originalAirDateSpecified.ToString(),
                                                programsProgram.originalAirDate.ToString(),
                                                String.IsNullOrEmpty(programsProgram.syndicatedEpisodeNumber) ? "-" : programsProgram.syndicatedEpisodeNumber,
                                                String.IsNullOrEmpty(programsProgram.year) ? "-" : programsProgram.year,
                                                String.IsNullOrEmpty(programsProgram.description) ? "-" : CleanContent(programsProgram.description)));

                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(String.Format("An exception occured : {0}", ex.Message));
                }
            }
            Debug.WriteLine("Done writing programs");
        }
Example #4
0
 private Dictionary<string, Program> BuildProgramsDictionary(xtvdResponse response)
 {
     Dictionary<string, Program> programs = new Dictionary<string, Program>();
     foreach (programsProgram program in response.xtvd.programs)
     {
         if (!programs.ContainsKey(program.id) )
         {
             programs.Add(program.id, new Program(program));
         }
     }
     return programs;
 }
Example #5
0
        private Dictionary<int, ImportGuideChannel> BuildImportGuideChannelDictionary(xtvdResponse response, string channelNameFormat)
        {
            // StationLCNs
            Dictionary<int, int> guideChannelsLcn = BuildGuideChannelLcnDictionary(response);

            Dictionary<int, ImportGuideChannel> guideChannels = new Dictionary<int, ImportGuideChannel>();
            foreach (stationsStation station in response.xtvd.stations)
            {
                if (!guideChannels.ContainsKey(station.id))
                {
                    ImportGuideChannel importGuideChannel = new ImportGuideChannel();
                    importGuideChannel.ExternalId = station.id.ToString();

                    string channelName = channelNameFormat.ToLowerInvariant();

                    channelName = channelName.Replace("{callsign}", station.callSign);
                    channelName = channelName.Replace("{name}", station.name);
                    channelName = channelName.Replace("{affiliate}", station.affiliate);
                    if (guideChannelsLcn.ContainsKey(station.id))
                    {
                        importGuideChannel.LogicalChannelNumber = guideChannelsLcn[station.id];
                        //string lcn3Digits = String.Format("{0:D3}", guideChannelsLcn[station.id]);
                        channelName = channelName.Replace("{logicalchannelnumber}", guideChannelsLcn[station.id].ToString());
                    }
                    else
                    {
                        channelName = channelName.Replace("{logicalchannelnumber}", String.Empty);
                    }
                    importGuideChannel.ChannelName = channelName;

                    guideChannels.Add(station.id, importGuideChannel);
                }
            }
            return guideChannels;
        }
Example #6
0
        private Dictionary<int, int> BuildGuideChannelLcnDictionary(xtvdResponse response)
        {
            Dictionary<int, int> guideChannelLcns = new Dictionary<int, int>();

            foreach (lineupsLineup lineUps in response.xtvd.lineups)
            {
                foreach (lineupsLineupMap lineUpMap in lineUps.map)
                {
                    if (!guideChannelLcns.ContainsKey(lineUpMap.station))
                    {
                        int lcn;
                        if (int.TryParse(lineUpMap.channel, out lcn))
                        {
                            guideChannelLcns.Add(lineUpMap.station, lcn);
                        }
                    }
                }
            }
            return guideChannelLcns;
        }
Example #7
0
        private void AddGenresToPrograms(xtvdResponse response, Dictionary<string, Program> programs)
        {
            foreach (genresProgramGenre genresProgramGenre in response.xtvd.genres)
            {
                if (programs.ContainsKey(genresProgramGenre.program))
                {
                    genresProgramGenreGenre[] programGenres = genresProgramGenre.genre;
                    int highestRelevance = -1;

                    for (int i = programGenres.Length - 1; i >= 0; i--)
                    {
                        if (programGenres[i].relevance > highestRelevance && !String.IsNullOrEmpty(programGenres[i].@class))
                        {
                            highestRelevance = programGenres[i].relevance;
                            programs[genresProgramGenre.program].Genre = programGenres[i].@class;
                        }
                    }
                }
            }
        }
Example #8
0
        private void AddActorsAndDirectorsToPrograms(xtvdResponse response, Dictionary<string, Program> programs)
        {
            foreach (productionCrewCrew productionCrew in response.xtvd.productionCrew)
            {
                if (programs.ContainsKey(productionCrew.program))
                {
                    try
                    {
                        foreach (crewMember crewMember in productionCrew.member)
                        {
                            if (String.IsNullOrEmpty(crewMember.role))
                                continue;

                            if (crewMember.role.Equals("Actor", StringComparison.InvariantCultureIgnoreCase))
                            {
                                string actorName = String.Format("{0} {1}", crewMember.givenname, crewMember.surname);
                                programs[productionCrew.program].AddActor(actorName.Trim());
                            }
                            else if (crewMember.role.Equals("Director", StringComparison.InvariantCultureIgnoreCase))
                            {
                                string directorName = String.Format("{0} {1}", crewMember.givenname, crewMember.surname);
                                programs[productionCrew.program].AddDirector(directorName.Trim());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Write(FormatForLogger(String.Format("Exception in AddActorsAndDirectorsToPrograms, message : {0} .", ex.Message)));
                    }
                }
            }
        }
Example #9
0
        private static void WriteLineUps(xtvdResponse response, string filename)
        {
            Debug.WriteLine("LineUps :");
            File.Delete(filename);
            using (StreamWriter sw = new StreamWriter(filename))
            {
                sw.WriteLine("Id;Name;UserLineupName;Location;Type;Device;PostalCode");
                try
                {
                    foreach (lineupsLineup lineupsLineup in response.xtvd.lineups)
                    {
                        sw.WriteLine(String.Format("{0};{1}",
                                                String.IsNullOrEmpty(lineupsLineup.id) ? "-" : lineupsLineup.id,
                                                String.IsNullOrEmpty(lineupsLineup.name) ? "-" : lineupsLineup.name,
                                                String.IsNullOrEmpty(lineupsLineup.userLineupName) ? "-" : lineupsLineup.userLineupName,
                                                String.IsNullOrEmpty(lineupsLineup.location) ? "-" : lineupsLineup.location,
                                                String.IsNullOrEmpty(lineupsLineup.type.ToString()) ? "-" : lineupsLineup.type.ToString(),
                                                String.IsNullOrEmpty(lineupsLineup.device) ? "-" : lineupsLineup.device,
                                                String.IsNullOrEmpty(lineupsLineup.postalCode) ? "-" : lineupsLineup.postalCode));

                        sw.WriteLine("LineUpMaps :");
                        sw.WriteLine("Station;Channel;ChannelMinor");

                        foreach (lineupsLineupMap lineupsLineupMap in lineupsLineup.map)
                        {
                            sw.WriteLine(String.Format("{0};{1};{2}",
                                                lineupsLineupMap.station,
                                                String.IsNullOrEmpty(lineupsLineupMap.channel) ? "-" : lineupsLineupMap.channel,
                                                String.IsNullOrEmpty(lineupsLineupMap.channelMinor) ? "-" : lineupsLineupMap.channelMinor));
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(String.Format("An exception occured : {0}", ex.Message));
                }
            }
            Debug.WriteLine("Done writing LineUps");
        }
Example #10
0
 private static void WriteStations(xtvdResponse response, string filename)
 {
     Debug.WriteLine(String.Format("Writing stations to : {0}", filename));
     File.Delete(filename);
     using (StreamWriter sw = new StreamWriter(filename))
     {
         sw.WriteLine("Id;Name;FccChanNbr;CallSign;Affiliate");
         try
         {
             foreach (stationsStation station in response.xtvd.stations)
             {
                 sw.WriteLine(String.Format("{0};{1};{2};{3};{4}",
                                         station.id,
                                         String.IsNullOrEmpty(station.name) ? "-" : station.name,
                                         String.IsNullOrEmpty(station.fccChannelNumber) ? "-" : station.fccChannelNumber,
                                         String.IsNullOrEmpty(station.callSign) ? "-" : station.callSign,
                                         String.IsNullOrEmpty(station.affiliate) ? "-" : station.affiliate));
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(String.Format("An exception occured : {0}", ex.Message));
         }
     }
     Debug.WriteLine("Done writing stations");
 }
Example #11
0
 private static void WriteSchedules(xtvdResponse response, string filename)
 {
     Debug.WriteLine(String.Format("Writing schedules to : {0}", filename));
     File.Delete(filename);
     using (StreamWriter sw = new StreamWriter(filename))
     {
         sw.WriteLine("Program;Station;CloseCaptionedSpecified;CloseCaptioned;DolbySpecified;Dolby;Duration;EiSpecified;Ei;HDTVSpecified;HDTV;NewSpecified;New;Part;RepeatSpecified;Repeat;StereoSpecified;Stereo;SubtitledSpecified;Subtitled;TvRatingSpecified;TvRating;Time");
         try
         {
             foreach (schedulesSchedule schedulesSchedule in response.xtvd.schedules)
             {
                 sw.WriteLine(String.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12};{13};{14};{15};{16};{17};{18};{19};{20};{21};{22}",
                                         String.IsNullOrEmpty(schedulesSchedule.program) ? "-" : schedulesSchedule.program,
                                         schedulesSchedule.station,
                                         schedulesSchedule.closeCaptionedSpecified.ToString(),
                                         schedulesSchedule.closeCaptioned.ToString(),
                                         schedulesSchedule.dolbySpecified.ToString(),
                                         schedulesSchedule.dolby.ToString(),
                                         String.IsNullOrEmpty(schedulesSchedule.duration) ? "-" : schedulesSchedule.duration,
                                         schedulesSchedule.eiSpecified.ToString(),
                                         schedulesSchedule.ei.ToString(),
                                         schedulesSchedule.hdtvSpecified.ToString(),
                                         schedulesSchedule.hdtv.ToString(),
                                         schedulesSchedule.newSpecified.ToString(),
                                         [email protected](),
                                         schedulesSchedule.part != null ? schedulesSchedule.part.number.ToString() + "/" + schedulesSchedule.part.total.ToString() : "-",
                                         schedulesSchedule.repeatSpecified.ToString(),
                                         schedulesSchedule.repeat.ToString(),
                                         schedulesSchedule.stereoSpecified.ToString(),
                                         schedulesSchedule.stereo.ToString(),
                                         schedulesSchedule.subtitledSpecified.ToString(),
                                         schedulesSchedule.subtitled.ToString(),
                                         schedulesSchedule.tvRatingSpecified.ToString(),
                                         schedulesSchedule.tvRating.ToString(),
                                         schedulesSchedule.time.ToLocalTime()));
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(String.Format("An exception occured : {0}", ex.Message));
         }
     }
     Debug.WriteLine("Done writing schedules");
 }