freeview channel time limiter

Discussion of Version 3 and developing lua grabbers
Post Reply
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

freeview channel time limiter

Post by alanbirtles »

I have made a new script that limits freeview channels to the time when they are broadcast:

Code: Select all

local channels={{id="1856",start=6,stop=18}}

local function Pass1Func(proc,program)
	local dst,starthour,stophour
	local i,n
	XGUI.SetStatus(2,"Processing "..XGUI_Lib.XS.Val(program.Title))
	dst=time.IsEUDST(program.Start)
	if dst then
		starthour=program.Start.Hour+1
		stophour=program.Stop.Hour+1
		else 
			starthour=program.Start.Hour
			stophour=program.Stop.Hour
			end
	n=table.getn(channels)
	for i=1,n do
		if program.Channel==channels[i].id then
			if (starthour<channels[i].start)or(stophour<channels[i].start)
				or(starthour>=channels[i].stop)or(stophour>channels[i].stop)
				or((stophour==channels[i].stop)and(program.Stop.Minute>0))
				or((stophour==channels[i].start)and(program.Stop.Minute==0)) then 
					return XGUI.OK
					else return program
					end
			end
		end
	return program
	end

PostProcs.UK_RT_Free_Limit={
	Name = "UK - Radio Times freeview channel time limiter",
	Version = "1.0",
	Author = "Alan Birtles",
	InfoURL = "http://www.birtles.org.uk/xmltv",
	Grabber = "UK_RT",
	Passes={
		Pass1={
			Type=XGUI.PassTypes.Program,
			Func=Pass1Func,
			},
		},
	}
save to scripts\uk_rt\ukrt_freeview_limit.lua
to add additional channels simply add a channels id its start and stop hour to the array at the top of the script
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

a small mistake in the script (corrected above),

Code: Select all

return program
should be added to the end of the function
andyrogers
Posts: 2
Joined: Tue Jan 17, 2006 9:59 pm

Post by andyrogers »

Alan

Ho do I go about putting an entry in to limit the EPG to a channel time which crosses into the next day.

IE UKTV Gold, broadcasts 12pm-5am the next morning. When I try all I get is no EPG data in this channel.

Also Discovery channel, whcih broadcasts 12pm-midnight.
WHen I put in either 0 as a stop, or 24 it cuts off the EPG at 23 hours.

Thanks

Andy
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

try this it seems to work reasonably well here:

Code: Select all

local function Pass1Func(proc,program)
	local dst,starthour,stophour
	local i,n
	XGUI.SetStatus(2,"Processing "..XGUI_Lib.XS.Val(program.Title))
	dst=time.IsEUDST(program.Start)
	if dst then
		starthour=program.Start.Hour+1
		stophour=program.Stop.Hour+1
		else 
			starthour=program.Start.Hour
			stophour=program.Stop.Hour
			end
	n=table.getn(channels)
	for i=1,n do
		if program.Channel==channels[i].id then
			local start1=channels[i].start
			local stop1=channels[i].stop
			if start1<stop1 then
				if (((starthour>=start1)and(stophour<stop1))
					or((stophour==stop1)and(program.Stop.Minute==0)))
					and((stop1==0)or(stophour>=starthour)) then 
						return program
						else return XGUI.OK
						end
				else
				if (starthour>=start1)
					or (stophour<stop1)
					or ((stophour==stop1)and(program.Stop.Minute==0))then 
						return program
						else return XGUI.OK
						end				
				end
			end
		end
	return program
	end
andyrogers
Posts: 2
Joined: Tue Jan 17, 2006 9:59 pm

Post by andyrogers »

Alan

Thanks for this reply the other day, you were quick & it worked fine.

Is it possible to amend this script to display a message like "Closedown" when the programs are not broadcasting on the EPG grid instead, as it just shows No Epg data avaibale in my software.

Thanks

Andy
alanbirtles
Site Admin
Posts: 495
Joined: Mon Sep 06, 2004 4:44 pm

Post by alanbirtles »

you could change each

Code: Select all

else return XGUI.OK
to

Code: Select all

else
	local p2={}
	p2.Start=program.Start
	p2.Stop=program.Stop
	p2.Channel=program.Channel
	p2.Title="Closedown"
	p2.Description="Channel currently off air"
	return p2
which would just change the title of each program to "Closedown" instead of deleting them completely. a full solution would be much mroe complex
Post Reply