too many changes to really list
This commit is contained in:
parent
74d206d5e0
commit
c571c967bf
11
launch.py
11
launch.py
|
@ -1,13 +1,8 @@
|
|||
import mc
|
||||
import time
|
||||
from mythboxee import MythBoxee
|
||||
|
||||
# DEBUG #
|
||||
#mc.GetApp().GetLocalConfig().SetValue("dbconn", "")
|
||||
#mc.GetApp().GetLocalConfig().ResetAll()
|
||||
# DEBUG #
|
||||
|
||||
# We'll use this to determine when to reload data.
|
||||
mc.GetApp().GetLocalConfig().SetValue("LastRunTime", str(time.time()))
|
||||
mc.GetApp().GetLocalConfig().SetValue("CurrentShowItemID", "0")
|
||||
|
||||
# Activate Loading Window
|
||||
mc.ActivateWindow(14001)
|
||||
mc.ActivateWindow(14001)
|
299
mythboxee.py
299
mythboxee.py
|
@ -1,5 +1,6 @@
|
|||
import mc
|
||||
import re
|
||||
import sys
|
||||
import random
|
||||
import time
|
||||
import pickle
|
||||
|
@ -10,8 +11,8 @@ from operator import itemgetter, attrgetter
|
|||
|
||||
class MythBoxee:
|
||||
logLevel = 1
|
||||
version = "4.0.beta"
|
||||
userAgent = "MythBoxee v4.0.beta"
|
||||
version = "4.0.1.beta"
|
||||
userAgent = "MythBoxee"
|
||||
tvdb_apikey = "6BEAB4CB5157AAE0"
|
||||
be = None
|
||||
db = None
|
||||
|
@ -23,16 +24,68 @@ class MythBoxee:
|
|||
series = {}
|
||||
|
||||
|
||||
"""
|
||||
__init__ - Lets make a connection to the backend!
|
||||
"""
|
||||
def __init__(self):
|
||||
self.log("def(__init__): Start =========================================================")
|
||||
self.log("def(__init__): Version: " + self.version)
|
||||
self.log("def(__init__): Python Version: " + str(sys.version_info))
|
||||
|
||||
self.config = mc.GetApp().GetLocalConfig()
|
||||
|
||||
# We'll use this to determine when to reload data.
|
||||
self.config.SetValue("LastRunTime", str(time.time()))
|
||||
self.config.SetValue("CurrentShowItemID", "0")
|
||||
|
||||
# If this is the first time the app is being run, lets set some default options.
|
||||
if not self.config.GetValue("app.firstrun"):
|
||||
self.config.SetValue("SortBy", "Original Air Date")
|
||||
self.config.SetValue("SortDir", "Descending")
|
||||
self.config.SetValue("Filter", "All")
|
||||
self.config.SetValue("StreamMethod", "XML")
|
||||
self.config.SetValue("app.firstrun", "true")
|
||||
|
||||
|
||||
# If dbconn isn't set, we'll assume we haven't found the backend.
|
||||
if not self.config.GetValue("dbconn"):
|
||||
mc.ActivateWindow(14004)
|
||||
else:
|
||||
# Now that the backend has been discovered, lets connect.
|
||||
try:
|
||||
self.log("def(__init__): Attempting Database Connection ...")
|
||||
self.dbconf = eval(self.config.GetValue("dbconn"))
|
||||
self.db = mythtv.MythDB(**self.dbconf)
|
||||
except MythError, e:
|
||||
self.log("def(__init__): Error: " + e.message)
|
||||
mc.ShowDialogNotification("Failed to connect to the MythTV Backend")
|
||||
mc.ActivateWindow(14004)
|
||||
else:
|
||||
self.log("def(__init__): Database Connection Successful")
|
||||
try:
|
||||
self.log("def(__init__): Attempting Connection to Backend")
|
||||
self.be = mythtv.MythBE(db=self.db)
|
||||
except MythError, e:
|
||||
self.log("def(__init__): Connection to Backend FAILED")
|
||||
self.log("def(__init__): MythBE Error: " + e.message)
|
||||
mc.CloseWindow()
|
||||
else:
|
||||
self.log("def(__init__): Connection to Backend Successful")
|
||||
self.GetRecordings()
|
||||
|
||||
self.log("def(__init__): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
DiscoverBackend - just as it sounds
|
||||
|
||||
|
||||
Attempt to discover the MythTV Backend using UPNP protocol, once found
|
||||
try and gather MySQL database connection information using default PIN
|
||||
via the XML interface. If that fails then prompt user to enter their
|
||||
custom SecurityPin, if we fail to gather database information that way
|
||||
finally prompt user to enter their credentials manually.
|
||||
"""
|
||||
def DiscoverBackend():
|
||||
def DiscoverBackend(self):
|
||||
self.log("def(DiscoverBackend): Start =========================================================")
|
||||
|
||||
pin = self.config.GetValue("pin")
|
||||
|
@ -42,87 +95,61 @@ class MythBoxee:
|
|||
pin = 0000
|
||||
|
||||
try:
|
||||
self.log("def(DiscoverBackend): Attempting Database Connection ...")
|
||||
self.db = mythtv.MythDB(SecurityPin=pin)
|
||||
except Exception, e:
|
||||
if e.ename == 'DB_CREDENTIALS' and count < 2:
|
||||
## Jump to Settings Window
|
||||
self.log("def(DiscoverBackend): Error: Database Credentials")
|
||||
elif e.ename == 'DB_CONNECTION' or e.ename == 'DB_CREDENTIALS' and count > 3:
|
||||
## Jump to Settings Window
|
||||
self.log("def(DiscoverBackend): Error: Database Connection")
|
||||
self.log("def(DiscoverBackend): Exception: " + str(e.ename))
|
||||
self.log("def(DiscoverBackend): End ===========================================================")
|
||||
return False
|
||||
else:
|
||||
# We have a successful connection, save database information
|
||||
self.config.SetValue("dbconn", str(self.db.dbconn))
|
||||
|
||||
self.log("def(DiscoverBackend): Database Connection Successful")
|
||||
self.log("def(DiscoverBackend): End ===========================================================")
|
||||
return True
|
||||
|
||||
|
||||
"""
|
||||
__init__ - Lets make a connection to the backend!
|
||||
"""
|
||||
def __init__(self):
|
||||
self.log("def(__init__): Start =========================================================")
|
||||
self.log("def(__init__): Version: " + self.version)
|
||||
|
||||
self.config = mc.GetApp().GetLocalConfig()
|
||||
|
||||
# If this is the first time the app is being run, lets set some default options.
|
||||
if not self.config.GetValue("firstrun"):
|
||||
self.config.SetValue("SortBy", "Original Air Date")
|
||||
self.config.SetValue("SortDir", "Descending")
|
||||
self.config.SetValue("Filter", "All")
|
||||
self.config.SetValue("firstrun", "1")
|
||||
|
||||
# If dbconn isn't set, we'll assume we haven't found the backend.
|
||||
if not self.config.GetValue("dbconn"):
|
||||
discoverBackend = False
|
||||
while discoverBackend is False:
|
||||
discoverBackend = self.DiscoverBackend()
|
||||
|
||||
# Parse our DB info into useable format
|
||||
dbconf = eval(self.config.GetValue("dbconn"))
|
||||
self.dbconf = dbconf
|
||||
|
||||
# Now that the backend has been discovered, lets connect.
|
||||
try:
|
||||
self.db = mythtv.MythDB(**dbconf)
|
||||
except MythError, e:
|
||||
mc.ShowDialogNotification("Failed to connect to the MythTV Backend")
|
||||
self.log(e.message)
|
||||
else:
|
||||
self.be = mythtv.MythBE(db=self.db)
|
||||
self.GetRecordings()
|
||||
|
||||
self.log("def(__init__): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
LoadMain - Loader for Main Window
|
||||
"""
|
||||
def LoadMain(self):
|
||||
self.log("def(LoadMain): Start =========================================================")
|
||||
mc.ShowDialogWait()
|
||||
self.config.SetValue("loadingmain", "true")
|
||||
|
||||
if not self.config.GetValue("dbconn"):
|
||||
return False
|
||||
|
||||
## Put focus on last selected item
|
||||
itemId = int(self.config.GetValue("CurrentShowItemID"))
|
||||
if itemId and itemId != 0:
|
||||
mc.GetWindow(14001).GetList(1030).SetFocusedItem(itemId)
|
||||
|
||||
mainList = mc.GetWindow(14001).GetList(1030)
|
||||
mainListitems = mainList.GetItems()
|
||||
mainLength = len(mainListitems)
|
||||
lastruntime = self.config.GetValue("LastRunTime")
|
||||
cacheTime = self.config.GetValue("cache.time")
|
||||
mainItems = len(mc.GetWindow(14001).GetList(1030).GetItems())
|
||||
|
||||
if mainLength == 0 or lastruntime <= str(time.time() - 3060):
|
||||
# Lets get the recordings
|
||||
if not cacheTime or mainItems == 0 or cacheTime <= str(time.time() - 2400):
|
||||
self.SetShows()
|
||||
|
||||
mc.HideDialogWait()
|
||||
self.config.Reset("loadingmain")
|
||||
self.log("def(LoadMain): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
RefreshMain - Refresh the Main Window
|
||||
"""
|
||||
def RefreshMain(self):
|
||||
self.log("def(RefreshMain): Start =========================================================")
|
||||
self.config.SetValue("loadingmain", "true")
|
||||
|
||||
self.config.Reset("cache.time")
|
||||
self.GetRecordings()
|
||||
self.SetShows()
|
||||
|
||||
self.config.Reset("loadingmain")
|
||||
self.log("def(RefreshMain): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
GetRecordings - Pulls all of the recordings out of the backend and prepares them for use in the app.
|
||||
|
||||
|
@ -131,6 +158,7 @@ class MythBoxee:
|
|||
"""
|
||||
def GetRecordings(self):
|
||||
self.log("def(GetRecordings): Start =========================================================")
|
||||
self.config.SetValue("loadingmain", "true")
|
||||
|
||||
# Empty out crucial info
|
||||
self.titles = []
|
||||
|
@ -139,10 +167,11 @@ class MythBoxee:
|
|||
self.shows = {}
|
||||
|
||||
cacheTime = self.config.GetValue("cache.time")
|
||||
mainItems = len(mc.GetWindow(14001).GetList(1030).GetItems())
|
||||
|
||||
self.recs = self.be.getRecordings()
|
||||
|
||||
if not cacheTime or cacheTime <= str(time.time() - 3600):
|
||||
if not cacheTime or mainItems == 0 or cacheTime <= str(time.time() - 2400):
|
||||
x=0
|
||||
for recording in self.recs:
|
||||
if recording.title not in self.titles:
|
||||
|
@ -169,6 +198,7 @@ class MythBoxee:
|
|||
|
||||
self.titles.sort()
|
||||
|
||||
self.config.Reset("loadingmain")
|
||||
self.log("def(GetRecordings): End ===========================================================")
|
||||
|
||||
|
||||
|
@ -196,7 +226,7 @@ class MythBoxee:
|
|||
self.log("def(GetRecordingArtwork): Start =========================================================")
|
||||
|
||||
sg = mc.Http()
|
||||
sg.SetUserAgent(self.userAgent)
|
||||
sg.SetUserAgent(self.userAgent + " " + self.version)
|
||||
html = sg.Get("http://www.thetvdb.com/api/GetSeries.php?seriesname=" + str(title.replace(" ", "%20")))
|
||||
banners = re.compile("<banner>(.*?)</banner>").findall(html)
|
||||
|
||||
|
@ -220,7 +250,7 @@ class MythBoxee:
|
|||
def GetRecordingSeriesID(self, title):
|
||||
self.log("def(GetRecordingSeriesID): Start =========================================================")
|
||||
sg = mc.Http()
|
||||
sg.SetUserAgent(self.userAgent)
|
||||
sg.SetUserAgent(self.userAgent + " " + self.version)
|
||||
html = sg.Get("http://www.thetvdb.com/api/GetSeries.php?seriesname=" + title.replace(" ", "%20"))
|
||||
series = re.compile("<seriesid>(.*?)</seriesid>").findall(html)
|
||||
|
||||
|
@ -275,7 +305,7 @@ class MythBoxee:
|
|||
"""
|
||||
def LoadShow(self):
|
||||
self.log("def(LoadShow): Start =========================================================")
|
||||
mc.ShowDialogWait()
|
||||
self.config.SetValue("loading", "true")
|
||||
|
||||
## Get Current Show Information
|
||||
title = self.config.GetValue("CurrentShowTitle")
|
||||
|
@ -288,7 +318,7 @@ class MythBoxee:
|
|||
self.SetSeriesDetails(title, seriesid)
|
||||
self.LoadShowRecordings(title)
|
||||
|
||||
mc.HideDialogWait()
|
||||
self.config.Reset("loading")
|
||||
self.log("def(LoadShow): End ===========================================================")
|
||||
|
||||
|
||||
|
@ -301,6 +331,8 @@ class MythBoxee:
|
|||
def LoadShowRecordings(self, title):
|
||||
self.log("def(LoadShowRecordings): Start =========================================================")
|
||||
|
||||
dbconf = eval(self.config.GetValue("dbconn"))
|
||||
|
||||
## Get current sort and filter settings
|
||||
sortBy = self.config.GetValue("SortBy")
|
||||
sortDir = self.config.GetValue("SortDir")
|
||||
|
@ -356,13 +388,6 @@ class MythBoxee:
|
|||
except:
|
||||
showitem.SetDate(2010, 01, 01)
|
||||
|
||||
## Set the Thumbnail for the ListItem
|
||||
#showitem.SetThumbnail("http://192.168.1.210:6544/Myth/GetPreviewImage?ChanId=1050&StartTime=2010-08-05%2021:00:00")
|
||||
#showitem.SetThumbnail("http://192.168.1.210:6544/Myth/GetPreviewImage?ChanId=" + chanid + "&StartTime=" + starttime.replace("T", "%20"))
|
||||
#showitem.SetThumbnail("http://" + dbconf['DBHostName'] + ":6544/Myth/GetPreviewImage?ChanId=" + chanid + "&StartTime=" + starttime.replace(" ", "%20") + "&random=" + str(random.randrange(1000000, 2000000, 2)))
|
||||
#showitem.SetThumbnail("mb_artwork_error.png")
|
||||
#showitem.SetThumbnail("http://192.168.1.210:6544/Myth/GetPreviewImage?ChanId=" + chanid + "&StartTime=" + starttime.replace(" ", "%20") + "&random=" + str(random.randrange(1000000, 2000000, 2)))
|
||||
#showitem.SetThumbnail("http://192.168.1.210:6544/Myth/GetPreviewImage?ChanId=" + chanid + "&StartTime=" + starttime.replace("T", "%20"))
|
||||
|
||||
# Determine Stream Method, Generate Proper Path
|
||||
streamMethod = self.config.GetValue("StreamMethod")
|
||||
|
@ -370,12 +395,12 @@ class MythBoxee:
|
|||
time = starttime.replace("T", "%20")
|
||||
path = "http://" + self.dbconf['DBHostName'] + ":6544/Myth/GetRecording?ChanId=" + chanid + "&StartTime=" + time
|
||||
showitem.SetThumbnail("http://" + self.dbconf['DBHostName'] + ":6544/Myth/GetPreviewImage?ChanId=" + chanid + "&StartTime=" + starttime.replace("T", "%20"))
|
||||
showitem.SetPath(path)
|
||||
elif streamMethod == "SMB":
|
||||
time = starttime.replace("T", "").replace("-", "").replace(":", "").replace(" ","")
|
||||
path = "smb://" + self.config.GetValue("smb.username") + ":" + self.config.GetValue("smb.password") + "@" + self.dbconf["DBHostName"] + "/" + self.config.GetValue("smb.share") + "/" + chanid + "_" + time + ".mpg"
|
||||
|
||||
## Set the Path for the ListItem
|
||||
showitem.SetPath(path)
|
||||
showitem.SetPath(path)
|
||||
#showitem.AddAlternativePath("XML Source", "http://" + self.dbconf['DBHostName'] + ":6544/Myth/GetRecording?ChanId=" + chanid + "&StartTime=" + starttime.replace("T", "%20"), )
|
||||
|
||||
self.log("def(LoadShowRecordings): Thumbnail: " + showitem.GetThumbnail())
|
||||
self.log("def(LoadShowRecordings): Path: " + showitem.GetPath())
|
||||
|
@ -439,7 +464,7 @@ class MythBoxee:
|
|||
def SetSeriesDetails(self, title, seriesid):
|
||||
self.log("def(SetSeriesDetails): Start =========================================================")
|
||||
sg = mc.Http()
|
||||
sg.SetUserAgent(self.userAgent)
|
||||
sg.SetUserAgent(self.userAgent + " " + self.version)
|
||||
html = sg.Get("http://thetvdb.com/api/" + self.tvdb_apikey + "/series/" + seriesid + "/")
|
||||
overview = re.compile("<Overview>(.*?)</Overview>").findall(html)
|
||||
poster = re.compile("<poster>(.*?)</poster>").findall(html)
|
||||
|
@ -485,24 +510,45 @@ class MythBoxee:
|
|||
|
||||
|
||||
"""
|
||||
SortBy - Sort List of Episodes
|
||||
SortBy - Set the Field that the List of Episodes is Sorted By
|
||||
"""
|
||||
def SortBy(self):
|
||||
self.log("def(SortBy): Start =========================================================")
|
||||
|
||||
## Figure out how we need to Sort
|
||||
sortByItems = sortByItemNumber = mc.GetWindow(14002).GetList(2051).GetSelected()
|
||||
sortDirectionItems = sortDirectionItemNumber = mc.GetWindow(14002).GetList(2061).GetSelected()
|
||||
mc.GetWindow(14002).GetList(2051).UnselectAll()
|
||||
mc.GetWindow(14002).GetList(2051).SetSelected(mc.GetWindow(14002).GetList(2051).GetFocusedItem(), True)
|
||||
|
||||
## Update the Sort Criteria
|
||||
self.config.SetValue("SortBy", mc.GetWindow(14002).GetList(2051).GetItem(mc.GetWindow(14002).GetList(2051).GetFocusedItem()).GetLabel())
|
||||
|
||||
self.log("def(SortBy): Direction: " + self.config.GetValue("SortBy"))
|
||||
|
||||
## Now that we have updated the Sort Criteria, reload the shows
|
||||
self.LoadShowRecordings(self.config.GetValue("CurrentShowTitle"))
|
||||
self.log("def(SortBy): End ===========================================================")
|
||||
|
||||
"""
|
||||
SortDir - Set the Direction that the List of Episodes is Sorted By
|
||||
"""
|
||||
def SortDir(self):
|
||||
self.log("def(SortDir): Start =========================================================")
|
||||
|
||||
## Figure out how we need to Sort
|
||||
sortDirectionItems = sortDirectionItemNumber = mc.GetWindow(14002).GetList(2061).GetSelected()
|
||||
mc.GetWindow(14002).GetList(2061).UnselectAll()
|
||||
mc.GetWindow(14002).GetList(2061).SetSelected(mc.GetWindow(14002).GetList(2061).GetFocusedItem(), True)
|
||||
|
||||
## Update the Sort Criteria
|
||||
self.config.SetValue("SortDir", mc.GetWindow(14002).GetList(2061).GetItem(mc.GetWindow(14002).GetList(2061).GetFocusedItem()).GetLabel())
|
||||
|
||||
self.log("def(SortDir): Direction: " + self.config.GetValue("SortDir"))
|
||||
|
||||
## Now that we have updated the Sort Criteria, reload the shows
|
||||
self.LoadShowRecordings(self.config.GetValue("CurrentShowTitle"))
|
||||
self.log("def(SortDir): End =========================================================")
|
||||
|
||||
|
||||
"""
|
||||
LoadSettings - Stuff that needs to be executed when settings window is loaded
|
||||
|
@ -516,10 +562,15 @@ class MythBoxee:
|
|||
self.log("def(LoadSettings): Stream Method: " + streamMethod)
|
||||
|
||||
# Grab and Set the Database Information
|
||||
dbconf = eval(self.config.GetValue("dbconn"))
|
||||
mc.GetWindow(14004).GetEdit(1042).SetText(dbconf['DBHostName'])
|
||||
mc.GetWindow(14004).GetEdit(1043).SetText(dbconf['DBUserName'])
|
||||
mc.GetWindow(14004).GetEdit(1044).SetText(dbconf['DBPassword'])
|
||||
if self.config.GetValue("dbconn"):
|
||||
dbconf = eval(self.config.GetValue("dbconn"))
|
||||
mc.GetWindow(14004).GetEdit(1042).SetText(dbconf['DBHostName'])
|
||||
mc.GetWindow(14004).GetEdit(1043).SetText(dbconf['DBUserName'])
|
||||
mc.GetWindow(14004).GetEdit(1044).SetText(dbconf['DBPassword'])
|
||||
mc.GetWindow(14004).GetEdit(1045).SetText(dbconf['DBName'])
|
||||
mc.GetWindow(14004).GetControl(1032).SetFocus()
|
||||
else:
|
||||
mc.GetWindow(14004).GetControl(1042).SetFocus()
|
||||
|
||||
# Setup Stream Methods for user to choose
|
||||
methods = ['XML', 'SMB']
|
||||
|
@ -550,13 +601,12 @@ class MythBoxee:
|
|||
mc.GetWindow(14004).GetControl(1032).SetEnabled(True)
|
||||
mc.GetWindow(14004).GetControl(1033).SetEnabled(True)
|
||||
mc.GetWindow(14004).GetControl(1034).SetEnabled(True)
|
||||
mc.GetWindow(14004).GetControl(1032).SetFocus()
|
||||
|
||||
## Update the fields with current SMB settings.
|
||||
mc.GetWindow(14004).GetEdit(1032).SetText(self.config.GetValue("smb.share"))
|
||||
mc.GetWindow(14004).GetEdit(1033).SetText(self.config.GetValue("smb.username"))
|
||||
mc.GetWindow(14004).GetEdit(1034).SetText(self.config.GetValue("smb.password"))
|
||||
|
||||
|
||||
self.log("def(LoadSettings): End ===========================================================")
|
||||
|
||||
|
||||
|
@ -592,6 +642,54 @@ class MythBoxee:
|
|||
self.log("def(SetStreamMethod): End =========================================================")
|
||||
|
||||
|
||||
"""
|
||||
SaveDbSettings - Save Database Settings
|
||||
"""
|
||||
def SaveDbSettings(self):
|
||||
self.log("def(SaveDbSettings): Start =========================================================")
|
||||
|
||||
dbconf = {}
|
||||
dbconf['DBHostName'] = mc.GetWindow(14004).GetEdit(1042).GetText()
|
||||
dbconf['DBUserName'] = mc.GetWindow(14004).GetEdit(1043).GetText()
|
||||
dbconf['DBPassword'] = mc.GetWindow(14004).GetEdit(1044).GetText()
|
||||
dbconf['DBName'] = mc.GetWindow(14004).GetEdit(1045).GetText()
|
||||
|
||||
self.config.SetValue("dbconn", str(dbconf))
|
||||
|
||||
## Notify the user that the changes have been saved.
|
||||
mc.ShowDialogNotification("Database Settings Saved")
|
||||
|
||||
self.log("def(SaveDbSettings): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
TestDbSettings - Test Database Settings
|
||||
"""
|
||||
def TestDbSettings(self):
|
||||
self.log("def(TestDbSettings): Start =========================================================")
|
||||
self.config.SetValue("loadingsettings", "true")
|
||||
mc.GetWindow(14004).GetLabel(9002).SetLabel("Attempting Database Connection ...")
|
||||
|
||||
dbconf = {}
|
||||
dbconf['DBHostName'] = mc.GetWindow(14004).GetEdit(1042).GetText()
|
||||
dbconf['DBUserName'] = mc.GetWindow(14004).GetEdit(1043).GetText()
|
||||
dbconf['DBPassword'] = mc.GetWindow(14004).GetEdit(1044).GetText()
|
||||
dbconf['DBName'] = mc.GetWindow(14004).GetEdit(1045).GetText()
|
||||
|
||||
try:
|
||||
self.log("def(TestDbSettings): Attempting Database Connection ...")
|
||||
mythtv.MythDB(**dbconf)
|
||||
except MythError, e:
|
||||
self.log("def(TestDbSettings): Error: " + e.message)
|
||||
mc.ShowDialogNotification("Failed to connect to the MythTV Backend")
|
||||
else:
|
||||
self.SaveDbSettings()
|
||||
mc.ShowDialogNotification("Connection to MythTV Backend Success. Settings Saved.")
|
||||
|
||||
self.config.Reset("loadingsettings")
|
||||
self.log("def(TestDbSettings): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
SaveSMBSettings - Saves the SMB settings the user inputted.
|
||||
"""
|
||||
|
@ -609,16 +707,45 @@ class MythBoxee:
|
|||
self.log("def(SetStreamMethod): End ===========================================================")
|
||||
|
||||
|
||||
"""
|
||||
SettingsInit - Init function for Settings Window
|
||||
"""
|
||||
def SettingsInit(self):
|
||||
self.config.SetValue("loadingsettings", "true")
|
||||
if not self.config.GetValue("dbconn"):
|
||||
mc.ShowDialogOk("MythBoxee", "Welcome to MythBoxee! Looks like this is the first time you have run this app. Please fill out all the settings and you'll be on your way to using this app.")
|
||||
response = mc.ShowDialogConfirm("MythBoxee", "Do you know what your Security Pin is for your MythTV Backend? If not, we'll try the default, if that fails, you'll need to fill your database information in manually.", "No", "Yes")
|
||||
if response:
|
||||
pin = mc.ShowDialogKeyboard("Security Pin", "", True)
|
||||
self.config.SetValue("pin", str(pin))
|
||||
else:
|
||||
pin = 0000
|
||||
self.config.SetValue("pin", str(pin))
|
||||
|
||||
mc.GetWindow(14004).GetLabel(9002).SetLabel("Connecting to Backend ...")
|
||||
if self.DiscoverBackend() == False:
|
||||
mc.ShowDialogOk("MythBoxee", "Unfortunately MythBoxee wasn't able to auto-discover your MythTV backend and database credentials. Please enter them in manually.")
|
||||
mc.GetWindow(14004).GetLabel(9002).SetLabel("LOADING...")
|
||||
self.LoadSettings()
|
||||
else:
|
||||
mc.ShowDialogOk("MythBoxee", "MythBoxee auto-discovered your MythTV backend. Enjoy your recordings!")
|
||||
self.config.Reset("app.lastruntime")
|
||||
mc.CloseWindow()
|
||||
else:
|
||||
self.LoadSettings()
|
||||
self.config.Reset("loadingsettings")
|
||||
|
||||
|
||||
"""
|
||||
log - logging function mainly for debugging
|
||||
"""
|
||||
def log(self, message):
|
||||
if self.logLevel >= 3:
|
||||
mc.LogDebug(">>> MythBoxee: " + message)
|
||||
|
||||
if self.logLevel >= 2:
|
||||
if self.logLevel == 3:
|
||||
mc.ShowDialogNotification(message)
|
||||
|
||||
if self.logLevel >= 1:
|
||||
if self.logLevel >= 2:
|
||||
mc.LogDebug(">>> MythBoxee: " + message)
|
||||
|
||||
if self.logLevel == 1:
|
||||
mc.LogInfo(">>> MythBoxee: " + message)
|
||||
print ">>> MythBoxee: " + message
|
||||
|
|
|
@ -1076,6 +1076,7 @@ class MythDBBase( object ):
|
|||
except:
|
||||
raise MythDBError(MythError.DB_CREDENTIALS)
|
||||
sock.setblocking(0)
|
||||
sock.settimeout(5)
|
||||
|
||||
# spam the request a couple times
|
||||
sock.sendto(sreq, upnptup)
|
||||
|
|
|
@ -179,7 +179,7 @@ mb.LoadMain()
|
|||
</content>
|
||||
</control>
|
||||
<control type="group">
|
||||
<visible>App.HasSetting(loading)</visible>
|
||||
<visible>App.HasSetting(loadingmain)</visible>
|
||||
<animation effect="fade" start="0" end="100" time="150">VisibleChange</animation>
|
||||
<control type="image">
|
||||
<width>1280</width>
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
<onload lang="python"><![CDATA[
|
||||
import mc
|
||||
import mythboxee
|
||||
mb.LoadSettings()
|
||||
|
||||
mb.SettingsInit()
|
||||
]]></onload>
|
||||
<controls>
|
||||
<control type="group" id="1010">
|
||||
|
@ -53,7 +54,47 @@ mb.LoadSettings()
|
|||
<password>true</password>
|
||||
<font>font18</font>
|
||||
<onup>1043</onup>
|
||||
<ondown>1022</ondown>
|
||||
<ondown>1045</ondown>
|
||||
</control>
|
||||
<control type="edit" id="1045">
|
||||
<posx>820</posx>
|
||||
<posy>265</posy>
|
||||
<width>300</width>
|
||||
<align>left</align>
|
||||
<label>Database:</label>
|
||||
<font>font18</font>
|
||||
<onup>1044</onup>
|
||||
<ondown>1047</ondown>
|
||||
</control>
|
||||
|
||||
</control>
|
||||
|
||||
<control type="grouplist" id="1046">
|
||||
<posx>820</posx>
|
||||
<posy>295</posy>
|
||||
<width>300</width>
|
||||
<itemgap>0</itemgap>
|
||||
<orientation>horizontal</orientation>
|
||||
<ondown>1022</ondown>
|
||||
<control type="button" id="1047">
|
||||
<label>Test Connection</label>
|
||||
<texturefocus>bg_btn.png</texturefocus>
|
||||
<texturenofocus></texturenofocus>
|
||||
<font>font14</font>
|
||||
<height>30</height>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<onclick lang="python"><![CDATA[mb.TestDbSettings()]]></onclick>
|
||||
</control>
|
||||
<control type="button" id="1048">
|
||||
<label>Save DB Settings</label>
|
||||
<texturefocus>bg_btn.png</texturefocus>
|
||||
<texturenofocus></texturenofocus>
|
||||
<font>font14</font>
|
||||
<height>30</height>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<onclick lang="python"><![CDATA[mb.SaveDbSettings()]]></onclick>
|
||||
</control>
|
||||
</control>
|
||||
|
||||
|
@ -64,7 +105,7 @@ mb.LoadSettings()
|
|||
<control type="group" id="1020">
|
||||
<control type="label" id="1021">
|
||||
<posx>820</posx>
|
||||
<posy>300</posy>
|
||||
<posy>360</posy>
|
||||
<width>250</width>
|
||||
<align>left</align>
|
||||
<label>Stream Method</label>
|
||||
|
@ -72,7 +113,7 @@ mb.LoadSettings()
|
|||
</control>
|
||||
<control type="list" id="1022">
|
||||
<posx>830</posx>
|
||||
<posy>335</posy>
|
||||
<posy>395</posy>
|
||||
<width>164</width>
|
||||
<height>100</height>
|
||||
<onup>1044</onup>
|
||||
|
@ -135,7 +176,7 @@ mb.LoadSettings()
|
|||
<control type="group" id="1030">
|
||||
<control type="label" id="1031">
|
||||
<posx>820</posx>
|
||||
<posy>420</posy>
|
||||
<posy>480</posy>
|
||||
<width>250</width>
|
||||
<align>left</align>
|
||||
<label>SMB Share</label>
|
||||
|
@ -143,36 +184,53 @@ mb.LoadSettings()
|
|||
</control>
|
||||
<control type="edit" id="1032">
|
||||
<posx>820</posx>
|
||||
<posy>445</posy>
|
||||
<posy>505</posy>
|
||||
<width>300</width>
|
||||
<label>Share:</label>
|
||||
<align>left</align>
|
||||
<font>font18</font>
|
||||
<onup>1022</onup>
|
||||
<ondown>1033</ondown>
|
||||
<ontextchange lang="python"><![CDATA[mb.SaveSMBSettings()]]></ontextchange>
|
||||
</control>
|
||||
<control type="edit" id="1033">
|
||||
<posx>820</posx>
|
||||
<posy>475</posy>
|
||||
<posy>535</posy>
|
||||
<width>300</width>
|
||||
<label>Username:</label>
|
||||
<align>left</align>
|
||||
<font>font18</font>
|
||||
<onup>1032</onup>
|
||||
<ondown>1034</ondown>
|
||||
<ontextchange lang="python"><![CDATA[mb.SaveSMBSettings()]]></ontextchange>
|
||||
</control>
|
||||
<control type="edit" id="1034">
|
||||
<posx>820</posx>
|
||||
<posy>505</posy>
|
||||
<posy>565</posy>
|
||||
<width>300</width>
|
||||
<label>Password:</label>
|
||||
<align>left</align>
|
||||
<font>font18</font>
|
||||
<password>true</password>
|
||||
<onup>1033</onup>
|
||||
<ontextchange lang="python"><![CDATA[mb.SaveSMBSettings()]]></ontextchange>
|
||||
<ondown>1071</ondown>
|
||||
</control>
|
||||
</control>
|
||||
|
||||
<control type="grouplist" id="1070">
|
||||
<posx>895</posx>
|
||||
<posy>600</posy>
|
||||
<width>300</width>
|
||||
<itemgap>0</itemgap>
|
||||
<orientation>horizontal</orientation>
|
||||
<onup>1034</onup>
|
||||
<control type="button" id="1071">
|
||||
<label>Save SMB Settings</label>
|
||||
<texturefocus>bg_btn.png</texturefocus>
|
||||
<texturenofocus></texturenofocus>
|
||||
<font>font14</font>
|
||||
<height>30</height>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<onclick lang="python"><![CDATA[mb.SaveSMBSettings()]]></onclick>
|
||||
</control>
|
||||
</control>
|
||||
|
||||
|
@ -226,6 +284,27 @@ mb.LoadSettings()
|
|||
-->
|
||||
<!-- END: CACHE SETTINGS -->
|
||||
|
||||
<control type="group" id="9000">
|
||||
<visible>App.HasSetting(loadingsettings)</visible>
|
||||
<animation effect="fade" start="0" end="100" time="150">VisibleChange</animation>
|
||||
<control type="image" id="9001">
|
||||
<width>1280</width>
|
||||
<height>720</height>
|
||||
<texture>black.png</texture>
|
||||
<animation effect="fade" start="80" end="80" time="0" condition="true">Conditional</animation>
|
||||
</control>
|
||||
<control type="label" id="9002">
|
||||
<posy>0</posy>
|
||||
<posx>0</posx>
|
||||
<width>1280</width>
|
||||
<height>720</height>
|
||||
<align>center</align>
|
||||
<aligny>center</aligny>
|
||||
<font>sans40b</font>
|
||||
<label>LOADING...</label>
|
||||
<textcolor>ffffffff</textcolor>
|
||||
</control>
|
||||
</control>
|
||||
|
||||
</controls>
|
||||
</window>
|
|
@ -26,11 +26,13 @@ mb.LoadShow()
|
|||
|
||||
<control type="grouplist" id="1040">
|
||||
<posy>28</posy>
|
||||
<posx>940</posx>
|
||||
<width>334</width>
|
||||
<posx>1106</posx>
|
||||
<width>166</width>
|
||||
<itemgap>10</itemgap>
|
||||
<orientation>horizontal</orientation>
|
||||
<ondown>2040</ondown>
|
||||
<!--
|
||||
940/334
|
||||
<control type="button" id="1041">
|
||||
<label>Refresh</label>
|
||||
<texturefocus>bg_btn.png</texturefocus>
|
||||
|
@ -39,6 +41,7 @@ mb.LoadShow()
|
|||
<align>center</align>
|
||||
<onclick lang="python"><![CDATA[mb.RefreshMain()]]></onclick>
|
||||
</control>
|
||||
-->
|
||||
<control type="button" id="1042">
|
||||
<label>Settings</label>
|
||||
<texturefocus>bg_btn.png</texturefocus>
|
||||
|
@ -57,7 +60,7 @@ mb.LoadShow()
|
|||
<align>center</align>
|
||||
<onclick lang="python"><![CDATA[mb.SendLogs()]]></onclick>
|
||||
</control>
|
||||
-->
|
||||
-->
|
||||
</control>
|
||||
|
||||
<!-- END: TOP MENU -->
|
||||
|
@ -160,7 +163,7 @@ mb.LoadShow()
|
|||
<align>left</align>
|
||||
<aligny>top</aligny>
|
||||
<info>ListItem.Label</info>
|
||||
<font>font18</font>
|
||||
<font>font18b</font>
|
||||
<textcolor>FFFEFEFE</textcolor>
|
||||
<wrapmultiline>true</wrapmultiline>
|
||||
</control>
|
||||
|
@ -236,7 +239,7 @@ mb.LoadShow()
|
|||
<align>left</align>
|
||||
<aligny>top</aligny>
|
||||
<info>ListItem.Label</info>
|
||||
<font>font18</font>
|
||||
<font>font18b</font>
|
||||
<textcolor>FFFEFEFE</textcolor>
|
||||
</control>
|
||||
<control type="label">
|
||||
|
@ -336,7 +339,7 @@ mb.LoadShow()
|
|||
</control>
|
||||
</focusedlayout>
|
||||
<content type="action">
|
||||
<onclick lang="python"><![CDATA[mythboxee.SortBySeriesEpisodes()]]></onclick>
|
||||
<onclick lang="python"><![CDATA[mb.SortBy()]]></onclick>
|
||||
</content>
|
||||
</control>
|
||||
|
||||
|
@ -408,11 +411,10 @@ mb.LoadShow()
|
|||
</control>
|
||||
</focusedlayout>
|
||||
<content type="action">
|
||||
<onclick lang="python"><![CDATA[mythboxee.SortDirSeriesEpisodes()]]></onclick>
|
||||
<onclick lang="python"><![CDATA[mb.SortDir()]]></onclick>
|
||||
</content>
|
||||
</control>
|
||||
</control>
|
||||
|
||||
|
||||
<control type="group" id="2080">
|
||||
<control type="label" id="2081">
|
||||
|
|
Loading…
Reference in New Issue