View Single Post
Old 2006-07-18, 01:43   #1 (permalink)
Dirk
Portal Member
 
Join Date: Mar 2005
Location: Netherlands, Wageningen
Age: 49
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

Country:


Default Overlapping programs cleanup script for TVGuide

Being an database adminstrator myself, I have written a sql script that removes overlapping programs and leaves the smaller ones. For instance things like 'Nederland 3' and 'Z@pp', CNBC, Jetix,
or 'Science Fiction week' are automatically removed.

I have made 2 sqlscripts;
This first sqlscript only shows the results,
the second one really removes them.

The scripts can be started within 'SQLite Database Browser' found in the Docs directory of mediaportal, use the execute SQL tab.
You need to open the file TVDatabaseV21.db3
in the subdirectory database of mediaportal
Don't forget to save it before exitting SQLite Database Browser.

This is also exactly my present problem: how can I automate this?
Or can it be incorporated in mediaportal tvguide import routine itself?

The first/(show) script:
The name of the overlapping program, the names of the first and the last program within the timeframe of the overlapping program are shown.
Followed by the times:
starttime of the overlapping show,
startime of first show,
endtime of last show and the
endtime of the overlapping show

Code:
Select p1.strTitle
,      p2.strTitle
,      p3.strTitle
,      p1.iStartTime
,      p2.iStartTime
,      p3.iEndTime
,      p1.iEndTime
From   tblPrograms p1
,      tblPrograms p2
,      tblPrograms p3
where  p2.iStartTime >=  p1.iStartTime
and    p2.iEndTime   <   p1.iEndTime
and    p2.idChannel  =   p1.idChannel
and    p3.iStartTime >   p1.iStartTime
and    p3.iEndTime   <=  p1.iEndTime
and    p3.idChannel  =   p1.idChannel
The second/(delete) script:
Code:
Delete tblPrograms p1
where exists (Select 0 
              from tblPrograms p2
              where p2.iStartTime >=  p1.iStartTime
              and   p2.iEndTime   <   p1.iEndTime
              and   p2.idChannel  =   p1.idChannel)
              and  exists (Select 0 
                           from tblPrograms p3
                           where p3.iStartTime >  p1.iStartTime
                           and   p3.iEndTime   <= p1.iEndTime
                           and   p3.idChannel  =  p1.idChannel)
I hope you like it!
Dirk is offline   Reply With Quote