diff --git a/default.py b/default.py index c6e58c2..2732c32 100644 --- a/default.py +++ b/default.py @@ -654,12 +654,7 @@ def PLAY( url, handle ): playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist.clear() - - id = urlParts[1] - jsonData = downloadUtils.downloadUrl("http://" + server + "/mediabrowser/Users/" + userid + "/Items/" + id + "?format=json", suppress=False, popup=1 ) - printDebug("Play jsonData: " + jsonData) - result = json.loads(jsonData) - + playurl = PlayUtils().getPlayUrl(server, id, result) printDebug("Play URL: " + playurl) thumbPath = downloadUtils.getArtwork(result, "Primary") @@ -672,25 +667,15 @@ def PLAY( url, handle ): xbmcgui.Dialog().ok(__language__(30128), __language__(30129)) return - watchedurl = 'http://' + server + '/mediabrowser/Users/'+ userid + '/PlayedItems/' + id - positionurl = 'http://' + server + '/mediabrowser/Users/'+ userid + '/PlayingItems/' + id - deleteurl = 'http://' + server + '/mediabrowser/Items/' + id - - # set the current playing info + # set the current playing item id WINDOW = xbmcgui.Window( 10000 ) - WINDOW.setProperty(playurl + "watchedurl", watchedurl) - WINDOW.setProperty(playurl + "positionurl", positionurl) - WINDOW.setProperty(playurl + "deleteurl", "") - - if result.get("Type")=="Episode" and __settings__.getSetting("offerDelete")=="true": - WINDOW.setProperty(playurl+"deleteurl", deleteurl) - - WINDOW.setProperty(playurl + "runtimeticks", str(result.get("RunTimeTicks"))) - WINDOW.setProperty(playurl + "item_id", id) + WINDOW.setProperty("item_id", id) + WINDOW.setProperty("run_time", str(result.get("RunTimeTicks"))) playlist.add(playurl, listItem) xbmc.Player().play(playlist) + #Set a loop to wait for positive confirmation of playback count = 0 while not xbmc.Player().isPlaying(): @@ -1629,6 +1614,7 @@ def showParentContent(pluginName, handle, params): def showViewList(url, pluginhandle): viewCats=['Movies', 'BoxSets', 'Trailers', 'Series', 'Seasons', 'Episodes', 'Music Artists', 'Music Albums', 'Music Videos', 'Music Tracks'] viewTypes=['_MOVIES', '_BOXSETS', '_TRAILERS', '_SERIES', '_SEASONS', '_EPISODES', '_MUSICARTISTS', '_MUSICALBUMS', '_MUSICVIDEOS', '_MUSICTRACKS'] + if "SETVIEWS" in url: for viewCat in viewCats: xbmcplugin.addDirectoryItem(pluginhandle, 'plugin://plugin.video.mbcon/?url=_SHOWVIEWS' + viewTypes[viewCats.index(viewCat)] + '&mode=' + str(_MODE_SETVIEWS), xbmcgui.ListItem(viewCat, ''), isFolder=True) @@ -1653,6 +1639,7 @@ def showViewList(url, pluginhandle): else: name=view.attrib['id'] xbmcplugin.addDirectoryItem(pluginhandle, 'plugin://plugin.video.mbcon?url=_SETVIEW_'+ url.split('_')[2] + '_' + view.attrib['value'] + '&mode=' + str(_MODE_SETVIEWS), xbmcgui.ListItem(name, 'test')) + xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=False) def checkService(): diff --git a/resources/lib/ArtworkLoader.py b/resources/lib/ArtworkLoader.py index f48dfae..bbe6af2 100644 --- a/resources/lib/ArtworkLoader.py +++ b/resources/lib/ArtworkLoader.py @@ -300,8 +300,12 @@ class ArtworkRotationThread(threading.Thread): self.logMsg("updateCollectionArtLinks UserID : " + userid) userUrl = "http://" + mb3Host + ":" + mb3Port + "/mediabrowser/Users/" + userid + "/Items/Root?format=json" - jsonData = downloadUtils.downloadUrl(userUrl, suppress=False, popup=1 ) + jsonData = downloadUtils.downloadUrl(userUrl, suppress=True, popup=0 ) self.logMsg("updateCollectionArtLinks UserData : " + str(jsonData), 2) + + if(len(jsonData) == 0): + return False + result = json.loads(jsonData) parentid = result.get("Id") @@ -309,7 +313,7 @@ class ArtworkRotationThread(threading.Thread): userRootPath = "http://" + mb3Host + ":" + mb3Port + "/mediabrowser/Users/" + userid + "/items?ParentId=" + parentid + "&SortBy=SortName&Fields=CollectionType,RecursiveItemCount&format=json" - jsonData = downloadUtils.downloadUrl(userRootPath, suppress=False, popup=1 ) + jsonData = downloadUtils.downloadUrl(userRootPath, suppress=True, popup=0 ) self.logMsg("updateCollectionArtLinks userRootPath : " + str(jsonData), 2) result = json.loads(jsonData) result = result.get("Items") diff --git a/resources/lib/DownloadUtils.py b/resources/lib/DownloadUtils.py index 3a1e619..6e608e2 100644 --- a/resources/lib/DownloadUtils.py +++ b/resources/lib/DownloadUtils.py @@ -73,7 +73,10 @@ class DownloadUtils(): break if(secure): - self.authenticate('http://' + host + ":" + port + "/mediabrowser/Users/AuthenticateByName?format=json") + authOk = self.authenticate() + if(authOk == False): + return_value = xbmcgui.Dialog().ok(self.getString(30044), self.getString(30044)) + sys.exit() if userid == "": return_value = xbmcgui.Dialog().ok(self.getString(30045),self.getString(30045)) @@ -89,7 +92,17 @@ class DownloadUtils(): def getMachineId(self): return "%012X"%get_mac() - def authenticate(self, url): + def authenticate(self): + + self.addonSettings.setSetting('AccessToken', "") + + port = self.addonSettings.getSetting("port") + host = self.addonSettings.getSetting("ipaddress") + if(host == None or host == "" or port == None or port == ""): + return False + + url = "http://" + self.addonSettings.getSetting("ipaddress") + ":" + self.addonSettings.getSetting("port") + "/mediabrowser/Users/AuthenticateByName?format=json" + txt_mac = self.getMachineId() version = ClientInformation().getVersion() @@ -99,17 +112,20 @@ class DownloadUtils(): authString = "Mediabrowser Client=\"XBMC\",Device=\"" + deviceName + "\",DeviceId=\"" + txt_mac + "\",Version=\"" + version + "\"" headers = {'Accept-encoding': 'gzip', 'Authorization' : authString} sha1 = hashlib.sha1(self.addonSettings.getSetting('password')) + resp = requests.post(url, data={'password':sha1.hexdigest(),'Username':self.addonSettings.getSetting('username')}, headers=headers) - code=str(resp.status_code) + code = str(resp.status_code) result = resp.json() + if result.get("AccessToken") != self.addonSettings.getSetting('AccessToken'): self.addonSettings.setSetting('AccessToken', result.get("AccessToken")) - if int(code) >= 200 and int(code)<300: + + if int(code) >= 200 and int(code) < 300: self.logMsg("User Authenticated") + return True else: self.logMsg("User NOT Authenticated") - return_value = xbmcgui.Dialog().ok(self.getString(30044), self.getString(30044)) - sys.exit() + return False def getArtwork(self, data, type, index = "0"): @@ -188,6 +204,7 @@ class DownloadUtils(): def downloadUrl(self, url, suppress=False, type="GET", popup=0 ): self.logMsg("== ENTER: getURL ==") + link = "" try: if url[0:4] == "http": serversplit=2 @@ -196,23 +213,30 @@ class DownloadUtils(): serversplit=0 urlsplit=1 - server=url.split('/')[serversplit] - urlPath="/"+"/".join(url.split('/')[urlsplit:]) + server =url.split('/')[serversplit] + urlPath = "/"+"/".join(url.split('/')[urlsplit:]) self.logMsg("DOWNLOAD_URL = " + url) self.logMsg("server = "+str(server), level=2) self.logMsg("urlPath = "+str(urlPath), level=2) conn = httplib.HTTPConnection(server, timeout=20) #head = {"Accept-Encoding" : "gzip,deflate", "Accept-Charset" : "UTF-8,*"} - if self.addonSettings.getSetting('AccessToken')==None: - self.addonSettings.setSetting('AccessToken','') - head = {"Accept-Encoding" : "gzip", "Accept-Charset" : "UTF-8,*", "X-MediaBrowser-Token" : self.addonSettings.getSetting('AccessToken')} + if(self.addonSettings.getSetting('AccessToken') == None): + self.addonSettings.setSetting('AccessToken', '') + + authToken = self.addonSettings.getSetting('AccessToken') + if(authToken != None and authToken != ""): + head = {"Accept-Encoding" : "gzip", "Accept-Charset" : "UTF-8,*", "X-MediaBrowser-Token" : authToken} + else: + head = {"Accept-Encoding" : "gzip", "Accept-Charset" : "UTF-8,*"} + self.logMsg("HEADERS : " + str(head), level=1) + #head = getAuthHeader() conn.request(method=type, url=urlPath, headers=head) #conn.request(method=type, url=urlPath) data = conn.getresponse() self.logMsg("GET URL HEADERS : " + str(data.getheaders()), level=2) - link = "" + contentType = "none" if int(data.status) == 200: retData = data.read() @@ -252,9 +276,12 @@ class DownloadUtils(): except Exception, msg: error = "Unable to connect to " + str(server) + " : " + str(msg) xbmc.log(error) - xbmc.executebuiltin("XBMC.Notification(\"MBCon\": URL error: Unable to connect to server,)") - xbmcgui.Dialog().ok("",self.getString(30204)) - raise + if suppress is False: + if popup == 0: + xbmc.executebuiltin("XBMC.Notification(\"MBCon\": URL error: Unable to connect to server,)") + else: + xbmcgui.Dialog().ok("",self.getString(30204)) + raise else: try: conn.close() except: pass diff --git a/resources/lib/Utils.py b/resources/lib/Utils.py index 1b693c1..1faa173 100644 --- a/resources/lib/Utils.py +++ b/resources/lib/Utils.py @@ -24,55 +24,35 @@ class PlayUtils(): addonSettings = xbmcaddon.Addon(id='plugin.video.mbcon') # if the path is local and depending on the video quality play we can direct play it do so- xbmc.log("MBCon getPlayUrl") - if self.isDirectPlay(result) == True: - xbmc.log("MBCon getPlayUrl -> Direct Play") - playurl = result.get("Path") - if playurl != None: - #We have a path to play so play it - USER_AGENT = 'QuickTime/7.7.4' - - # If the file it is not a media stub - if (result.get("IsPlaceHolder") != True): - if (result.get("VideoType") == "Dvd"): - playurl = playurl + "/VIDEO_TS/VIDEO_TS.IFO" - elif (result.get("VideoType") == "BluRay"): - playurl = playurl + "/BDMV/index.bdmv" - if addonSettings.getSetting('smbusername') == '': - playurl = playurl.replace("\\\\", "smb://") - else: - playurl = playurl.replace("\\\\", "smb://" + addonSettings.getSetting('smbusername') + ':' + addonSettings.getSetting('smbpassword') + '@') - playurl = playurl.replace("\\", "/") - - if ("apple.com" in playurl): - playurl += '?|User-Agent=%s' % USER_AGENT - if addonSettings.getSetting('playFromStream') == "true": - playurl = 'http://' + server + '/mediabrowser/Videos/' + id + '/stream?static=true' - mediaSources = result.get("MediaSources") - if(mediaSources != None): - if mediaSources[0].get('DefaultAudioStreamIndex') != None: - playurl = playurl + "&AudioStreamIndex=" +str(mediaSources[0].get('DefaultAudioStreamIndex')) - if mediaSources[0].get('DefaultSubtitleStreamIndex') != None: - playurl = playurl + "&SubtitleStreamIndex=" + str(mediaSources[0].get('DefaultAudioStreamIndex')) + + playurl = result.get("Path") + if playurl != None: + #We have a path to play so play it + USER_AGENT = 'QuickTime/7.7.4' + + # If the file it is not a media stub + if (result.get("IsPlaceHolder") != True): + if (result.get("VideoType") == "Dvd"): + playurl = playurl + "/VIDEO_TS/VIDEO_TS.IFO" + elif (result.get("VideoType") == "BluRay"): + playurl = playurl + "/BDMV/index.bdmv" + if addonSettings.getSetting('smbusername') == '': + playurl = playurl.replace("\\\\", "smb://") + else: + playurl = playurl.replace("\\\\", "smb://" + addonSettings.getSetting('smbusername') + ':' + addonSettings.getSetting('smbpassword') + '@') + playurl = playurl.replace("\\", "/") + + if ("apple.com" in playurl): + playurl += '?|User-Agent=%s' % USER_AGENT + if addonSettings.getSetting('playFromStream') == "true": + playurl = 'http://' + server + '/mediabrowser/Videos/' + id + '/stream?static=true' + mediaSources = result.get("MediaSources") + if(mediaSources != None): + if mediaSources[0].get('DefaultAudioStreamIndex') != None: + playurl = playurl + "&AudioStreamIndex=" +str(mediaSources[0].get('DefaultAudioStreamIndex')) + if mediaSources[0].get('DefaultSubtitleStreamIndex') != None: + playurl = playurl + "&SubtitleStreamIndex=" + str(mediaSources[0].get('DefaultAudioStreamIndex')) - - else: - #No path or has a path but not sufficient network so transcode - xbmc.log("MBCon getPlayUrl -> Transcode") - if result.get("Type") == "Audio": - playurl = 'http://' + server + '/mediabrowser/Audio/' + id + '/stream.mp3' - else: - txt_mac = downloadUtils.getMachineId() - playurl = 'http://' + server + '/mediabrowser/Videos/' + id + '/master.m3u8?mediaSourceId=' + id - playurl = playurl + '&videoCodec=h264' - playurl = playurl + '&AudioCodec=aac,ac3' - playurl = playurl + '&deviceId=' + txt_mac - playurl = playurl + '&VideoBitrate=' + str(int(self.getVideoBitRate()) * 1000) - mediaSources = result.get("MediaSources") - if(mediaSources != None): - if mediaSources[0].get('DefaultAudioStreamIndex') != None: - playurl = playurl + "&AudioStreamIndex=" +str(mediaSources[0].get('DefaultAudioStreamIndex')) - if mediaSources[0].get('DefaultSubtitleStreamIndex') != None: - playurl = playurl + "&SubtitleStreamIndex=" + str(mediaSources[0].get('DefaultAudioStreamIndex')) return playurl.encode('utf-8') # Works out if we are direct playing or not diff --git a/resources/lib/WebSocketClient.py b/resources/lib/WebSocketClient.py index 4439c34..4bd0688 100644 --- a/resources/lib/WebSocketClient.py +++ b/resources/lib/WebSocketClient.py @@ -54,7 +54,7 @@ class WebSocketThread(threading.Thread): def playbackStopped(self, itemId, ticks): if(self.client != None): try: - self.logMsg("Sending Playback Stopped") + self.logMsg("Sending Playback Stopped : " + str(ticks)) messageData = {} messageData["MessageType"] = "PlaybackStopped" messageData["Data"] = itemId + "|" + str(ticks) @@ -68,7 +68,7 @@ class WebSocketThread(threading.Thread): def sendProgressUpdate(self, itemId, ticks): if(self.client != None): try: - self.logMsg("Sending Progress Update") + self.logMsg("Sending Progress Update : " + str(ticks)) messageData = {} messageData["MessageType"] = "PlaybackProgress" messageData["Data"] = itemId + "|" + str(ticks) + "|false|false" diff --git a/service.py b/service.py index 365ca83..d9b46b7 100644 --- a/service.py +++ b/service.py @@ -27,90 +27,33 @@ __addon__ = xbmcaddon.Addon(id='plugin.video.mbcon') __language__ = __addon__.getLocalizedString BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib' ) ) sys.path.append(BASE_RESOURCE_PATH) -base_window = xbmcgui.Window( 10000 ) from ArtworkLoader import ArtworkRotationThread from WebSocketClient import WebSocketThread from ClientInformation import ClientInformation from MenuLoad import LoadMenuOptionsThread +from DownloadUtils import DownloadUtils _MODE_BASICPLAY=12 -def getAuthHeader(): - addonSettings = xbmcaddon.Addon(id='plugin.video.mbcon') - deviceName = addonSettings.getSetting('deviceName') - deviceName = deviceName.replace("\"", "_") # might need to url encode this as it is getting added to the header and is user entered data - clientInfo = ClientInformation() - txt_mac = clientInfo.getMachineId() - version = clientInfo.getVersion() - userid = xbmcgui.Window( 10000 ).getProperty("userid") - authString = "MediaBrowser UserId=\"" + userid + "\",Client=\"XBMC\",Device=\"" + deviceName + "\",DeviceId=\"" + txt_mac + "\",Version=\"" + version + "\"" - headers = {'Accept-encoding': 'gzip', 'Authorization' : authString} - xbmc.log("MBCon Authentication Header : " + str(headers)) - return headers +downloadUtils = DownloadUtils() + +# auth the service +try: + downloadUtils.authenticate() +except Exception, e: + pass # start some worker threads +newWebSocketThread = WebSocketThread() +newWebSocketThread.start() -newWebSocketThread = None -if __addon__.getSetting('useWebSocketRemote') == "true": - newWebSocketThread = WebSocketThread() - newWebSocketThread.start() -else: - xbmc.log("MBCon Service WebSocketRemote Disabled") +newMenuThread = LoadMenuOptionsThread() +newMenuThread.start() -newMenuThread = None -if __addon__.getSetting('useMenuLoader') == "true": - newMenuThread = LoadMenuOptionsThread() - newMenuThread.start() -else: - xbmc.log("MBCon Service MenuLoader Disabled") - -artworkRotationThread = None -if __addon__.getSetting('useBackgroundLoader') == "true": - artworkRotationThread = ArtworkRotationThread() - artworkRotationThread.start() -else: - xbmc.log("MBCon Service BackgroundLoader Disabled") - - -def deleteItem (url): - return_value = xbmcgui.Dialog().yesno(__language__(30091),__language__(30092)) - if return_value: - xbmc.log('Deleting via URL: ' + url) - progress = xbmcgui.DialogProgress() - progress.create(__language__(30052), __language__(30053)) - resp = requests.delete(url, data='', headers=getAuthHeader()) - deleteSleep=0 - while deleteSleep<10: - xbmc.sleep(1000) - deleteSleep=deleteSleep+1 - progress.update(deleteSleep*10,__language__(30053)) - progress.close() - xbmc.executebuiltin("Container.Refresh") - return 1 - else: - return 0 - -def markWatched(url): - xbmc.log('MBCon Service -> Marking watched via: ' + url) - resp = requests.post(url, data='', headers=getAuthHeader()) - -def markUnWatched(url): - xbmc.log('MBCon Service -> Marking watched via: ' + url) - resp = requests.delete(url, data='', headers=getAuthHeader()) - -def setPosition (url, method): - xbmc.log('MBCon Service -> Setting position via: ' + url) - if method == 'POST': - resp = requests.post(url, data='', headers=getAuthHeader()) - elif method == 'DELETE': - resp = requests.delete(url, data='', headers=getAuthHeader()) - -def stopTranscoding(url): - xbmc.log('MBCon Service -> Stopping transcoding: ' + url) - resp = requests.delete(url, data='', headers=getAuthHeader()) - - +artworkRotationThread = ArtworkRotationThread() +artworkRotationThread.start() + def hasData(data): if(data == None or len(data) == 0 or data == "None"): return False @@ -131,52 +74,32 @@ def stopAll(played_information): xbmc.log ("MBCon Service -> item_url : " + item_url) xbmc.log ("MBCon Service -> item_data : " + str(data)) - watchedurl = data.get("watchedurl") - positionurl = data.get("positionurl") - deleteurl = data.get("deleteurl") - runtime = data.get("runtime") + runtime = data.get("run_time") currentPossition = data.get("currentPossition") item_id = data.get("item_id") - if(currentPossition != None and hasData(runtime) and hasData(positionurl) and hasData(watchedurl)): + if(hasData(item_id) and hasData(runtime)): runtimeTicks = int(runtime) - xbmc.log ("MBCon Service -> runtimeticks:" + str(runtimeTicks)) + xbmc.log("MBCon Service -> runtimeticks: " + str(runtimeTicks)) percentComplete = (currentPossition * 10000000) / runtimeTicks markPlayedAt = float(addonSettings.getSetting("markPlayedAt")) / 100 - xbmc.log ("MBCon Service -> Percent Complete:" + str(percentComplete) + " Mark Played At:" + str(markPlayedAt)) + xbmc.log("MBCon Service -> Percent Complete:" + str(percentComplete) + " Mark Played At:" + str(markPlayedAt)) if (percentComplete > markPlayedAt): - gotDeleted = 0 - if(deleteurl != None and deleteurl != ""): - xbmc.log ("MBCon Service -> Offering Delete:" + str(deleteurl)) - gotDeleted = deleteItem(deleteurl) + xbmc.log("MBCon Service -> Marked Watched") + newWebSocketThread.playbackStopped(item_id, str(0)) - if(gotDeleted == 0): - setPosition(positionurl + '/Progress?PositionTicks=0', 'POST') - if(newWebSocketThread != None): - newWebSocketThread.playbackStopped(item_id, str(0)) - markWatched(watchedurl) else: - #markUnWatched(watchedurl) # this resets the LastPlayedDate and that causes issues with sortby PlayedDate so I removed it for now - if(newWebSocketThread != None): - newWebSocketThread.playbackStopped(item_id, str(int(currentPossition * 10000000))) - setPosition(positionurl + '?PositionTicks=' + str(int(currentPossition * 10000000)), 'DELETE') - if(newNextUpThread != None): - newNextUpThread.updateNextUp() - - if(artworkRotationThread != None): - artworkRotationThread.updateActionUrls() + xbmc.log("MBCon Service -> Set Position:" + str(int(currentPossition * 10000000))) + newWebSocketThread.playbackStopped(item_id, str(int(currentPossition * 10000000))) + + artworkRotationThread.updateActionUrls() played_information.clear() - - # stop transcoding - todo check we are actually transcoding? - clientInfo = ClientInformation() - txt_mac = clientInfo.getMachineId() - url = ("http://%s:%s/mediabrowser/Videos/ActiveEncodings" % (addonSettings.getSetting('ipaddress'), addonSettings.getSetting('port'))) - url = url + '?DeviceId=' + txt_mac - stopTranscoding(url) + + class Service( xbmc.Player ): played_information = {} @@ -194,41 +117,25 @@ class Service( xbmc.Player ): xbmc.log("MBCon Service -> onPlayBackStarted" + currentFile) WINDOW = xbmcgui.Window( 10000 ) - watchedurl = WINDOW.getProperty(currentFile+"watchedurl") - deleteurl = WINDOW.getProperty(currentFile+"deleteurl") - positionurl = WINDOW.getProperty(currentFile+"positionurl") - runtime = WINDOW.getProperty(currentFile+"runtimeticks") - item_id = WINDOW.getProperty(currentFile+"item_id") + item_id = WINDOW.getProperty("item_id") + run_time = WINDOW.getProperty("run_time") # reset all these so they dont get used is xbmc plays a none - # xbmb3c MB item - # WINDOW.setProperty(currentFile+"watchedurl", "") - # WINDOW.setProperty(currentFile+"deleteurl", "") - # WINDOW.setProperty(currentFile+"positionurl", "") - # WINDOW.setProperty(currentFile+"runtimeticks", "") - # WINDOW.setProperty(currentFile+"item_id", "") + WINDOW.setProperty("item_id", "") + WINDOW.setProperty("run_time", "") if(item_id == None or len(item_id) == 0): return - if(newWebSocketThread != None): - newWebSocketThread.playbackStarted(item_id) + newWebSocketThread.playbackStarted(item_id) - if (watchedurl != "" and positionurl != ""): + data = {} + data["item_id"] = item_id + data["run_time"] = run_time + self.played_information[currentFile] = data - data = {} - data["watchedurl"] = watchedurl - data["deleteurl"] = deleteurl - data["positionurl"] = positionurl - data["runtime"] = runtime - data["item_id"] = item_id - self.played_information[currentFile] = data - - xbmc.log("MBCon Service -> ADDING_FILE : " + currentFile) - xbmc.log("MBCon Service -> ADDING_FILE : " + str(self.played_information)) - - # reset in progress possition - setPosition(positionurl + '/Progress?PositionTicks=0', 'POST') + xbmc.log("MBCon Service -> ADDING_FILE : " + currentFile) + xbmc.log("MBCon Service -> ADDING_FILE : " + str(self.played_information)) def onPlayBackEnded( self ): # Will be called when xbmc stops playing a file @@ -243,10 +150,6 @@ class Service( xbmc.Player ): monitor = Service() lastProgressUpdate = datetime.today() -addonSettings = xbmcaddon.Addon(id='plugin.video.mbcon') -if socket.gethostname() != None and socket.gethostname() != '' and addonSettings.getSetting("deviceName") == 'MBCon': - addonSettings.setSetting("deviceName", socket.gethostname()) - while not xbmc.abortRequested: if xbmc.Player().isPlaying(): try: @@ -263,8 +166,7 @@ while not xbmc.abortRequested: if(secDiff > 10): if(monitor.played_information.get(currentFile) != None and monitor.played_information.get(currentFile).get("item_id") != None): item_id = monitor.played_information.get(currentFile).get("item_id") - if(newWebSocketThread != None): - newWebSocketThread.sendProgressUpdate(item_id, str(int(playTime * 10000000))) + newWebSocketThread.sendProgressUpdate(item_id, str(int(playTime * 10000000))) lastProgressUpdate = datetime.today() except Exception, e: @@ -275,11 +177,6 @@ while not xbmc.abortRequested: xbmcgui.Window(10000).setProperty("XBMB3C_Service_Timestamp", str(int(time.time()))) # stop the WebSocket client -if(newWebSocketThread != None): - newWebSocketThread.stopClient() - -# stop the image proxy -keepServing = False +newWebSocketThread.stopClient() xbmc.log("MBCon Service -> Service shutting down") -