NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 25 26 27 28 29 … 93 Next »
INI, Text File Reader...

 
  • 0 Vote(s) - 0 Average
INI, Text File Reader...
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#21
2009-02-08, 11:08 PM
whurlston Wrote:I updated the sample code on the previous page to provide a working sample. You will need to reference the IsoCodes.dll as well as the XmlTv.dll

I'm having some troubles updating fields that are empty. I'm probably just missing something... In the code below, I'm simply taking the Title and the Secondary Title and adding them, or overwriting the Description for test. I get an error, when I hit a record that has a title, and secondary, but no decription


Code:
For Each p As XmlTv.Programme In xmltv.Programmes
            RecordNumber = RecordNumber + 1
            lblCount.Text = RecordNumber
            Application.DoEvents()

            If (p.SecondaryTitle.Count) <> 0 Then
                [B]p.Description(0).Text[/B] = "New Text " & p.Title(0).Text & " : " & p.SecondaryTitle(0).Text
            End If

            ' the AddDays value would be the number of day before consider old  -1.
            ' This is used since the isNew value is not always correct.

            'If p.isNew OrElse p.OriginalAirDate > p.Start.AddDays(-7) Then
            ' p.Title(0).Text += " "
            ' End If
        Next

I'm not sure enough to wonder if it's a bug in your dll or my trying to update a property that hasn't been dimensioned yet...
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#22
2009-02-08, 11:23 PM
Off the top of my head, I don't thing that SecondaryTitle is required so therefore may not be initialized. If this is the case, you need to check for null:

[quote=zehd]
Code:
If (p.SecondaryTitle.Count) <> 0 Then
should be:
Code:
If p.SecondaryTitle IsNot Nothing AndAlso p.SecondaryTitle.Count <> 0 Then
I'll check tonight to make sure.
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#23
2009-02-08, 11:34 PM
whurlston Wrote:Off the top of my head, I don't thing that SecondaryTitle is required so therefore may not be initialized. If this is the case, you need to check for null:

[quote=zehd]
Code:
If (p.SecondaryTitle.Count) <> 0 Then
should be:
Code:
If p.SecondaryTitle IsNot Nothing AndAlso p.SecondaryTitle.Count <> 0 Then
I'll check tonight to make sure.

I will also check for null, but in the above example, I confirmed that there IS a Title and a Secondary, but probably null in Description, and I can't set info into Description...

And if you wouldn't mind checking whether I can 'create' values for Ratings, Star Ratings, Date, Premiere, PreviouslyShown.




Thanks

--- funny how we could have been having this discussion last year when I was working on Ultra. Man was I ever banging my head against the wall?...
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#24
2009-02-09, 09:23 AM (This post was last modified: 2009-02-09, 09:30 AM by whurlston.)
zehd Wrote:I will also check for null, but in the above example, I confirmed that there IS a Title and a Secondary, but probably null in Description, and I can't set info into Description...

I checked and "Title" is the only required field so you'll need to check for null on everything else. Description is a list of the "TextWithLang" class so to add a description, you will need to perform the following:

Code:
// C#
if (p.Description == null)
{
    p.Description = new List<XmlTv.TextWithLang>();
}
p.Description.Add(new XmlTv.TextWithLang("This is a description of the program"));

Code:
// VB
If p.Description Is Nothing Then
    p.Description = New List(Of XmlTv.TextWithLang)()
End If
p.Description.Add(new XmlTv.TextWithLang("This is a description of the program"));

There is also an override for adding the language attribute:
Code:
p.Description.Add(new XmlTv.TextWithLang(IsoCodes.Language.TwoDigit.en, "This is a description of the program"));


zehd Wrote:And if you wouldn't mind checking whether I can 'create' values for Ratings, Star Ratings, Date, Premiere, PreviouslyShown.

Same theory applies (but they me be derivatives of a different class). If you give me a day or two I will add some methods to check for null, create the list and add the field automatically so you can just call programme.AddDescription() etc.



zehd Wrote:Thanks

--- funny how we could have been having this discussion last year when I was working on Ultra. Man was I ever banging my head against the wall?...
I tried to tell you. Smile
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#25
2009-02-09, 04:13 PM
whurlston Wrote:Same theory applies (but they me be derivatives of a different class). If you give me a day or two I will add some methods to check for null, create the list and add the field automatically so you can just call programme.AddDescription() etc.

Well that would be great... though I would imagine that if I used a programme.AddDescription() then I would still need to test for nulls..

Is it too much to ask that the class itself deals with the null, so that when I just try and use a property that doesn't exist, it adds it for me.

Or maybe another idea. Maybe on the ReadFrom method, all the properties are initialized, and only on the Write To Method, would it ignore and not write Blank Properties.

