pcall (dofile,m_simpleTV.MainScriptDir .. "lib/channel_filter.lua")
pcall (dofile,m_simpleTV.MainScriptDir .. "lib/epg_filter.lua")

------------------------------------------------------------------
local function GetAllEpgForChannel(Name)
  
  local t={}
  local w=1
  for i=1,#epgFilterTable do
   if Name == epgFilterTable[i][1] then
      t[w]=epgFilterTable[i]
      w=w+1  	  
  end 
 end
  return t
end
------------------------------------------------------------------
--called from core
------------------------------------------------------------------
function GetEpgShiftByChannelName(OldName)
 
 if epgFilterTable~=nil then 
 local t = GetAllEpgForChannel(OldName)
   for i=1,#t do
    local q = m_simpleTV.Database.GetTable('SELECT ProgChannel.Id FROM ProgChannel WHERE (ProgChannel.NameChannel="' ..  m_simpleTV.Common.string_toUTF8(t[i][2],1251) .. '");',false)
    if q~=nil and q[1]~=nil and q[1].Id~=nil then
			return t[i][2],-t[i][3]*2
    end			
   end 
  if #t>=1 then return t[1][2],-t[1][3]*2 end
 end
  
 local shift = string.match(OldName,'%([+-]?%d+%)')
 if shift == nil then 
   OldName = string.gsub(OldName,'%(.-%)','')
   --debug_in_file(OldName .. '\n')
   return OldName,-1000
 end
 --debug_in_file(shift)
 OldName  = string.gsub(OldName,'%([+-]?%d+%)','')
 shift = string.gsub(shift,'[%(%)%+]','')
 shift = -tonumber(shift)
 if shift<-24 or shift>24 then shift=-500 end
 return OldName,shift*2
end
------------------------------------------------------------------ 
--called from core
------------------------------------------------------------------
function ClearChannelNameForLogo(OldName)
 OldName  = string.gsub(OldName,'%([+-]?%d+%)','')
 OldName = string.gsub(OldName,'%(ΔΣΑΛά)','')
 OldName = string.gsub(OldName,'%(δσαλό)','')
 return OldName
end
------------------------------------------------------------------ 
--called from core
------------------------------------------------------------------ 
function ChangeChannelName(OldName,MassNames)

 if MassNames==nil then 
  if DefaultMassNames==nil then return OldName end
  MassNames=DefaultMassNames 
 end

 for i=1,#MassNames do  
   if OldName==MassNames[i][1] then return MassNames[i][2] end
 end

 return OldName
end
------------------------------------------------------------------
