bugs in b5

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

bugs in b5

Post by alanbirtles »

just realised that there are some major bugs in some scripts,
"lib\XGUI_Lib.lua" should be:

Code: Select all

XGUI_Lib={}
XGUI_Lib.XS={}

XGUI_Lib.XS.Type_String=1
XGUI_Lib.XS.Type_XString=2
XGUI_Lib.XS.Type_List=3

XGUI_Lib.XS.Type = function (xstr)
if istable(xstr) then
	if xstr.Value then return XGUI_Lib.XS.Type_XString
		else return XGUI_Lib.XS.Type_List
		end
	else return XGUI_Lib.XS.Type_String
	end
end

XGUI_Lib.XS.Cat = function (xstr1,xstr2)
if not xstr1 then return xstr2
	elseif not xstr2 then return xstr1
	end
local x1type=XGUI_Lib.XS.Type(xstr1)
local x2val=XGUI_Lib.XS.Val(xstr2)
if x1type==XGUI_Lib.XS.Type_String then return xstr1..x2val
	elseif x1type==XGUI_Lib.XS.Type_XString then
		xstr1.Value=xstr1.Value..x2val
		return xstr1
	else 
		xstr1[1]=XGUI_Lib.XS.Cat(xstr1[1],x2val)
		return xstr1
		end
end

XGUI_Lib.XS.Prefix = function (xstr,str)
if not xstr then return str
	elseif not str then return xstr
	end
local xtype=XGUI_Lib.XS.Type(xstr)
if xtype==XGUI_Lib.XS.Type_String then return str..xstr
	elseif xtype==XGUI_Lib.XS.Type_XString then
		xstr.Value=str..xstr.Value
		return xstr
	else 
		xstr[1]=XGUI_Lib.XS.Prefix(xstr[1],str)
		return xstr
		end
end

XGUI_Lib.XS.Add = function (xstr1,xstr2)
if not xstr1 then return xstr2
	elseif not xstr2 then return xstr1
	end
local x1type=XGUI_Lib.XS.Type(xstr1)
local x2type=XGUI_Lib.XS.Type(xstr2)
if x1type~=XGUI_Lib.XS.Type_List then
	xstr1={xstr1}
	end
if x2type~=XGUI_Lib.XS.Type_List then
	xstr2={xstr2}
	end
local n=table.getn(xstr2)
for i=1,n do
	table.insert(xstr1,xstr2[i])
	end
return xstr1
end

XGUI_Lib.XS.Val = function (xstr)
if not xstr then	
	return ""
	end
local xtype=XGUI_Lib.XS.Type(xstr)
if xtype==XGUI_Lib.XS.Type_String then return xstr
	elseif xtype==XGUI_Lib.XS.Type_XString then return xstr.Value
		else return XGUI_Lib.XS.Val(xstr[1])
	end
end
"scripts\prog_details.lua" should be:

Code: Select all

require("XGUI_Lib")

local AddFilm
local AddMovie
local AddStars
local AddEpNums
local RepeatPrems
local AddPDateDesc
local AddPDateTitle

local function Pass1Func(proc,program)
	local cat,str,i
	XGUI.SetStatus(2,"Processing "..XGUI_Lib.XS.Val(program.Title))
	if program.Category then
		cat=XGUI_Lib.XS.Val(program.Category)
		end
	if ((cat=="Film")or(cat=="Movie")) then
		if AddFilm then
			program.Title=XGUI_Lib.XS.Prefix(program.Title,"Film:") end
		if AddMovie then
			program.Title=XGUI_Lib.XS.Prefix(program.Title,"Movie:") end
		end
	if AddStars and (program.StarRating)and(program.StarRating.Number~=0) then
		str=" "
		for i = 1,program.StarRating.Number do
			str=str.."*"
			end
		program.Title=XGUI_Lib.XS.Cat(program.Title,str)
		end
	if AddEpNums and program.Episode then
		str=nil
		if program.Episode.System=="xmltv_ns" then
			local nums={}
			for n1,n2 in string.gfind(program.Episode.Number,".*%.%s*(%d*)%s*%/%s*(%d*)%s*%..*") do
				table.insert(nums,tonumber(n1))
				table.insert(nums,tonumber(n2))
				end
			if table.getn(nums)==2 then
				if (not nums[1])and(not nums[2]) then 
					str=nil
					elseif not nums[2] then
						str=string.format("Episode %d",nums[1]+1)
						elseif not nums[1] then str=nil--print (string.format("%d episodes",nums[2]))
						else str=string.format("Episode %d of %d",nums[1]+1,nums[2])
						end
				end
			end
		if str then
			if program.Sub_Title then
				str=str.." - "
				end
			program.Sub_Title=XGUI_Lib.XS.Prefix(program.Sub_Title,str)
			end
		end
	if RepeatPrems then
		if (not program.PreviouslyShown)and(not program.Premiere) then
			program.Premiere="Not a repeat"
			end
		end
	if AddPDateDesc then
		if program.Date then
			program.Description=XGUI_Lib.XS.Cat(program.Description,"Date: "..program.Date)
			end
		end
	if AddPDateTitle then
		if program.Date then
			program.Title=XGUI_Lib.XS.Cat(program.Title," ("..program.Date..")")
			end
		end
	return program
	end

local function Pass1Start(proc)
	AddFilm=toboolean(XGUI.GetSetting(proc,"AddFilm",true))
	AddMovie=toboolean(XGUI.GetSetting(proc,"AddMovie",false))
	AddStars=toboolean(XGUI.GetSetting(proc,"AddStars",true))
	AddEpNums=toboolean(XGUI.GetSetting(proc,"AddEpNums",true))
	RepeatPrems=toboolean(XGUI.GetSetting(proc,"RepeatPrems",false))
	AddPDateDesc=toboolean(XGUI.GetSetting(proc,"AddPDateDesc",false))
	AddPDateTitle=toboolean(XGUI.GetSetting(proc,"AddPDateTitle",false))
	return XGUI.OK
	end

local function Init(proc)
	XGUI.AddSetting(proc,"AddFilm",XGUI.SettingType.Boolean,"true","Add \"Film:\" to the title of films")
	XGUI.AddSetting(proc,"AddMovie",XGUI.SettingType.Boolean,"false","Add \"Movie:\" to the title of films")
	XGUI.AddSetting(proc,"AddStars",XGUI.SettingType.Boolean,"true","Add stars to program titles")
	XGUI.AddSetting(proc,"AddEpNums",XGUI.SettingType.Boolean,"true","Add episode numbers to program subtitle")
	XGUI.AddSetting(proc,"RepeatPrems",XGUI.SettingType.Boolean,"false","Mark all non-repeats as \"Premieres\"")
	XGUI.AddSetting(proc,"AddPDateDesc",XGUI.SettingType.Boolean,"false","Add production date to description")
	XGUI.AddSetting(proc,"AddPDateTitle",XGUI.SettingType.Boolean,"false","Add production date to title")
	return XGUI.OK
	end

PostProcs.PrgDets={
	Name = "Program Details Processor",
	Version = "1.0",
	Author = "Alan Birtles",
	InfoURL = "http://www.birtles.org.uk/xmltv",
	Passes={
		Pass1={
			Start=Pass1Start,
			Type=XGUI.PassTypes.Program,
			Func=Pass1Func,
			},
		},
	Init=Init,		
	}
Post Reply