# Dynamic Folders in GUI



## solaise (Sep 17, 2006)

I was astonished to see what mikerr had achieved with sortnp and especially the folders option.

Having installed it I tried a tweak here and there and then decided I actually wanted something slightly different.

I think what sortnp does very well is provide an archive facility for existing recordings thats integrates well with TivoWeb.

What I wanted was a distinct folder zone that added new recordings automatically and tracked deletions. I.e I wanted instead to use it for my favourite shows. A visible indication that a folder had a new show would be nice.
I also wanted to speed up the opening and closing of folders and I wanted to drive it off the remote keys rather than a menuing subsystem. 

It took a lot of decoding of Tivo events with a hex calculator
but I am pretty happy with the results. I have got opening and closing a folder down to a couple of seconds and devised a way to show the Tivo Wait screen whilst this is going on.

It is clearly derives its inspiration and significant portions of critical code from sortnp.tcl but there is a lot
of new code in there as well. I have removed lots of functionality (such as synchronising with TivoWeb folders) which didn't seem relevant to the new focus.

As I haven't posted anything before I anticipate that I have probably forgotten some vital element needed for it to run but if anyone want to try it out I will do my best to offer any help I can. 

There were some problems reported with folder creation caused by MFS errors - the latest version defaults to moving to TivoCentral to create the folder which seems to have fixed the problem.


----------



## martink0646 (Feb 8, 2005)

Hi,

Attempting this is a great effort!!!! I have looked at the (comprehensive) instructions & I will attempt to install this at the weekend due to the time it's going to take (me).

One quick question, can this be installed alongside sortnowplaying or do I have to kill it (either via the GUI or a telnet session) or uninstall it?

Martin


----------



## solaise (Sep 17, 2006)

Martin

Whilst giving New Folders a try out you need to at least shut down sortnp. Assuming you have version with folders then you can do this from the Tivo GUI with its menu system 0 to pull up menu and 8 to exit.

I will have a look and see what impact leaving any sortnp folders about would have on New Folders - it won't recognise them and it may be a bit confusing visually but I will check precisely what does happen.

I have just realised that I (exactly as predicted) left a vital component out of the zip file - namely newtext2osd. It shouldn't be a problem for anyone who has previously installed sortnp as this will have installed it.

I will update the zip this evening.

Steve


----------



## mikerr (Jun 2, 2005)

Excellent, lots of hard work there :up: :up:

Works nice and very fast too - almost instant due to your event code


----------



## ColinYounger (Aug 9, 2006)

Solaise - wow. How long did all this take you? It's very impressive.

Can you explain what you're doing in DecodeTmsId and why?

Did you use a tcl environment offline, or did you do all the development on TiVo itself?


----------



## solaise (Sep 17, 2006)

mikerr said:


> Excellent, lots of hard work there :up: :up:
> 
> Works nice and very fast too - almost instant due to your event code


Thanks Mike I am glad you like it - after all a lot of it is yours!!

The EnableTransactionHoldoff true setting which I spotted in tivoweb gave a big proportion of the speed up. I've done a lot of testing opening and closing folders and checking there is no impact on live tv video - you may notice I wait every 5 shows to give everyone else a look in.


----------



## solaise (Sep 17, 2006)

ColinYounger said:


> Solaise - wow. How long did all this take you? It's very impressive.
> 
> Can you explain what you're doing in DecodeTmsId and why?
> 
> Did you use a tcl environment offline, or did you do all the development on TiVo itself?


Its taken about four weeks in all - a fair few evenings and weekends. Its a lot lot easier when you have something working to base it on rather than starting from scratch.

Most of MwApp is concerned with trying to figure out which program the cursor in the GUI is on. In the original mikerr was using mwstate to do this whereas I use the BACKHAUL events. These don't in general give the FSID of the show (although one event oddly does ) but do supply the date and time and the TmsID. The TMS Id is the Turner?? Media Services (I guess?) code for the show. It something like EP8906272890. It has 3 portions the prefix is EP SH or MV for an episode of a series, a one off show or a movie. The last 4 digits are the episode number within the series and zero for a SH or MV

In lib/NewFolders/advSort.tcl I read this from Mfs.

I wasn't convinced that the date time was necessary always a 100% unique key so I try and use the TmsId in preference. Its encoded in 40 bits but when I tried working on this in Tcl it threw an error so I had to come up with a way to decode it - it works is about the best thing I can say about it...

I used the Dos Editor on Windows and downloaded Tcl 8.4 for the help file. I used cygwin as a transfer staging post where i ran dos2unix and built the tar file for the published version. I created the package index files on windows as the Tcl 8.0.3 on the Tivo has a very poor implementation of pkg_mkIndex which cannot really deal with namespaces.


----------



## Pete77 (Aug 1, 2006)

From my paltry and miserable understanding of the black art of programming (which stopped back in the days in the early 1980s when CP/M and ZX81 Basic still had line numbers) it sounds to me like some of your discoveries could be used to improve the efficiency of the code in Mike's sortnp.tcl utility.

Perhaps there is even a way for the two you to work together to make the whole thing in to one fully integrated and even more breathtaking Tivo GUI utility?:up:


----------



## bugmenever (Feb 4, 2007)

Sounds good - does anyone have screenshots they can share please?


----------



## tc2000 (Mar 7, 2007)

Evening... this looks great. I'm probably not running something right, but after installing and running the program, and then pressing pause to create a folder, I get the following error log.