Lately, I've been trying to Strong Type the xml from theTVdb,com but I noticed that the index of the xml tags is not always the same, so I'm trying to fix a sample I have for a generic XML Serialization class, so that I'll always find what I want....
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#26
2009-02-09, 04:18 PM
zehd Wrote:Lately, I've been trying to Strong Type the xml from theTVdb,com but I noticed that the index of the xml tags is not always the same, so I'm trying to fix a sample I have for a generic XML Serialization class, so that I'll always find what I want....

Oops. Got that one solved...
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#27
2009-02-09, 05:18 PM (This post was last modified: 2009-02-09, 05:38 PM by whurlston.)
zehd Wrote:Or maybe another idea. Maybe on the ReadFrom method, all the properties are initialized, and only on the Write To Method, would it ignore and not write Blank Properties.
Yeah, I could do that. I hadn't thought of it. You will still need to check if the count > 0 on lists like the description before attempting to access p.Description(0).Text though.
whurlston
Offline

Posting Freak

Posts: 7,885
Threads: 102
Joined: Nov 2006
#28
2009-02-09, 07:57 PM
After thinking about this, I think a better solution would be to add a readonly bool like Programme.HasDescription so you could just do something like:

Code:
// C#
if (p.HasDescription)
{
  p.Description[0].Text = "Modified description for program.";
}
else
{
  p.AddDescription("New description for program");
}

Code:
// VB
If p.HasDescription Then
    p.Description(0).Text = "Modified description for program."
Else
    p.AddDescription("New description for program")
End If
It would return "false" if the Description is null or if Description.Count is 0. There would also be others like Program.HasCategories, Programme.IsEpisodic, Programme.HasRatings, etc.

Would this work for you?
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#29
2009-02-10, 12:47 AM
whurlston Wrote:After thinking about this, I think a better solution would be to add a readonly bool like Programme.HasDescription so you could just do something like:

Code:
// C#
if (p.HasDescription)
{
  p.Description[0].Text = "Modified description for program.";
}
else
{
  p.AddDescription("New description for program");
}

Code:
// VB
If p.HasDescription Then
    p.Description(0).Text = "Modified description for program."
Else
    p.AddDescription("New description for program")
End If
It would return "false" if the Description is null or if Description.Count is 0. There would also be others like Program.HasCategories, Programme.IsEpisodic, Programme.HasRatings, etc.

Would this work for you?

You know, I'm seeing it clear enough now to know that I would probably make a wrapper for that, so that I would pass a string and do the if/then checking for me...

Beggars can't be choosers, but I did think that that checking could be part of the class... (sorry to be a pain...)
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
zehd
Offline

Posting Freak

Posts: 5,119
Threads: 249
Joined: Feb 2006
#30
2009-02-11, 08:48 AM
I was able to iterate through the categories and compare to a string. I can then skip processing that record

Code:
If p.Categories.Count > 0 Then
                For i = 0 To p.Categories.Count - 1
                    If p.Categories.Item(i).Text = "Paid Programming" Then
                        If p.SecondaryTitle IsNot Nothing AndAlso p.SecondaryTitle.Count <> 0 Then
                            p.SecondaryTitle(0).Text = "Please Donate"
                        End If
                        PaidAds = PaidAds + 1
                        'I want to skip querying this
                        GoTo GoAhead
                    End If
                Next
            End If
Frank Z
[COLOR="Gray"]
I used to ask 'why?' Now I just reinstall...
[SIZE="1"]______________________________________________
Author: ZTools: ZProcess, MVPServerChecker; UltraXMLTV Enhancer, Renamer, Manager; [/SIZE]
[/COLOR]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)

Pages (7): « Previous 1 2 3 4 5 … 7 Next »
Jump to page 


Possibly Related Threads…
Thread Author Replies Views Last Post
  How Does "Use S01E01 File naming format if possible" work puck64 7 5,342 2015-08-25, 10:21 AM
Last Post: puck64
  NEWA - using buffer file produced by /public/VLCService?Channel= bgowland 5 2,811 2014-01-02, 06:36 AM
Last Post: bgowland
  Is the input file for pvrx2.exe -import unique to NextPVR? spinnaker 1 1,776 2013-10-08, 02:25 AM
Last Post: sub
  Accessing music file metadata in C# bgowland 6 3,310 2013-01-26, 05:14 AM
Last Post: bgowland
  RSS Reader tmrt 51 18,215 2011-02-21, 07:22 AM
Last Post: tmrt
  File browsing - a big ask imilne 3 1,999 2010-11-04, 09:03 PM
Last Post: imilne
  Run Multiple File Conversions On Your 4 Core -Burn Your Processor luttrell1962 12 4,582 2010-03-25, 07:33 AM
Last Post: luttrell1962
  Determining text size and available space Ommina 2 1,667 2010-03-15, 05:34 AM
Last Post: sub
  Using Windows file system shortcuts ACTCMS 0 1,808 2010-01-26, 11:45 PM
Last Post: ACTCMS
  Not looking in correct location for skin file scb147 4 2,219 2009-07-29, 06:26 PM
Last Post: scb147

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode