SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #61  
Old 04-28-2009, 01:19 PM
MeInMaui's Avatar
MeInMaui MeInMaui is offline
SageTVaholic
 
Join Date: Feb 2005
Location: Maui. HI
Posts: 4,203
@jaminben

Do you have a local community college or equivalent nearby? I know here they offer continuing education classes that include an intro to programming course. The language doesn't really matter. What is important is learning the fundamentals, which hold true regardless of language.

If you are serious about learning the basics of programming I think taking a course would be a great investment of your time and (hopefully not too much) money. Unless you are very motivated and disciplined there is no substitute for live instruction and interaction.

Aloha,
Mike
__________________
"Everything doesn't exist. I'm thirsty." ...later... "No, it's real!!! I'm full."
- Nikolaus (4yrs old)
Reply With Quote
  #62  
Old 04-29-2009, 01:25 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by MeInMaui View Post
@jaminben

Do you have a local community college or equivalent nearby? I know here they offer continuing education classes that include an intro to programming course. The language doesn't really matter. What is important is learning the fundamentals, which hold true regardless of language.

If you are serious about learning the basics of programming I think taking a course would be a great investment of your time and (hopefully not too much) money. Unless you are very motivated and disciplined there is no substitute for live instruction and interaction.
Yeah, that would be nice but its just not possible at the moment. My books arrived today so that should help.

I think I'm almost there now with regards to removing the single recorded shows. I just need to work out how to look inside each "Key" to see how many episodes are available. See screenshot of my latest code. Maybe I'm not but it feels like I'm understanding it better. I couldn't work out before how the loop would know how many shows I had but I figured that out

Screensot details, on the left is the "Airing" list which shows all shows. At the bottom is the "Keys" and above that is the total number of "Keys" or grouped shows including the single recorded ones.
Attached Images
File Type: jpg Almost there.jpg (118.3 KB, 112 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders

Last edited by jaminben; 04-29-2009 at 01:40 AM.
Reply With Quote
  #63  
Old 04-29-2009, 11:01 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
The structure of your loop looks right, but the body needs some work. I understand that this code isn't meant to be complete, but what you have in the body doesn't make much sense.

Code:
FilteredKeys = GetElement(GroupByMethod(Keys, "GetShowEpisode"), null)
What is the above line meant to do? You've already grouped your files and are iterating through the groups, so no need to group again. Also, GetElement() takes an integer as its second argument; null makes no sense in that position.

But whatever this line does or doesn't do is moot, because you then wipe it out in very the next line:

Code:
FilteredKeys = Keys
As written, your code doesn't do any filtering at all; it just copies Keys to FilteredKeys N times.

What you really want to be doing in the body of the loop (i.e. the code that gets executed once per key) is to call GetSubgroup() to get the subset of files corresponding to that key, measure the size of that subset, and branch on the result to either include or exclude the subgroup in a filtered map built up by the loop.
__________________
-- Greg
Reply With Quote
  #64  
Old 04-29-2009, 11:48 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by GKusnick View Post
The structure of your loop looks right, but the body needs some work. I understand that this code isn't meant to be complete, but what you have in the body doesn't make much sense.
Yeah, the structure of the filtering code is completly wrong and is what I just got up to. I know it looks simple to you but to me its a massive improvement as I finally understand how the loop works and thnk I know how the filtering is going to work, its just getting it to work. Another few days of reading and trying things should get this finished. The extra tips you have given is pushing me in the right direction
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #65  
Old 05-01-2009, 03:54 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Ok, So I'm still trying to make this filter work and do having it working but in the wrong place i.e after the event has already happened. Looking at my screenshot you can see that I'm able to view which grouped recordings have single files and which have multiple files. This all works via the "GroupedFiles" and the table component "AiringList" code. I can see what I need to do but dont understand how I can bring an alternative table component into the filter before it gets to the Airing code. I was under the impression that java_util_Map_keySet would be the answer, but it doesn't appear so.

Ignore the actual filter code as that just doesn't work and is my way of testing. I'm assuming once I get the correct code it will only display the false results of

Code:
Size(GetShowTitle(GetElement(GetSubgroup(GroupedFiles, AiringList), 1))) >= 2
as I dont have any code entered into the true statment.

I keep thinking that what I've done to make it work in the incorrect place is overkill and that all I really need is

Code:
Size(GetShowTitle(GetSubgroup(GroupedFiles, Keys), 1))) >= 2
but that doesn't work.

Am I getting close or does it need more reseach?

Cheers

Ben
Attached Images
File Type: jpg Works but in the wrong place.jpg (137.1 KB, 103 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #66  
Old 05-01-2009, 10:23 AM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Your loop still isn't doing anything at all & probably simply exits the first time through.

Inside the loop, you need to:
  1. Get the current key from the list of keys.
  2. Get the subgroup for the current key
  3. Check the size of the current key's subgroup - then do something if the size is or isn't what you want
  4. Increment the counter & recheck the loop's conditional

Try doing things 1 at a time on each line & use debug logging to help see what result you are getting at each step. Add a debug log statement that simply shows you what the current value of 'i' is too, so you can see in the log how many times your loop is running. You are combining several calls on a single line, which would be OK except that some of the nested calls aren't returning what you think they are & thus the whole statement fails.

There are many ways to "do something if the size is or isn't what you want". You could use the java_util_Map_remove() call to remove the subgroup you don't want, as I mentioned in one of my earlier posts. (there are other solutions, but I'll leave it at one for now.)

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #67  
Old 05-01-2009, 10:51 AM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by Opus4 View Post
Your loop still isn't doing anything at all & probably simply exits the first time through.

Inside the loop, you need to:
  1. Get the current key from the list of keys.
  2. Get the subgroup for the current key
  3. Check the size of the current key's subgroup - then do something if the size is or isn't what you want
  4. Increment the counter & recheck the loop's conditional

Try doing things 1 at a time on each line & use debug logging to help see what result you are getting at each step. Add a debug log statement that simply shows you what the current value of 'i' is too, so you can see in the log how many times your loop is running. You are combining several calls on a single line, which would be OK except that some of the nested calls aren't returning what you think they are & thus the whole statement fails.

There are many ways to "do something if the size is or isn't what you want". You could use the java_util_Map_remove() call to remove the subgroup you don't want, as I mentioned in one of my earlier posts. (there are other solutions, but I'll leave it at one for now.)

- Andy
Thanks for the reply Andy,

My problem is that I don't know what to put in the GetSubGroup boxes under the BeforeMenuLoad hook. As you can see I have it working outside this hook and within the actual menu via the table component.

Grouping - the map to get the value from
Key - the key to use for retrieving the value

Grouping in my case would be Keys and Key would be GetShowTitle?

I've had to type this reply very quickly before my broadband goes down for another two hours Unless I'm really lucky and leaving my router off for two hours has somehow fixed it
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders

Last edited by jaminben; 05-01-2009 at 10:58 AM.
Reply With Quote
  #68  
Old 05-01-2009, 11:24 AM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by jaminben View Post
Ignore the actual filter code as that just doesn't work and is my way of testing. I'm assuming once I get the correct code it will only display the false results of

Code:
Size(GetShowTitle(GetElement(GetSubgroup(GroupedFiles, AiringList), 1))) >= 2
as I dont have any code entered into the true statment.

I keep thinking that what I've done to make it work in the incorrect place is overkill and that all I really need is

Code:
Size(GetShowTitle(GetSubgroup(GroupedFiles, Keys), 1))) >= 2
but that doesn't work.
Do you know why it doesn't work, and why GetElement() makes a difference? Look again at the documentation for those functions. GetShowTitle() takes a Show object. GetSubgroup() returns the value for the given key, which according to the documentation for GroupByMethod(), is a Vector. You can't pass a Vector where a Show is expected. Programming is all about precision; you must obey the input/output specs of the functions you use or they won't work properly.

But the real question is, why are you trying to call GetShowTitle() at all at this point? You've already grouped by title in a previous call. Your Keys array contains all the titles; GetSubgroup() retrieves a set of files with the same title. Surely it's the size of that subgroup you want to measure. Wrapping that result in a call to GetShowTitle() throws away the subgroup and leaves you with the actual text of the show title (which is simply the key you used to get the subgroup in the first place). How is the length of that text string relevant to your calculation?

As Andy said, you really need to break this expression down into its component calls and print out the result of each call to make sure you understand exactly what's going on at each step of the process.
__________________
-- Greg
Reply With Quote
  #69  
Old 05-01-2009, 01:38 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
I didn't want to do this but after trying for the last 6 days and at least 5 hours a day could someone please tell me what I need to use for this to work.

What widgets do I need to complete this list.
  1. Get the current key from the list of keys - GetElement ?
  2. Get the subgroup for the current key - GetSubGroup ?
  3. Check the size of the current key's subgroup - then do something if the size is or isn't what you want. - If size() >= 2, true/false ?
  4. Increment the counter & recheck the loop's conditional - i = i + 1, i < Size(Keys) ?

I dont want the data\values just a list of whats going to work, please.
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #70  
Old 05-01-2009, 02:17 PM
Opus4's Avatar
Opus4 Opus4 is offline
Administrator
 
Join Date: Sep 2003
Location: NJ
Posts: 19,624
Inside the loop, use code something like this (I haven't tested it to verify the exact syntax):

Code:
i=0  <- Init loop counter
 if i < Size(Keys) <- Is index still within size of list of Keys?
  true <- Yes, it is
   CurKey = GetElement(Keys,i) <- Get the current key in the list, at index number 'i'
    CurSubgroup = GetSubgroup(GroupedFiles,CurKey) <- get the subgroup for the key
     if Size(CurSubgroup) <= 1 <- Is the current subgroup too small to bother with?
      java_util_Map_remove(GroupedFiles,CurKey) <- Yes, it is, so remove the key from the grouping.
   i = i + 1 <- Note the indentation here; always increment counter regardless of subgroup size
    reference to if i < Size(Keys) <- jump back to start of loop
  else <- Not really needed
I don't plan on writing the whole code each time, but maybe that will get you started with those types of calls. I may have mistyped some names, so double check.

- Andy
__________________
SageTV Open Source v9 is available.
- Read the SageTV FAQ. Older PDF User's Guides mostly still apply: SageTV V7.0 & SageTV Studio v7.1.
- Hauppauge remote help: 1) Basics/Extending it 2) Replace it 3) Use it w/o needing focus
- HD Extenders: A) FAQs B) URC MX-700 remote setup
Note: This is a users' forum; see the Rules. For official tech support fill out a Support Request.
Reply With Quote
  #71  
Old 05-01-2009, 03:50 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
I think I'm going to cry

It still doesn't work, I'm pretty sure I understand what its doing but how do I link back to the Table? I've tried all sorts of links and also removing the code from the BeforeMenuLoad hook resulting in one big code tree.

