def GetLogoFolder(): CUSTOM = '1' logoType = GetLogoType() if logoType == CUSTOM: logoFolder = dixie.GetSetting('user.logo.folder') else: logoFolder = dixie.GetSetting('dixie.logo.folder') return logoFolder
def getResponse(): URL = dixie.GetVerifyUrl() USER = dixie.GetSetting('username') PASS = dixie.GetSetting('password') PAYLOAD = {'username': USER, 'password': PASS} request = requests.post(URL, data=PAYLOAD) response = request.content dixie.log(response) return response
def isUpdated(self, channelsLastUpdated, programsLastUpdated): zero = datetime.datetime.fromtimestamp(0) if channelsLastUpdated is None or channelsLastUpdated == zero: return True current = int(dixie.GetSetting('current.channels')) update = int(dixie.GetSetting('updated.channels')) if update == -1: dixie.SetSetting('updated.channels', current) return True return current != update
def loadPlaylist(self): iptv_type = dixie.GetSetting('playlist.type') IPTV_URL = '0' IPTV_FILE = '1' entries = list() label = '' value = '' if iptv_type == IPTV_FILE: path = os.path.join(dixie.GetSetting('playlist.file')) else: url = dixie.GetSetting('playlist.url') path = os.path.join(datapath, 'playlist.m3u') try: if url == '': path = os.path.join(datapath, 'playlist.m3u') else: request = requests.get(url) playlist = request.content with open(path, 'wb') as f: f.write(playlist) except: pass if os.path.exists(path): f = open(path) playlist = f.readlines() f.close() for line in playlist: if line.startswith('#EXTINF:'): label = line.split(',')[-1].strip() elif line.startswith('rtmp') or line.startswith( 'rtmpe') or line.startswith('rtsp') or line.startswith( 'http'): value = line.replace('rtmp://$OPT:rtmp-raw=', '').replace('\n', '') entries.append((label, value)) entries.sort() return entries
def CheckPlugin(): if dixie.GetSetting('MINIGUIDE') == 'false': if dixie.DialogYesNo('Would you like to install the ', 'On-Tapp.TV Mini-Guide?', 'Access our listings anywhere in Kodi!'): xbmc.executebuiltin( 'XBMC.RunScript(special://home/addons/script.tvguidedixie/install.py)' ) else: pass
def doBackup(): CUSTOM = '1' chanType = dixie.GetSetting('chan.type') logoType = dixie.GetSetting('logo.type') try: dixie.log('Backup Type: %s' % str(sys.argv[1])) except: pass dixie.log('Backup: Channel setting is %s' % chanType) dixie.log('Backup: Logo setting is %s' % logoType) if (chanType == CUSTOM) or (logoType == CUSTOM): dixie.DialogOK('It appears you are using a custom location', 'for your channels or logos (Home Networking).', 'Please back-up TV Portal manually.') return try: folder = getFolder('Please select backup folder location') if not folder: return False filename = os.path.join(folder, FILENAME) dp = dixie.Progress(LINE1, LINE2) success = doZipfile(filename, dp) dp.close() if success: dixie.DialogOK('Backup successfully created') else: dixie.DeleteFile(filename) return True except Exception, e: dixie.log(e)
def initializeChannels(self): channels = self.getAllChannels() if len(channels) == 0: dixie.SetSetting('PREVLOGO', '') return BUILTIN = '0' CUSTOM = '1' logoFolder = GetLogoFolder() logoType = GetLogoType() if logoType == CUSTOM: logoPath = '' else: logoPath = 'special://profile/addon_data/script.tvportal/extras/logos/' dixie.log('Logo Path Setting: %s' % logoPath) dixie.log('Logo Folder Setting: %s' % logoFolder) dixie.log('Logo Type: %s' % logoType) prevLogoFolder = dixie.GetSetting('PREVLOGO') currLogoFolder = logoFolder if currLogoFolder == prevLogoFolder: return True dixie.SetSetting('PREVLOGO', currLogoFolder) for ch in channels: dixie.log('### CHAN: '+str(ch)) channel = self.getChannelFromFile(ch) chtitle = channel.title if channel == None: continue # Remove the country code from the channel name so we can use a generic universal logo if chtitle.endswith(')') and chtitle[-4] == '(': country = chtitle[-5:] newname = chtitle.replace(country,'') # If country not set then don't bother replacing the country code else: newname = chtitle logoFile = os.path.join(logoPath, logoFolder, newname.replace(' ', '_') + '.png') if channel.logo <> logoFile: channel.logo = logoFile self.replaceChannel(channel) return True
def _check(): response = urllib2.urlopen(URL).read() dixie.log('Response in message._check %s' % str(response)) response = json.loads(u"" + (response)) try: currentID = dixie.GetSetting('messageID') currentID = float(currentID) except Exception, e: currentID = 0
def tidySettings(self): files = [] for i in range(10): enabled = dixie.GetSetting('INI_%d_E' % i) == 'true' if enabled: file = dixie.GetSetting('INI_%d' % i) files.append(file) print files index = 0 for file in files: if len(file) > 0: dixie.SetSetting('INI_%d' % index, file) dixie.SetSetting('INI_%d_E' % index, 'true') index += 1 for i in range(index, 10): dixie.SetSetting('INI_%d' % i, '') dixie.SetSetting('INI_%d_E' % index, 'false')
def CheckVersion(): prev = dixie.GetSetting('VERSION') curr = VERSION dixie.log('****** On-Tapp.EPG %s LAUNCHED ******' % str(VERSION)) if prev == curr: return dixie.SetSetting('VERSION', curr) dixie.DialogOK('Welcome to On-Tapp.TV 3.0', 'For online support, please register at our new forum:', 'www.on-tapp-networks.com/forum') showChangelog()
def getIniFiles(self): files = [] import glob ini = os.path.join(datapath, 'ini', '*.*') files = glob.glob(ini) for i in range(10): file = dixie.GetSetting('INI_%d' % i) if len(file) > 0: if file not in files: files.append(file) if os.path.exists(os.path.join(datapath,'addons.ini')): files.append(os.path.join(datapath, 'addons.ini')) return files
def initializeChannels(self): channels = self.getAllChannels() if len(channels) == 0: dixie.SetSetting('PREVLOGO', '') return BUILTIN = '0' CUSTOM = '1' logoFolder = GetLogoFolder() logoType = GetLogoType() if logoType == CUSTOM: logoPath = '' else: logoPath = 'special://profile/addon_data/script.tvguidedixie/extras/logos/' dixie.log('Logo Path Setting: %s' % logoPath) dixie.log('Logo Folder Setting: %s' % logoFolder) dixie.log('Logo Type: %s' % logoType) prevLogoFolder = dixie.GetSetting('PREVLOGO') currLogoFolder = logoFolder if currLogoFolder == prevLogoFolder: return True dixie.SetSetting('PREVLOGO', currLogoFolder) for ch in channels: channel = self.getChannelFromFile(ch) chtitle = channel.title if DSF: chtitle = urllib.quote_plus(channel.title) if channel == None: continue logoFile = os.path.join(logoPath, logoFolder, chtitle + '.png') if channel.logo <> logoFile: channel.logo = logoFile self.replaceChannel(channel) return True
def updateAvailable(latest): dir = datapath folder = os.path.join(dir, 'channels') files = [] try: current, dirs, files = os.walk(folder).next() except: pass if len(files) == 0: dixie.SetSetting('updated.channels', -1) #force refresh of channels return True db = os.path.join(dir, 'program.db') if not os.path.exists(db): return True current = dixie.GetSetting('epg.date') current = parseDate(current) latest = parseDate(latest) update = latest > current return update
def _initializeS(self, cancel_requested_callback): BUILTIN = '0' CUSTOM = '1' logoFolder = GetLogoFolder() logoType = GetLogoType() if logoType == CUSTOM: logoPath = '' else: logoPath = 'special://profile/addon_data/script.tvguidedixie/extras/logos/' dixie.log('Logo Path Setting: %s' % logoPath) dixie.log('Logo Folder Setting: %s' % logoFolder) dixie.log('Logo Type: %s' % logoType) prevLogoFolder = dixie.GetSetting('PREVLOGO') currLogoFolder = logoFolder if currLogoFolder == prevLogoFolder: return True channels = self.getAllChannels() for ch in channels: channel = self.getChannelFromFile(ch) if channel == None: continue logoFile = os.path.join(logoPath, logoFolder, channel.title + '.png') channel.logo = logoFile self.replaceChannel(channel) dixie.SetSetting('PREVLOGO', logoFolder) return True
def getIniFiles(self): files = [] import glob ini = os.path.join(datapath, 'ini', '*.*') files = glob.glob(ini) for i in range(10): file = dixie.GetSetting('INI_%d' % i) if len(file) > 0: if file not in files: files.append(file) files.append(os.path.join(datapath, 'addons.ini')) if LOCAL: files.append(os.path.join(datapath, 'local.ini')) if FTVINI == 'UK Links': files.append(os.path.join(datapath, 'uk.ini')) else: files.append(os.path.join(datapath, 'nongeo.ini')) return files
ACTION_DOWN = 4 ACTION_PAGE_UP = 5 ACTION_PAGE_DOWN = 6 CHANNELS_PER_PAGE = 10 ACTION_BACK = 92 ACTION_STOP = 122 ACTION_X = 13 ACTION_PARENT_DIR = 9 ACTION_PLAY = 79 ACTION_SELECT = 7 ACTION_HOTKEY = dixie.GetSetting('hot_key') ACTION_SHOW_INFO = -1 #currently not used PATH = os.path.join(dixie.PROFILE, 'extras', 'skins', dixie.SKIN) XML = 'script-tvguide-changer.xml' OTT_CHANNELS = os.path.join(dixie.GetChannelFolder(), 'channels') IGNORESTRM = dixie.GetSetting('ignore.stream') == 'true' DSF = dixie.isDSF() MAIN = 5000 EPG_CHANNEL = 6000 EPG_METADATA = 6001 OSD_MINIGUIDE = 7000
def _updateChannelAndProgramListCaches(self, date, progress_callback, clearExistingProgramList): sqlite3.register_adapter(datetime.datetime, self.adapt_datetime) sqlite3.register_converter('timestamp', self.convert_datetime) if not self._isCacheExpired(date): return self.updateInProgress = True self.updateFailed = False dateStr = date.strftime('%Y-%m-%d') try: xbmc.log('[script.tvguidedixie] Updating caches...', xbmc.LOGDEBUG) if progress_callback: progress_callback(0) if self.settingsChanged: self.source.doSettingsChanged() self.settingsChanged = False # only want to update once due to changed settings toDelete = self.getAllChannels() weight = 0 imported = imported_channels = imported_programs = 0 for item in self.source.getDataFromExternal( date, progress_callback): imported += 1 if isinstance(item, Channel): imported_channels += 1 channel = item clean = CleanFilename(channel.id) if clean in toDelete: toDelete.remove(clean) weight += 1 channel.weight = weight self.addChannel(channel) #channels updated try: settings.set('ChannelsUpdated', self.adapt_datetime(datetime.datetime.now()), settingsFile) except: pass # for id in toDelete: # self.removeCleanChannel(id) if imported_channels == 0: self.updateFailed = True if imported_programs == 0: self.updateFailed = (not USE_DB_FILE) except SourceUpdateCanceledException: # force source update on next load try: settings.set('ChannelsUpdated', 0, settingsFile) except: pass except Exception: import traceback as tb import sys (etype, value, traceback) = sys.exc_info() tb.print_exception(etype, value, traceback) try: # invalidate cached data try: settings.set('ChannelsUpdated', 0, settingsFile) except: pass except: pass self.updateFailed = True finally: update = dixie.GetSetting('updated.channels') if int(update) < 0: dixie.SetSetting('updated.channels', 0) dixie.SetSetting('current.channels', 0) else: dixie.SetSetting('current.channels', update) self.channelDict = {} self.updateInProgress = False
import os import re import datetime import urllib2 import urllib import requests import requests.packages.urllib3 requests.packages.urllib3.disable_warnings() import json import dixie import sfile DIXIEURL = dixie.GetSetting('dixie.url').upper() username = dixie.GetSetting('username') password = dixie.GetSetting('password') response = '' home = dixie.HOME datapath = dixie.PROFILE extras = os.path.join(datapath, 'extras') logos = os.path.join(extras, 'logos') logofolder = os.path.join(logos, 'None') logodest = os.path.join(logos, 'logos.zip') cookiepath = os.path.join(datapath, 'cookies') cookiefile = os.path.join(cookiepath, 'cookie') try:
ACTION_PLAY = 79 ACTION_SELECT = 7 ACTION_SHOW_INFO = -1 #currently not used PATH = os.path.join(dixie.PROFILE, 'extras', 'skins', dixie.SKIN) XML = 'script-tvguide-changer.xml' AddonID = 'script.trtv' ADDON = xbmcaddon.Addon(id=AddonID) showSFchannels = ADDON.getSetting('showSFchannels') show_social = ADDON.getSetting('show_social') SF_CHANNELS = ADDON.getSetting('SF_CHANNELS') OTT_CHANNELS = os.path.join(dixie.GetChannelFolder(), 'channels') IGNORESTRM = dixie.GetSetting('ignore.stream') == 'true' datapath = dixie.PROFILE logofolder = os.path.join(datapath, 'extras', 'logos', 'Colour Logo Pack') MAIN = 5000 EPG_CHANNEL = 6000 EPG_METADATA = 6001 OSD_MINIGUIDE = 7000 OSD_METADATA = 7001 OSD_TITLEBAR = 7002 def CleanFilename(text): text = text.replace('*', '_star') text = text.replace('+', '_plus') text = text.replace(' ', '_')
import xbmc import xbmcaddon import download import extract import datetime import os import dixie ADDON = xbmcaddon.Addon(id = 'script.tvguidedixie') datapath = xbmc.translatePath(ADDON.getAddonInfo('profile')) extras = os.path.join(datapath, 'extras') logos = os.path.join(extras, 'logos') nologos = os.path.join(logos, 'None') dest = os.path.join(extras, 'logos.zip') logopack = dixie.GetSetting('dixie.logo.folder') url = dixie.GetExtraUrl() + 'resources/logos.zip' try: if not os.path.exists(logos): os.makedirs(logos) os.makedirs(nologos) except: pass download.download(url, dest) if os.path.exists(logos): now = datetime.datetime.now() date = now.strftime('%B-%d-%Y %H-%M')
from strings import * import xbmc import xbmcgui import xbmcvfs import sqlite3 from channel import Channel import dixie import settings import sfile import re import io SOURCE = dixie.GetSetting('source') DIXIEURL = dixie.GetSetting('dixie.url').upper() GMTOFFSET = dixie.GetGMTOffset() datapath = dixie.PROFILE settingsFile = os.path.join(datapath, 'settings.cfg') USE_DB_FILE = True SETTINGS_TO_CHECK = ['dixie.url'] channelFolder = dixie.GetChannelFolder() channelPath = os.path.join(channelFolder, 'channels') dixie.log('Channel Folder Setting: %s' % channelPath) try:
def getPassword(): return dixie.GetSetting('password') def getAccount(): return {'log': getUsername(), 'pwd': getPassword(), 'wp-submit': 'Log In'} def getPayload(): return urllib.urlencode(getAccount()) ADDON = xbmcaddon.Addon(id='script.tvguidedixie') DIXIEURL = dixie.GetSetting('dixie.url').upper() baseurl = dixie.GetLoginUrl() datapath = xbmc.translatePath(ADDON.getAddonInfo('profile')) cookiepath = os.path.join(datapath, 'cookies') cookiefile = os.path.join(cookiepath, 'on-tapp.lwp') urlopen = urllib2.urlopen Request = urllib2.Request cj = cookielib.LWPCookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) if not os.path.exists(cookiepath): try: os.makedirs(cookiepath) except:
def GetLogoType(): return dixie.GetSetting('logo.type')
def getUsername(): return dixie.GetSetting('username')
# import xbmc from xml.etree import ElementTree from xml.parsers.expat import ExpatError import ConfigParser import os import re import xbmcaddon import urllib import requests import dixie ADDON = dixie.ADDON LOCAL = dixie.GetSetting('local.ini') == 'true' FTVINI = dixie.GetSetting('ftv.ini') datapath = dixie.PROFILE class StreamsService(object): def __init__(self): self.addonsParser = ConfigParser.ConfigParser(dict_type=OrderedDict) self.addonsParser.optionxform = lambda option: option iniFiles = self.getIniFiles() for file in iniFiles: try: self.addonsParser.read(file)
def getPassword(): return dixie.GetSetting('password')
import buggalo import xbmcaddon import xbmcplugin from strings import * import xbmc import xbmcgui import xbmcvfs import sqlite3 import dixie import settings import re import io SOURCE = dixie.GetSetting('source') DIXIEURL = dixie.GetSetting('dixie.url').upper() DIXIELOGOS = dixie.GetSetting('dixie.logo.folder') GMTOFFSET = dixie.GetGMTOffset() datapath = xbmc.translatePath( 'special://profile/addon_data/script.tvguidedixie/') channelPath = os.path.join(datapath, 'channels') extras = os.path.join(datapath, 'extras') logopath = os.path.join(extras, 'logos') username = ADDON.getSetting('username') password = ADDON.getSetting('password') LOGOCHANGED = DIXIELOGOS != ADDON.getSetting('PREVLOGO') if LOGOCHANGED:
import xbmc from xml.etree import ElementTree from xml.parsers.expat import ExpatError import ConfigParser import os import re import xbmcaddon import urllib import requests import json import dixie ADDON = dixie.ADDON SF_METALLIQ = dixie.GetSetting('SF_METALLIQ') autoplay = dixie.GetSetting('autoplay') LOCAL = dixie.GetSetting('local.ini') == 'true' FTVINI = dixie.GetSetting('ftv.ini') datapath = dixie.PROFILE class StreamsService(object): def __init__(self): self.addonsParser = ConfigParser.ConfigParser(dict_type=OrderedDict) self.addonsParser.optionxform = lambda option: option iniFiles = self.getIniFiles() for file in iniFiles:
# import xbmc import xbmcaddon import os import sfile import dixie ottv = xbmcaddon.Addon('script.on-tapp.tv') ottvdir = ottv.getAddonInfo('profile') ottvskin = os.path.join(ottvdir, 'skins') settings = xbmc.translatePath('special://profile/settings.bak') OTTVURL = ottv.getSetting('ottv.url').upper() OTEPGURL = dixie.GetSetting('dixie.url').upper() def resetAddon(): if OTEPGURL == 'OTHER': ottv.setSetting('ottv.url', 'other') ottv.setSetting('SKIN', 'OTT-Skin') if OTTVURL == 'OTHER': dixie.SetSetting('dixie.url', 'Other') dixie.SetSetting('dixie.skin', 'EPG-Skin') try: sfile.rmtree(dixie.PROFILE) sfile.rmtree(ottvskin) sfile.remove(settings)
def checkSettings(): validator = dixie.GetSetting('validator') return validator != '0'