/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/xmltv_parser/main.cs	2013/03/10 10:18:06	99
+++ trunk/xmltv_parser/main.cs	2013/03/10 10:34:07	100
@@ -178,11 +178,21 @@
                 var id = program.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString();
                 Channel = instance.Channels.Find(m => m.Id == id);
                 //ListViewItem li = new ListViewItem(string.Format("{0} {1}", Channel.Number, Channel.CallSign));
-                if (Channel.MetaData.Count() == 0)
+                if (Channel.MetaData.Count() == 0) { throw new ArgumentOutOfRangeException(string.Format("No metadata available for channel id: {0}", Channel.Id)); }
+                var channel_names = Channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName];
+                string channel_name = string.Empty;
+                if (channel_names.Count() == 0) { throw new ArgumentOutOfRangeException(string.Format("No properties named '{0}' found for channel id: {1}", XMLTVConstants.Channels.ChannelDisplayName, Channel.Id)); }
+                else
                 {
-                    throw new InvalidOperationException(string.Format("Unable to get channel display name for channel id: {0}", Channel.Id));
+                    var channame = channel_names.FirstOrDefault();
+                    if (channame == null) { throw new NullReferenceException(string.Format("Unable to get channel display name for channel id: {0}", Channel.Id)); }
+                    else
+                    {
+                        if (channame.Value == null) { throw new NullReferenceException(string.Format("Unable to get channel display name for channel id: {0}", Channel.Id)); }
+                        else { channel_name = channame.Value.ToString(); }
+                    }
                 }
-                ListViewItem li = new ListViewItem(string.Format("{0}", Channel.MetaData[0].Value));
+                ListViewItem li = new ListViewItem(string.Format("{0}", channel_name));
                 li.Tag = program;
                 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.MetaData[XMLTVConstants.Programs.ProgramTitle].ToString()));
                 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString()));

 

  ViewVC Help
Powered by ViewVC 1.1.22