One last little gift then I promise you wont hear from me for another few hours
Attached Images
File Type: jpg Holding back the tears.....jpg (108.5 KB, 111 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #72  
Old 05-01-2009, 04:34 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Where are you setting Airinglist? If I follow you, you wnat to set Airinglist to the Hash of GroupedFiles. If you don't mind posting the xml file and can explain what you want it to do, I can take a look if you want another pair of eyes to go over it....

Thanks,
Jeff
Reply With Quote
  #73  
Old 05-01-2009, 04:46 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by jphipps View Post
Where are you setting Airinglist? If I follow you, you wnat to set Airinglist to the Hash of GroupedFiles. If you don't mind posting the xml file and can explain what you want it to do, I can take a look if you want another pair of eyes to go over it....

Thanks,
Jeff
Thats just it, it doesn't work no matter where I set it. I'm sure I'm missing the obvious answer but I just can't see the wood for the trees at the moment. I should be able to do this but I'm sick of starring at this problem and really just want to move on

Please find attached a zip file containing the export.

Cheers

Ben
Attached Files
File Type: zip A1_Tester_Export.zip (1.3 KB, 79 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #74  
Old 05-01-2009, 04:58 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Not sure if this was you were looking for it to do or not... Let me know if this is not what you were trying to get it to do...

Thanks,
Jeff
Attached Files
File Type: zip A1_Tester_Export.zip (1.3 KB, 90 views)
Reply With Quote
  #75  
Old 05-01-2009, 05:02 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Part of your confusion is that you're using the variable name AiringList to mean two different things, neither of which is a list of Airings.

In the first case, you have AiringList feeding the Table widget. But you don't want a list of Airings here, you want a map of Airings grouped by title. That's what we just went to all that trouble to compute. So don't use AiringList here; use GroupedFiles to feed the table.

In the second case, you've named your TableComponent AiringList. This is not the same AiringList as before; it's a new variable that just happens to have the same name (which is bad practice, in case that's not obvious). And again, it's not a list of Airings; it's the group key from your GroupedFiles map. Since you grouped by title, the key is a String containing the show title. So name it something that indicates that (like Key or Title or whatever). But be aware that if you change this variable name, you'll also need to change the use of it feeding the Text widget.

Make those changes and you can get rid of the AiringList variable altogether, because it's not doing anything for you.
__________________
-- Greg
Reply With Quote
  #76  
Old 05-01-2009, 05:04 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by jphipps View Post
Not sure if this was you were looking for it to do or not... Let me know if this is not what you were trying to get it to do...

Thanks,
Jeff

Thanks but you get the same results that I do when I place the "AiringList = GroupedFiles" above the java_util_Map_remove(GroupedFiles,CurKey) widget. A list of shows but it doesn't remove the single recordings.
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #77  
Old 05-01-2009, 05:17 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
It does show the list but it doesn't remove the single recordings. I'm not sure if Andy has put a deliberate mistake into the mix to try and make sure I understand it. Maybe I'm trying too hard and need to step back a little.

The screen shot shows the code as you suggested.


Quote:
Originally Posted by GKusnick View Post
Part of your confusion is that you're using the variable name AiringList to mean two different things, neither of which is a list of Airings.

In the first case, you have AiringList feeding the Table widget. But you don't want a list of Airings here, you want a map of Airings grouped by title. That's what we just went to all that trouble to compute. So don't use AiringList here; use GroupedFiles to feed the table.

In the second case, you've named your TableComponent AiringList. This is not the same AiringList as before; it's a new variable that just happens to have the same name (which is bad practice, in case that's not obvious). And again, it's not a list of Airings; it's the group key from your GroupedFiles map. Since you grouped by title, the key is a String containing the show title. So name it something that indicates that (like Key or Title or whatever). But be aware that if you change this variable name, you'll also need to change the use of it feeding the Text widget.

Make those changes and you can get rid of the AiringList variable altogether, because it's not doing anything for you.
Edit:

I see why its not removing the single recordings, its reading the "GroupedFiles" from further up the tree. You can see this by removing the filter altogether (see screenshot).

So I must need to reference something after the filtering has taken place.
Attached Images
File Type: jpg Like This.jpg (107.2 KB, 109 views)
File Type: jpg Remove Filter.jpg (99.0 KB, 99 views)
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders

Last edited by jaminben; 05-01-2009 at 05:37 PM.
Reply With Quote
  #78  
Old 05-01-2009, 06:19 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
Quote:
Originally Posted by jaminben View Post
So I must need to reference something after the filtering has taken place.
The filtering takes place in BeforeMenuLoad; by definition everything else happens after that. The actual postion of the BeforeMenuLoad hook in the widget tree is irrelevant; it always executes first, before any UI widgets. If I were you, I would move the hook up to be the first child of the Menu widget. Not that it makes any functional difference, but just as a visual reminder of what order things happen in.

If the filtering code doesn't seem to be doing what you expect, insert some calls to DebugLog() in your loop to print out the intermediate results and see what's happening line by line.
__________________
-- Greg
Reply With Quote
  #79  
Old 05-01-2009, 07:04 PM
jaminben jaminben is offline
Sage Icon
 
Join Date: Sep 2007
Location: Norwich, UK
Posts: 1,754
Send a message via MSN to jaminben
Quote:
Originally Posted by GKusnick View Post
The filtering takes place in BeforeMenuLoad; by definition everything else happens after that.
I did wonder about that.

Quote:
Originally Posted by GKusnick View Post
If the filtering code doesn't seem to be doing what you expect, insert some calls to DebugLog() in your loop to print out the intermediate results and see what's happening line by line.
Tried this and every thing seems to work ok until the i < Size(Keys) everything after that returns null. This proberly means I've setup the DebugLog() wrong but its after 02.00 now so I'll try again tomorrow

Thanks for everyones help tonight, I've learnt lots.
__________________
Server - Win7 64bit, 2.4Ghz Intel Core 2 Duo, TBS 6284 PCI-E Quad DVB-T2 Tuner, 3 x HD200 & 1 x HD300 extenders
Reply With Quote
  #80  
Old 05-01-2009, 07:31 PM
jphipps jphipps is offline
Sage Expert
 
Join Date: Aug 2006
Location: Maryland
Posts: 512
Looks like I cracked the case... The main issue was that the return variable for the java_util_keySet returns a set and not an array. You have to convert the set to an array and then you can use GetElement on it. GetElement does not seem to work on sets... I have attached the copy that I have working...

Thanks,
Jeff
Attached Files
File Type: zip A1_test2.zip (1.3 KB, 83 views)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Studio and SageMC Questions bama SageMC Custom Interface 4 07-26-2008 01:11 PM
Silly Newbie Question: Starting Studio willetin SageTV Studio 2 01-05-2008 08:21 AM
Studio Newbie Question mightyt SageTV Studio 4 01-30-2006 01:52 AM
Some questions about the upcoming Studio. ToxMox SageTV Customizations 26 06-08-2004 09:00 AM


All times are GMT -6. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.