TiVo plays the first couple of seconds and I get the message box on screen but then it just stays there. After a while I pressed TiVo on the remote and this took me back to TiVo Central.

I followed all of the implementation except for the 'magic program'.

Any ideas ??? Thanks!


```
22:29:32 MWAPP: Trigger ContextLeave 7
22:29:32 MWAPP: Trigger ContextEnter 6
22:29:33 backhaul 3
22:29:33 playing 13954 1095
22:29:33 playing show EP7206345067
22:29:33 MWAPP: Trigger Play 28 13954 1095 -1 EP7206345067
22:29:33 Create folder request
22:29:35 Creating New Folder Come Dine with Me
22:29:35 Cannot find folder Come Dine with Me
22:29:35 Come Dine with Me
22:29:35 error calling package can't open object (0x00021004)

22:29:35 can't open object (0x00021004)

    while executing
"db $db openidconstruction $id $sub"
    ("foreach" body line 6)
    invoked from within
"foreach id $recordings {

            incr eps
            set sub "10"

            set recording [db $db openidconstruction $id $sub]
     ..."
    ("uplevel" body line 15)
    invoked from within
"uplevel $body"
    invoked from within
"transaction {uplevel $body}"
    (procedure "RetryTransaction" line 5)
    invoked from within
"RetryTransaction {
        set duration 0
        set newtitle ""
        set parttime 0
        set eps 0
        set multirec [db $db create Recordi..."
    (procedure "BuildFolder" line 13)
    invoked from within
"BuildFolder $serieslist "$seriesname" $FOLDER_DATE  $azTime"
    (procedure "::aSort::CreateFolder" line 104)
    invoked from within
"::aSort::CreateFolder $seriesname """
    (procedure "::NewFolders::Play" line 45)
    invoked from within
"::NewFolders::Play 28 13954 1095 -1 EP7206345067"
    ("eval" body line 1)
    invoked from within
"eval ::${package}::${trigger} $args"
    ("uplevel" body line 2)
    invoked from within
"uplevel $body"
22:29:35 backhaul 9
```


----------



## solaise (Sep 17, 2006)

It doesn't look great to me!

I'm rather grasping at straws here.

The magic show shouldnt make a difference here - the failure is before it considers using it a few lines down

The error means that it couldn't open one of the list of recordings it thought should go into the folder.

How many episodes of "Come dine with me" did you have in Now Playing at the time?

Has you deleted any or is there any possibility that any had been deleted off the bottom of the NP list by tivo between starting NewFolders and trying to create the folder? (i.e is the tivo strapped for space at the moment?)

Have you tried creating another folder since - do you get the same error or is it just related to this one series?

How many shows do you have in Now showing by the way?

I've done some code changes to try and catch this error in a neater fashion and skip the recording which is giving problems. I will try and test and release these changes this evening. However I am no closer to figuring what the MFS error means.

The other thing to try is starting and stopping New Folders.

echo exit>/var/tmp/NewFolders_ctrl

Check trace log to see that it has indeed shutdown. Then start it again and see what happens.


Steve


----------



## tc2000 (Mar 7, 2007)

solaise said:


> How many episodes of "Come dine with me" did you have in Now Playing at the time?


Right now there are 10 episodes in Now Playing, all with the same title and no episode titles.



solaise said:


> Has you deleted any or is there any possibility that any had been deleted off the bottom of the NP list by tivo between starting NewFolders and trying to create the folder? (i.e is the tivo strapped for space at the moment?)


I don't think so, although my TiVo is always running pretty much at capacity. The oldest show in Now Playing is start of Feb (except some that I've got set to keep until I delete) and the latest Come Dining episode is 17th of Feb so quite a lot of shows inbetween.



solaise said:


> Have you tried creating another folder since - do you get the same error or is it just related to this one series?


Yes. This was actually my second attempt, and its happened on each attempt I've made... say about 10.



solaise said:


> How many shows do you have in Now showing by the way?


Right now there is Approx 250



solaise said:


> The other thing to try is starting and stopping New Folders.
> 
> echo exit>/var/tmp/NewFolders_ctrl
> 
> ...


I'm having problems shutting it down. In telnet I've entered the command from above to shut down and it responds with last line as Shutting Down but seems to hang there. I check the log and there is nothing indicating that a shut down has happened... I even tried to start it up and shut it down again, but still don't seem to be able to quit?!

As an aside question, when you run this program (or any program) using telnet can you kill the telnet window with the program still running or should I be using something else to run the program... all the other hacks I've run have been added to rc.sysinit.author so run in the background (probably a dumb question but I'm no expert on this stuff!!)

The only other thing that comes to mind, is that before I installed NewFolders I have added in episode titles to Now Playing using the original program from mikerr - would this be causing NewFolders to fall over? And is it possible for me to remove the titles using NewFolders or do I have to reuse the original version to get rid? (I've just removed them using the original version which seemed to work fine)

Thanks for your help.
Tim


----------



## ColinYounger (Aug 9, 2006)

solaise said:


> The TMS Id is the Turner?? Media Services (I guess?)


The T stands for Tribune, I believe - the company that supplies the guide data.

Also don't be worried about 'problems' cropping up even though you tested a million times. Just keep plugging away!

The mix\quantity of programmes seems to be the issue when mikerr has had a problem. I don't see you being any different.


----------



## solaise (Sep 17, 2006)

Hi Tim

Those are a comprehensive set of answers - thanks for perserving.

I am pretty sure you are shutting it down ok.

If you look below this shows me telnetting to the Tivo.
Doing a ps-ef|grep Tivo which return just one line with no mention of TivoAppSh.tcl. This tells me it isn't running.

Then I run TivoAppSh.tcl placing it in background with the &

It can still write to the terminal (but doesn't mind if you close it)

After it has started ok - I do another ps -ef command and this time I can see the TivoAppSh.tcl process running.


```
bash-2.02# ps -ef|grep Tivo
0          517   501  0 19:00 ttyp0    00:00:00 grep Tivo
bash-2.02#
bash-2.02# TivoAppSh.tcl -config NewFolders_config  &
[1] 518
bash-2.02#
bash-2.02# 19:00:27 About to load packages
19:00:27 about to open control File
19:00:27 About to startup applciation
19:00:27 registering events...
19:00:30 opening database...
19:00:31 about to load Packages
19:00:31 Analysing Now Playing List
19:00:34 errTmBackgroundHoldoff : retrying
19:00:36 errTmBackgroundHoldoff : retrying
19:00:38 errTmBackgroundHoldoff : retrying
19:00:41 adding new titles: {{Shaun the Sheep} 2890829}
19:00:41 <2890829> inserting Shaun the Sheep in DATE order
19:00:41 <2890829> updating date time 3730 65700
19:00:41 Adding Shaun the Sheep <2890829> to Shaun the Sheep <2913917>
19:00:41 Done 77 shows ( 7 shows/sec ) 10 seconds
19:00:42 turning on transaction holdoff thingy
19:00:42 NewFolders Started
19:00:42 NewFolders Started
19:00:42 NewFolders Still going!
19:00:42 NewFolders Startup Complete

bash-2.02#
bash-2.02# ps -ef|grep Tivo
0          518   501 10 19:00 ttyp0    00:00:03 tivosh /var/hack/TivoAppSh.tcl -config NewFolders_config
0          520   501  0 19:01 ttyp0    00:00:00 grep Tivo
bash-2.02
```
If I open another telnet window and type in the 
"echo exit >...." command

Then you see

```
bash-2.02# 19:08:24 woke up in control file Handler
19:08:24 got command exit
19:08:24 Shutting Down

[1]+  Done                    TivoAppSh.tcl -config NewFolders_config
bash-2.02#
bash-2.02#
```
The last few lines only appear if you hit return in the first window to get a prompt but the process has shut down when you see the Shutting Down message.

If you can make sure that its properly shut down, Start it up afresh and try one more time. Then perhaps you can send me the complete TraceLog to look at.

In some ways the problem looks similar to an occasional problem that 
tivoweb has 
http://www.tivocommunity.com/tivo-vb/archive/index.php/t-280903.html

If it doesnt go away then thats both good & bad. At least if it happens consistently I can send you a version with some more trace to try and figure out what is happening.


----------



## tc2000 (Mar 7, 2007)

Hi Steve

I followed your instructions for shutting down, and that all seemed to work ok, so happy that it is shutting down correctly.

However, when I start it back up, I still have the same problem.

I'll email you the logs so you can have a look at them!

Thanks
Tim


----------



## tc2000 (Mar 7, 2007)

Thanks for the patch. Still not quite there, I will email logs separately but below is excerpt from telnet screen after applying patch:


```
23:04:32 woke up in control file Handler
23:04:32 got command exit
23:04:32 Shutting Down

[1]+  Done                    TivoAppSh.tcl -config /var/hack/NewFolders_config
Bash /var/hack #
Bash /var/hack #export TIVOSH_POOLSIZE=2916352
Bash /var/hack #
Bash /var/hack #TivoAppSh.tcl -config /var/hack/NewFolders_config &
[1] 1052
Bash /var/hack #
Bash /var/hack #23:05:04 About to load packages
23:05:04 about to open control File
23:05:05 About to startup applciation
23:05:05 registering events...
23:05:08 opening database...
23:05:08 about to load Packages
23:05:09 Analysing Now Playing List
23:05:09 errTmBackgroundHoldoff : retrying
23:05:11 errTmBackgroundHoldoff : retrying
23:05:26 adding new titles: {{Grand Designs} 782560}
23:05:26 <782560> inserting Grand Designs in DATE order
23:05:26 <782560> updating date time 3730 75600
23:05:26 Done 226 shows ( 13 shows/sec ) 17 seconds
23:05:26 turning on transaction holdoff thingy
23:05:26 NewFolders Started
23:05:26 NewFolders Started
23:05:26 NewFolders Still going!
23:05:26 NewFolders Startup Complete
23:05:34 MWAPP: Trigger 0_Key 5
23:05:35 Context Change 2 from 0
23:05:35 MWAPP: Trigger ContextLeave 0
23:05:35 MWAPP: Trigger ContextEnter 2
23:05:35 MWAPP: Trigger 2_Key 5
23:05:36 Context Change 7 from 2
23:05:36 MWAPP: Trigger ContextLeave 2
23:05:36 MWAPP: Trigger ContextEnter 7
23:05:43 MWAPP: Trigger 7_Key 1
23:05:45 MWAPP: Trigger 7_Key 27
23:05:46 Context Change 6 from 7
23:05:46 MWAPP: Trigger ContextLeave 7
23:05:46 MWAPP: Trigger ContextEnter 6
23:05:47 backhaul 3
23:05:47 playing 13957 690
23:05:47 playing show EP7206345028
23:05:47 MWAPP: Trigger Play 28 13957 690 -1 EP7206345028
23:05:47 Create folder request
23:05:50 Creating New Folder Come Dine with Me
23:05:50 Cannot find folder Come Dine with Me
23:05:50 Come Dine with Me
23:05:50 Shows are 766311 785348 785347 785346 785345 785344 769636 720666 72066
5 720663
23:05:50 Could not create folder Come Dine with Me
23:05:50 Folder not created
23:05:50 backhaul 9
23:05:52 Context Change 7 from 6
23:05:52 MWAPP: Trigger ContextLeave 6
23:05:52 MWAPP: Trigger ContextEnter 7
23:06:05 MWAPP: Trigger 7_Key 0
23:06:07 MWAPP: Trigger 7_Key 27
23:06:08 Context Change 6 from 7
23:06:08 MWAPP: Trigger ContextLeave 7
23:06:08 MWAPP: Trigger ContextEnter 6
23:06:08 backhaul 3
23:06:08 playing 13957 1200
23:06:08 playing show EP5215475060
23:06:08 MWAPP: Trigger Play 28 13957 1200 -1 EP5215475060
23:06:08 Create folder request
23:06:09 Creating New Folder Relocation, Relocation
23:06:09 Cannot find folder Relocation, Relocation
23:06:09 Relocation, Relocation
23:06:09 next series is Come Dine with Me
23:06:09 Could not create folder Relocation, Relocation
23:06:09 Folder not created
23:06:09 backhaul 9
23:06:13 Context Change 7 from 6
23:06:13 MWAPP: Trigger ContextLeave 6
23:06:13 MWAPP: Trigger ContextEnter 7
23:08:13 MWAPP: Trigger 7_Key 0
23:08:15 MWAPP: Trigger 7_Key 27
23:08:15 Context Change 6 from 7
23:08:15 MWAPP: Trigger ContextLeave 7
23:08:15 MWAPP: Trigger ContextEnter 6
23:08:16 backhaul 3
23:08:16 playing 13957 1260
23:08:16 playing show EP4332445063
23:08:16 MWAPP: Trigger Play 28 13957 1260 -1 EP4332445063
23:08:16 Create folder request
23:08:17 Creating New Folder Grand Designs
23:08:17 Cannot find folder Grand Designs
23:08:17 Grand Designs
23:08:17 previous series is Relocation, Relocation
23:08:17 Could not create folder Grand Designs
23:08:17 Folder not created
23:08:17 backhaul 9
23:08:19 Context Change 7 from 6
23:08:19 MWAPP: Trigger ContextLeave 6
23:08:19 MWAPP: Trigger ContextEnter 7
```


----------



## ColinYounger (Aug 9, 2006)

Solaise,

Couple of points for you, if you don't mind.

<scratch point 1, I was being stoopid>

2) README addition - if you're using TiVoWebPlus 2.x you'll need to do a full reload after importing the logo to get the new channel listed.


----------



## ColinYounger (Aug 9, 2006)

Ah. An error.

```
09:39:17 Could not initialise package NewFolders  divide by zero
09:39:17 divide by zero
    while executing
"expr $i &#37; $showit"
    (procedure "DoSort" line 35)
    invoked from within
"DoSort DATE"
    (procedure "aSort::AnalyseNP" line 109)
    invoked from within
"aSort::AnalyseNP"
    (procedure "::NewFolders::Init" line 12)
    invoked from within
"::${package}::Init"
    ("uplevel" body line 2)
    invoked from within
"uplevel $body"
09:39:17 NewFolders Started
09:39:17 NewFolders Startup Complete
```
This TiVo only has three (differently titled) programmes.


----------



## ColinYounger (Aug 9, 2006)

I've tried with the patch you posted as well, and still get the divide by zero.


----------



## ColinYounger (Aug 9, 2006)

OK - hope you don't mind, but I fixed it:

*BEFORE*

```
proc DoSort {type} {
:
.
           if  { [expr $i &#37; $showit ] == 0} {
               txtout "                              [expr $i*100/$totshows]%" 2
           }
.
:
}
```
*AFTER*

```
proc DoSort {type} {
:
.
           if  { [b]$showit > 0 && [/b][expr $i % $showit ] == 0} {
               txtout "                              [expr $i*100/$totshows]%" 2
           }
.
:
}
```


----------



## ColinYounger (Aug 9, 2006)

FWIW, I'm getting the same error as Tim. I don't see any folder 'zones' in NP either.

```
10:26:50 can't create object (0x00021004)

    while executing
"db $db create Series"
    ("uplevel" body line 57)
    invoked from within
"uplevel $body"
    invoked from within
"transaction {uplevel $body}"
    (procedure "RetryTransaction" line 5)
    invoked from within
"RetryTransaction {
        set duration 0
        set newtitle ""
        set parttime 0
        set eps [llength $recordings]

        set multirec [..."
    (procedure "BuildFolder" line 15)
    invoked from within
"BuildFolder $serieslist "$seriesname" $FOLDER_DATE  $azTime"
    (procedure "::aSort::CreateFolder" line 106)
    invoked from within
"::aSort::CreateFolder $seriesname """
    ("uplevel" body line 7)
    invoked from within
"uplevel $body"
10:26:50 Could not create folder Two and a Half Men
10:26:50 can't create object (0x00021004)
```


----------



## mikerr (Jun 2, 2005)

Screenshot showing an "opened" folder:










I am having some problems with it refusing to create folders for some shows thinking the folder exists when it doesn't:


> Folder Mythbusters Already Exists
> error calling package can't read "fldData(Mythbusters)": no such element in array


and also it sometimes doesn't create the folder object,
but does rename all the shows in the folder so I can't see which is which...!

The latter is fixed by changing channel (which triggers the cleanup) though.

I've added that transactionholdoff to sortnp though... it speeds up things 2x


----------



## solaise (Sep 17, 2006)

Mike

Yes thats the speed up I thought you would get - waiting for mwstate is most of the rest I think.

Do you have any more of the error log? - I suspect that the array not existing is a follow on error from a folder create that failed. I'd be interested to see if you are having mfs errors in the same BuildFolder function. The first patch I gave Tim managed to disable error reporting on what went wrong!

I'm scratching my head a bit at the moment - I cant understand why the code from merge.tcl is failing.
I am wondering whether I should try going back to the main screen in Tivo to create the folder like you did - perhaps its asking too much to play even a paused recording, record live tv and do the mfs.

What I plan to do is give Tim and Colin a standalone utility (maybe even a modded sortnp!!!) to see if we can create some folders on their systems.

Thanks for posting the screenshot btw - I haven't figured out how to do that yet - but here are a couple of pics as attachments showing your folder icon in all it glory!!
Folders2 shows the top of the folders zone with a new
recording that hasn't been loaded sitting above it.

Folders 1 shows the bottom of the folders zone with the
"Magic" Recording acting as a divider from the normal now playing zone. The green blob on Shaun means that a new recording has recently been added to the folder.


Steve


----------



## ColinYounger (Aug 9, 2006)

I have a suspicion that that the (0x00021004) error is something akin to 'table locked' - our little TiVos are rather underpowered and with all the constant recording, keypresses and other events occasionally ends up in with an event queue (i.e. a list of things to do) which it kicks off in parallel causing blockages.

I'm surprised that the problem occurs on my 'play' TiVo (the one with only three shows) as it doesn't 'do' an awful lot - there aren't even a ton of hacks on it.

I felt brave and put it on the main TiVo (the one I get a severe bruising on when I disrupt it) and the same problem.

Is there anything I can do to give you more info - I can tweak myself if required (see above )? I notice that my 0x00021004 happens in a different routine from Tim's.

Oh - it's also worth noting that I haven't ever tried sortnp (sorry, mikerr!). Is there perhaps something in that hack package that yours is missing...?


----------



## ColinYounger (Aug 9, 2006)

Oh - and again, don't be disheartened. I'm willing to plug away at this for you. :up:


----------



## mikerr (Jun 2, 2005)

solaise said:


> Do you have any more of the error log? - I suspect that the array not existing is a follow on error from a folder create that failed. I'd be interested to see if you are having mfs errors in the same BuildFolder function.


Yes, its in the merge part:

```
13:33:40 Create folder request
13:33:41 Creating New Folder Top Gear
13:33:41 Cannot find folder Top Gear
13:33:41 Top Gear
13:33:41 previous series is Zoo Days
13:33:41 next series is The Twilight Zone
13:33:41 error calling package can't open object (0x00021004)

13:33:41 can't open object (0x00021004)

    while executing
"db $db openidconstruction $id $sub"
    ("foreach" body line 6)
    invoked from within
"foreach id $recordings {
```
Note it does this for some, but works for others 
It may just need a 1 second delay...


> I am wondering whether I should try going back to the main screen in Tivo to create the folder like you did - perhaps its asking too much to play even a paused recording, record live tv and do the mfs.


The now-playing screen is to be avoided when doing anything with mfs,
but you could just "left key" back onto the program description screen after getting the fsid, and do it the rest there.

I suspect 0x00021004 is caused by a timeout - I've actually seen that error in the GUI when cancelling/redoing a recording after a clash


----------



## solaise (Sep 17, 2006)

Mike/Colin

Thanks for the help/thoughts etc

Colin I will try and put together a new version this evening to try out some of the ideas. If you want to try a quick test in advance of that then find the CreateFolder procedure in advSort.tcl


```
proc CreateFolder {seriesname serieslist} {
    global    db
    IncludeAllVars

    TRACE "Creating New Folder $seriesname"

    set now [clock seconds]
    set errcount 0

    # If we havent been given the entries for the folder look for matches
```
and insert after the TRACE statement

*after 3000 *

That will give a 3 second delay. If that works then we can try reducing it down.

My Tivo has about 90 shows on it but it does have a cachecard with 512MB - I wonder if that could explain why I don't see these errors?? Its running endpad and Tivoweb but not much else.

Steve


----------



## tc2000 (Mar 7, 2007)

Hi Steve

Ok loaded 2nd patch, and get below error when starting up:


```
Bash /var/hack/lib #tar -xvf NewFolders_patch_v1.2.tar
NewFolders/
NewFolders/advSort.tcl
NewFolders/dbFuncs.tcl
NewFolders/dbFuncs_old.tcl
NewFolders/newFolders.tcl
NewFolders/pkgIndex.tcl
Bash /var/hack/lib #
Bash /var/hack/lib #TivoAppSh.tcl -config /var/hack/NewFolders_config &
[1] 1503
Bash /var/hack/lib #
Bash /var/hack/lib #18:46:02 About to load packages
18:46:02 about to open control File
18:46:02 About to startup applciation
18:46:02 registering events...
18:46:05 opening database...
18:46:06 about to load Packages
18:46:06 Analysing Now Playing List
18:46:07 Could not initialise package NewFolders  syntax error in expression "86
400 * 13958 + "
18:46:07 syntax error in expression "86400 * 13958 + "
    while executing
"expr 86400 * $a + $b"
    (procedure "TivoDtToClockTime" line 2)
    invoked from within
"TivoDtToClockTime $currStopDate $currStopTime"
    (procedure "::dbase::ReadNPEntryInTrans" line 64)
    invoked from within
"::dbase::ReadNPEntryInTrans $name $fsid"
    ("uplevel" body line 3)
    invoked from within
"uplevel $body"
    invoked from within
"ForeachMfsFileTrans fsid name "tyDb" "/Recording/NowShowing" $prefix $::CONFIG:
:mfs_bucket {
          # Read an entry - returns ""  if a recording in..."
    (procedure "aSort::AnalyseNP" line 20)
    invoked from within
"aSort::AnalyseNP"
    (procedure "::NewFolders::Init" line 12)
    invoked from within
"::${package}::Init"
    ("uplevel" body line 2)
    invoked from within
"uplevel $body"
18:46:07 turning on transaction holdoff thingy
18:46:07 NewFolders Started
18:46:07 NewFolders Started
18:46:07 NewFolders Still going!
18:46:07 NewFolders Startup Complete
```
Did I miss out a step?


----------



## solaise (Sep 17, 2006)

Tim

No but I suspect I may have done! - will take a look.

Ok it means that there is a recording with a stop time of "" which is a bit strange. It shouldn't have much impact but if you recovered the original dates then it would fix it.

Steve


----------



## solaise (Sep 17, 2006)

I've put a new version in the first post - includes some of the error handling from the patches plus waits one second before trying to create folder. This delay can be increased or decreased from the config - see README.


----------



## tc2000 (Mar 7, 2007)

Hi...

Got new version copied over and still getting errors so was going to amend the config file.



> The folder creation seems unreliable on other Tivos and doesn't work at all on some. This release tries to put a configurable delay in of 1s
> 
> new config values
> 
> ...


Where exactly should I put the delay config (nb the config file in the new release is an old file - wasn't sure if there was meant to be a new one?)?? Also, what values should we use for delays - in earlier post it says 3000 = 3 seconds. Is that what we put in the config?

Thanks
Tim


----------



## solaise (Sep 17, 2006)

Hi tim

yes try

set folderCreateDelay 3000

put it somewhere near the end.

...and see what happens - you need to stop and start NewFolders after doing this.

If that doesnt work then I will try jumping back into the main menu of the GUI or just create a stand alone program to create folders.

I'm sorry this is proving to be such a pain!

Steve


----------



## tc2000 (Mar 7, 2007)

Hi Steve... gave that a go but unfortunately still not working 

Thanks
Tim


----------



## solaise (Sep 17, 2006)

Ok Tim

New version 1.3 . There is a new config option which can be set to cause it to switch to Tivo Central when it tries to create the folder - see if this helps.

You need to edit the new config file to uncomment the line to make it work the new way. You shouldnt see the pop up message over the video, instead it should skip to the Tivo Main menu

Steve


----------



## solaise (Sep 17, 2006)

Colin

If the latest version doesn't work then I would like you to try creating a folder by hand for me on your 3 show tivo!

The attachment is a script CreateFolder.tcl which I would like you to ftp as binary to /var/hack

Its designed so I could call from NewFolders so it isn't exactly user friendly so read very carefully!!

you run it as

CreateFolder.tcl "folder name" date time fsid1 fsid2

The folder name is the name of the series and must be in double quotes.

The date is a a number and should always be 10957

The time is a unique value between 1 and 86400 and must be different for each folder. The display sequence is determined by the value - if you create more than one folder leave a gap of a few hundred.

The Fsids are the ids of the shows to go into the folder

The process goes like this.

1) With New Folders running try and create the folder you want. Assuming it fails of course shut it down and then look at the trace. You will find a lines like


```
12:27:44 MWAPP: Trigger Play 28 13954 1320 -1 EP8156635003
12:27:44 Create folder request
12:27:44 Creating New Folder Mad Men
12:27:44 Cannot find folder Mad Men
12:27:44 Mad Men
12:27:44 Shows are 2895262 2895261
```
In this case the Fsids were 2895262 and 2895261

2) With NewFolders NOT running enter the command using your folder name and the FSIDs that you see.

So in the case above I entered

*CreateFolder.tcl "Mad Men" 10957 55320 2895262 2895261*

The 55320 is the time value I chose.

3) Startup NewFolders. It should find the folder and you should then (I hope) be able to open and close it. Nb dont forget you need to move out of and back into NowShowing after you have restarted it.

Steve


----------



## tc2000 (Mar 7, 2007)

Hi Steve... and Happy Good Friday to ya !

SUCCESS !!!

I installed new version, added config to make folder on TiVo Central and had the dealys as the defaults in the new config file.

After thinking it wasn't working, I quit and restarted it and it works a dream!

I'm loving it... well done!

OK, one small thing I noticed was that I went about creating a bunch of folders and they were all open. Then went to live tv and changed channel to see the folders get closed. This all worked, but the channel change went a bit weird, it did change the channel successfully but the Sky box looked as though it tried to change twice and on the second time only 2 numbers were showing... I guess its just all the processing going on at the same time.

On another note, it would be great if you could create folders for all shows where you have say +1 show with the same title?

Overall I think this is a great idea and now it works its even better!

Thanks again.
Tim


----------



## ColinYounger (Aug 9, 2006)

Hi Folks, sorry to be late to the party - it is Good Friday after all and I have a family to entertain with my tales of TiVo hacking. Thankfully they've all dosed off allowing me to play.

Solaise - I'll try the latest version from post 1 and report back. Sounds like you've cracked it though, according to Tim.


----------



## solaise (Sep 17, 2006)

Tim/Colin 

:up: Thats good news.

keep me posted on how it goes - might be worth going into live tv and rewinding after opening/closing a big folder and seeing if there are any glitches etc - I did a lot of testing on my tivo but it seems to have been fitted with some kind of turbo at the factory?! so perhaps we may have to do some more tuning.

Tim I will take a look at the folder close feature see if I can reduce the impact a tad - if it becomes annoying there is an option to turn it off in the config - look for the line with set autoclose 1 and comment it out. You will need to stop and restart - i do mean to implement a config reread function.

Thanks for perserving

Steve


----------



## NickB (Jun 29, 2002)

solaise said:


> 4) cd /var/hack/lib and enter
> 
> tar -xvf NewFoldersLib.tar
> 
> ...


Where can I get the tar executable?


----------



## ColinYounger (Aug 9, 2006)

OK - using the config as set in the first post files won't work on my TiVo - the familiar error.

Uncommenting "set createFolderInSitu 0" allows the folder to be created properly. I did not uncomment the delay parameters.

When man TiVo is free, I'll try it on there - loads more programs on that.


----------



## ColinYounger (Aug 9, 2006)

NickB said:


> Where can I get the tar executable?


Tar executable

FTP this file to your TiVo (into /var/hack/bin), then telnet in:

cd /var/hack/bin
mv tar.bin tar
chmod 755 tar


----------



## ColinYounger (Aug 9, 2006)

One oddity on play TiVo - not sure if my expectations are incorrect.

My NPL Reads:

Programme 1
Programme 2
Programme 3

I pressed 'pause' on Programme 1 and it created a folder. So I now have

Programme 1 (1 eps)
Programme 1
Programme 2
Programme 3

Note that there is NO indentation there. I've changed channels rewound, FFd and nothing changes in the NPL.

What *should* I be seeing here?


----------



## solaise (Sep 17, 2006)

Hi Colin 

You haven't picked the best program/example to put into a folder!

If you position on the folder and hit pause it should open the folder. This should move program 1 up to um exactly where it already is and then indent it!!! Closing the folder should unindent it. 

The point being of course is that if you have 50 programmes and 10 folders then the 10 folders appear at the top. Opening a folder will then show the programmes in the folder indented immediately following the folder. Closing the folder will put the programmes back into the list that follows the folders in their date or time order.

If you look at the pictures I posted earlier you can get more of an impression. If you create the "Magic Show" then this is used as a visual divider to separate the folders expanded or not and the ordinary shows.

You should be able to see a little more happen if you put programme 2 in a folder. Opening that folder should move programme 2 up above programme 1.

If it isnt working properly post the trace log and I will take a look


Steve


----------



## ColinYounger (Aug 9, 2006)

Solaise - I know it's not the best NPL in the world, but that's testing for ya.  My play TiVo breaks lots of things that expect a load of programs. <hee hee>

My real question is that if the folder is closed, shouldn't I either:

1) see a '~~~~~' divider
2) Not see programme 1

??


----------



## ColinYounger (Aug 9, 2006)

Oh - also, can you not extract your 'special magic programme' from your TiVo and put it in the distro?

I haven't got a VCR or recording DVD to be able to create one of my own.


----------



## solaise (Sep 17, 2006)

All programmes are always there somewhere - the only way I could hide a programme is to delete it - and I am sure you wouldn't want me to do that 

From the Tivo's point of view there is just a now playing list of shows. It doesn't know that some of those shows are my folders. So you can select a folder, change its expiry date save it to a VCR etc etc.

So when I talk about zones they just refer to the order that things appear in the NP list in the Tivo GUI.

At the top are any recordings in progress or programmes that havent been "loaded" by New Folders yet. These show up at this position because they have a date in the present - usually today!

Next appear all the folders. These appear next because they are created with a date of 1st January 2000 - so they are older than anything in the present. The "time" of the folder is chosen such that they appear in alphabetical order. If you look in CreateFolder in advSort.tcl you can see it hunt through a sorted list to select a "time".

Then appear the rest of the programmes. These appear after the folders because I change their date to be 28 years in the past which handily keeps the same day of the week etc - so in the Tivo GUI they look normal. (when you do a A-Z sort they go even further in the past back to 1972 - this last is what sortnp.tcl does as well)

When you open a folder I change the date of the shows in that folder to be on 1st jan 2000 with start times each one one second more after the folder. This moves all the shows to be positioned following the folder in the GUI. When you close the folder the dates go back to the previous value.

Because there is a visual confusion if the last folder is open between where the folders stop at the top of the shows begin I came up with the ~~~~~ line. But to get this you have to create a magic show and run SetupnewFolders which will change its title to ~~~~~s.

When Newfolders spots a new show it changes its date back 28 years and it then moves below all the folders.

SetupNewFolders has an option to restore all the dates to their original values.


----------



## solaise (Sep 17, 2006)

Colin I don't believe that discussion of video extraction is permitted on this forum! 

_What you could perhaps do is go and record 10 mins of BBC3 which isnt broadcasting until 7pm using the Tivo and use that as the magic recording. So it will just recording the banner saying it isnt broadcasting._

This wasn't a good idea see post 57


----------



## ColinYounger (Aug 9, 2006)

I'm not discussing, I'm telling.


----------



## Prof. Yaffle (Aug 2, 2002)

Just been having a play around and have come across a problem. When I select option 4 to restore the dates and titles I get "> can't read "db": no such variable"


----------



## tc2000 (Mar 7, 2007)

Hi Steve

I had a go at making the magic recording, by just recording a non-broadcasting channel. Followed the instructions to get the FSID number and updated config file. However, after closing down and restarting I get error as shown below:


```
Bash /var/tmp #TivoAppSh.tcl -config /var/hack/NewFolders_config &
[1] 192
Bash /var/tmp #
Bash /var/tmp #13:18:33 About to load packages
13:18:33 about to open control File
13:18:33 /var/tmp/NewFolders_ctrl isn't a FIFO
```
Any ideas?

Looking at NPL I do have the show with updated title of -----------------

Thanks
Tim


----------



## tc2000 (Mar 7, 2007)

OK worked out last problem. Delete the temp file its complaining about as it creates a new one if it doesn't exists.

Now I'm confused, as I have my magic programme in NPL but when I open/close folders it still plays the first few seconds of an episode in that folder... I thought it would play my magic show?

I do have the config setting:

```
#
#  Uncomment to skip back from recording to create folder
#

set createFolderInSitu 0
```
Does it not work with this setting maybe? could it ?

Thanks
Tim

p.s. just tried changing above config back to default, and whilst creating and opening/closing folders works (which was my original problem!), it still doesn't show the magic show... am I missing something?


----------



## solaise (Sep 17, 2006)

Hi Tim

The magic show will only work for new folders created after you changed the config. If you delete and recreate an existing folder you should then see it.

Steve


----------



## solaise (Sep 17, 2006)

Prof. Yaffle said:


> Just been having a play around and have come across a problem. When I select option 4 to restore the dates and titles I get "> can't read "db": no such variable"


yes sorry I will post a new version of Setup later - if you want to change it yourself then you need to insert the change in bold into the SetupNewFolders.tcl script

```
#
#  Restore dates back to original values
#
proc RestoreDates {} {

[B]global db[/B]
     ForeachMfsFile fsid name "tyDb" "/Recording/NowShowing" "" {
```


----------



## NickB (Jun 29, 2002)

ColinYounger said:


> Tar executable
> 
> FTP this file to your TiVo (into /var/hack/bin), then telnet in:
> 
> ...


Top man, cheers


----------



## LampyDave (Sep 4, 2003)

> ```
> #
> #  Restore dates back to original values
> #
> ...


You'll also need to change the case of 'date' 5 lines on from that to so that realDate has a capital 'D'


```
set realDate [dbobj $showing get Date]
```
Cheers,

Dave


----------



## solaise (Sep 17, 2006)

New version 1.4 fixes bugs in SetupNewfolders - of 8 lines 2 were duff!!!

Also some tweaks to lower impact on tv on a channel change - lower priority (possibly) and delays between each folder


----------



## Prof. Yaffle (Aug 2, 2002)

I've just noticed a problem. The programme I recorded for the magic show was one of the channels that wasn't broadcasting anything in the early ours and had the title Sign Off. One of the side effects I've noticed after removing Dynamic Folders is that all the channels that are not broadcasting anything at all now have the programme name ~~~~~~~~~~~~~~~, the episode "Folder" and the description "Please Wait - Opening or Closing a Folder". Is there any way I can reset this as it's a bit annoying when doing stuff in TiVoweb or looking at the channels on TiVo?

It never occurred to me at the time but I remember reading about it a long while ago somewhere on here.


----------



## solaise (Sep 17, 2006)

Assuming that you have deleted the "magic recording" then you need to record a few minutes of something that should be "SIGN OFF" so you have a "~~~~~" entry in Now Playing.

Then run the attached script which you need to ftp to tivo as binary. That should change it back. Can you let me know if its ok?


----------



## Prof. Yaffle (Aug 2, 2002)

Sorry it took so long to get back to you. I think TiVo's been recording pretty constantly all night. That's worked perfectly thanks. Everything's back to normal. :up:


----------



## BrianHughes (Jan 21, 2001)

solaise said:


> New version 1.4 fixes bugs in SetupNewfolders - of 8 lines 2 were duff!!!
> 
> ...


Sounds a pretty good average to me. I aspire to produce code with less than 25% of lines with errors


----------



## solaise (Sep 17, 2006)

Added Version 1.5 which includes support for a Suggestions Folders - doesnt actually show the number of shows but does act as a fast way to see what suggestions there are.

Also fixed a bug where if multiple shows were deleted in quick succession the hack could get confused about which show had been deleted and so folders could have missing episodes


----------

