def checkDailySync(): currhour = datetime.datetime.now().strftime('%H') syncflag = media.settings('dailysync') if syncflag != '': dailysync = int(syncflag) else: dailysync = 0 media.settings('dailysync', '0') # Set daily sync flag xbmc.log('Mezzmo initial daily sync flag is: ' + str(dailysync), xbmc.LOGDEBUG) if int(currhour) > 5 and dailysync <> 0: dailysync = 0 # Reset daily sync flag media.settings('dailysync', str(dailysync)) msynclog = 'Mezzmo daily sync process flag reset.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) elif int(currhour) >= 0 and int(currhour) <= 5 and dailysync == 0: dailysync = 1 # Set daily sync flag if not run yet msynclog = 'Mezzmo daily sync process flag set.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) elif int(currhour) >= 0 and int(currhour) <= 5 and dailysync == 1: dailysync = 0 xbmc.log('Mezzmo final daily sync flag is: ' + str(dailysync), xbmc.LOGDEBUG) return(dailysync)
def onPlayBackPaused(self): xbmc.log("Playback paused - LED OFF") contenturl = media.settings('contenturl') manufacturer = getContentURL(contenturl) objectID = getObjectID(file) bmdelay = 15 - int(media.settings('bmdelay')) if len( contenturl ) > 5 and 'Conceiva' in manufacturer: # Ensure Mezzmo server has been selected bookmark.SetBookmark(contenturl, objectID, str(pos + bmdelay)) if media.getMServer( contenturl) in file: # Check for paused Mezzmo files self.paflag = 1
def content_mapping(contentType): # Remap for skins which have limited Top / Folder views current_skin_name = xbmc.getSkinDir() if current_skin_name == 'skin.aeon.nox.5' or current_skin_name == 'skin.aeon.nox.silvo': aeonfoldermap = media.settings('aeoncontentmap') if aeonfoldermap != 'Default': contentType = aeonfoldermap.lower() if current_skin_name == 'skin.estuary': estuaryfoldermap = media.settings('estuarycontentmap') if estuaryfoldermap != 'Default': contentType = estuaryfoldermap.lower() return(contentType)
def onPlayBackStopped(self): contenturl = media.settings('contenturl') manufacturer = getContentURL(contenturl) objectID = getObjectID(file) bmdelay = 15 - int(media.settings('bmdelay')) xbmc.log( "Mezzmo Playback stopped at " + str(pos + bmdelay) + " in " + objectID, xbmc.LOGDEBUG) self.paflag = 0 if len( contenturl ) > 5 and 'Conceiva' in manufacturer: # Ensure Mezzmo server has been selected bookmark.SetBookmark(contenturl, objectID, str(pos + bmdelay))
def autoStart(): autdialog = xbmcgui.Dialog() if sys.argv[ 2] == "clear": # Ensure user reMost Recenty wants to clear autostart aumsg = "Are you sure you want to clear your curent Mezzmo addon autostart setting ?" cselect = autdialog.yesno('Mezzmo Autostart Clear', aumsg) else: # Confirm new autostart setting auplaylist = sys.argv[3].encode('utf-8', 'ignore') aumsg = "Confirm setting Mezzmo addon autostart to: \n\n" + auplaylist cselect = autdialog.yesno('Mezzmo Autostart Setting', aumsg) if cselect == 1: media.settings('autostart', sys.argv[2]) mgenlog = 'Mezzmo autostart set to: ' + str(sys.argv[2]) xbmc.log(mgenlog, xbmc.LOGNOTICE) media.mgenlogUpdate(mgenlog) xbmc.executebuiltin('Container.Refresh()')
def checkSync(): # Check for Sync server svrfile = openNosyncDB() # Open server database curps = svrfile.execute('SELECT controlUrl FROM mServers WHERE mSync=?', ('Yes', )) srvrtuple = curps.fetchone() # Get server from database if srvrtuple: syncurl = srvrtuple[0] else: contenturl = settings('contenturl') # Check for content URL curpc = svrfile.execute('SELECT srvName, sIcon FROM mServers WHERE controlUrl=?', \ (contenturl,)) srvrtuple = curpc.fetchone() # Get server from database if srvrtuple: # Auto update if Mezzmo found syncurl = contenturl sname = srvrtuple[0] if updateSync(contenturl) == 0: # Update sync server flag iconimage = srvrtuple[1] msynclog = 'Mezzmo sync server updated automatically: ' + str( sname) xbmc.log(msynclog, xbmc.LOGNOTICE) mezlogUpdate(msynclog) notify = xbmcgui.Dialog().notification(translate(30401), msynclog, addon_icon, 5000) else: # Sync srver not set yet syncurl = 'None' svrfile.close() return syncurl
def onPlayBackEnded(self): xbmc.log("Mezzmo Playback ended - LED OFF", xbmc.LOGDEBUG) contenturl = media.settings('contenturl') manufacturer = getContentURL(contenturl) objectID = getObjectID(file) pos = 0 self.paflag = 0 if len( contenturl ) > 5 and 'Conceiva' in manufacturer: # Ensure Mezzmo server has been selected bookmark.SetBookmark(contenturl, objectID, str(pos))
def deleteTexturesCache(contenturl): # do not cache texture images if caching disabled if media.settings('caching') == 'false': try: from sqlite3 import dbapi2 as sqlite except: from pysqlite2 import dbapi2 as sqlite DB = os.path.join(xbmc.translatePath("special://database"), "Textures13.db") db = sqlite.connect(DB) serverport = '%' + media.getServerport(contenturl) + '%' # Get Mezzmo server port info cur = db.execute('DELETE FROM texture WHERE url LIKE ?', (serverport,)) rows = cur.rowcount mgenlog ='Mezzmo addon texture rows deleted: ' + str(rows) xbmc.log(mgenlog, xbmc.LOGNOTICE) media.mgenlogUpdate(mgenlog) db.commit() cur.close() db.close() media.settings('caching', 'true') # reset back to true after clearing
def picDisplay(): # Picture slideshow presenter try: piclist = getPictures() # Get pictures from picture DB slidetime = int(settings('slidetime')) # Get slide pause time #xbmc.log('Mezzmo picture list: ' + str(piclist) , xbmc.LOGNOTICE) if 'upnp' in str( piclist[0]['url']): # Kodi cannot display pictures over uPNP dialog_text = translate(30413) xbmcgui.Dialog().ok(translate(30412), dialog_text) xbmc.executebuiltin('Action(ParentDir)') return else: cselect = 3 while cselect >= 0: #pictures = ['Slideshow','Pictures Normal Delay'] pictures = [ translate(30417), translate(30418), translate(30419) ] ddialog = xbmcgui.Dialog() cselect = ddialog.select(translate(30415), pictures) if cselect == 1: # User selects pictures normal showPictureMenu(piclist, slidetime) #xbmc.executebuiltin('Action(ParentDir)') if cselect == 2: # User selects pictures extended showPictureMenu(piclist, (slidetime * 3)) #xbmc.executebuiltin('Action(ParentDir)') elif cselect == 0: # User selects slideshow ShowSlides(piclist, slidetime) elif cselect < 0: #xbmc.executebuiltin('Action(ParentDir)') break #return except Exception as e: printexception() mgenlog = 'Mezzmo error displaying picture slideshow.' xbmc.log(mgenlog, xbmc.LOGNOTICE) mgenlogUpdate(mgenlog)
) > 5 and 'Conceiva' in manufacturer: # Ensure Mezzmo server has been selected bookmark.SetBookmark(contenturl, objectID, str(pos + bmdelay)) player = XBMCPlayer() monitor = xbmc.Monitor() media.checkNosyncDB() # Check nosync database while True: if xbmc.Player().isPlaying(): file = xbmc.Player().getPlayingFile() pos = long(xbmc.Player().getTime()) if count % 30 == 0: # Update bookmark once every 30 seconds during playback contenturl = media.settings('contenturl') manufacturer = getContentURL(contenturl) objectID = getObjectID(file) bmdelay = 15 - int(media.settings('bmdelay')) if contenturl != 'none' and 'Conceiva' in manufacturer: # Ensure Mezzmo server has been selected bookmark.SetBookmark(contenturl, objectID, str(pos + bmdelay)) count += 1 if count == 2: # Check for autostarting the Mezzmo GUI media.autostart() pacount += 1 if pacount % 30 == 0: # Check for paused video every 30 seconds pastoptime = int(media.settings('pastop')) xbmc.log('Mezzmo count and stop time ' + str(pacount) + ' ' + str(pastoptime) + \ ' ' + str(player.paflag), xbmc.LOGDEBUG)
def updateRealtime(mrecords, krecords, mlvcount, mnsyncount): # Disable real time updates when 90% sync achieved mezzmorecords = mrecords - mlvcount - mnsyncount # Calculate adjusted Mezzmo records if krecords >= mezzmorecords: # 100% maximum is Kodi > Mezzmo completepct = 100.0 elif krecords > 0 and mezzmorecords > 0: # Calculate % sync completepct = 1 / (float(mezzmorecords)/krecords) * 100.0 else: completepct = 0 if int(mezzmorecords * .9) > krecords: # Check if in sync media.settings('kodiactor', 'true') # Enable real time updates media.settings('kodichange', 'true') msynclog = 'Mezzmo sync process not yet in sync at {:.1f}'.format(completepct) + \ '%. Real time updates enabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) else: media.settings('kodiactor', 'false') # Disable real time updates media.settings('kodichange', 'false') msynclog = 'Mezzmo sync process in sync at {:.1f}'.format(completepct) + \ '%. Real time updates disabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) kodisync = media.settings('kodisync') # Check Kodi auto sync mksync = media.settings('kodisyncvar') # Get sync setting if kodisync == 'true': if int(completepct) > 90 and mksync != 'Off' \ and mksync != 'Newest': # Set to Newest > 90% media.settings('kodisyncvar', 'Newest') msynclog = 'Mezzmo autosync set to Newest.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) elif int(completepct) <= 90 and mksync != 'Off' \ and mksync != 'Normal': # Set to Normal <= 90% media.settings('kodisyncvar', 'Normal') msynclog = 'Mezzmo autosync set to Normal.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) else: msynclog = 'Mezzmo autosync is enabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) else: msynclog = 'Mezzmo autosync is disabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog)
def syncContent(content, syncurl, objectId, syncpin, syncoffset, maxrecords): # Mezzmo data parsing / insertion function contentType = 'movies' itemsleft = -1 global mezzmorecs, dupelog koditv = media.settings('koditv') try: while True: e = xml.etree.ElementTree.fromstring(content) body = e.find('.//{http://schemas.xmlsoap.org/soap/envelope/}Body') browseresponse = body.find('.//{urn:schemas-upnp-org:service:ContentDirectory:1}BrowseResponse') result = browseresponse.find('Result') NumberReturned = browseresponse.find('NumberReturned').text TotalMatches = browseresponse.find('TotalMatches').text xbmc.log('Mezzmo total matches = ' + str(TotalMatches), xbmc.LOGDEBUG) xbmc.log('Mezzmo number returned = ' + NumberReturned, xbmc.LOGDEBUG) xbmc.log('Mezzmo records = ' + str(mezzmorecs), xbmc.LOGDEBUG) if not TotalMatches: # Sanity check TotalMatches = 0 else: mezzmorecs = int(TotalMatches) + 5 # Set global variable with record count if int(NumberReturned) == 0: # Stop once offset = Total matches itemsleft = 0 return(0) break; #sanity check if maxrecords == 1000 or maxrecords > int(TotalMatches): TotalMatches = int(TotalMatches) + 5 dsyncflag = 1 else: TotalMatches = maxrecords dsyncflag = 0 if itemsleft == -1: itemsleft = TotalMatches #xbmc.log('Mezzmo offset = ' + str(syncoffset), xbmc.LOGNOTICE) #xbmc.log('Mezzmo items left initial = ' + str(itemsleft), xbmc.LOGNOTICE) elems = xml.etree.ElementTree.fromstring(result.text.encode('utf-8')) for container in elems.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}container'): title = container.find('.//{http://purl.org/dc/elements/1.1/}title').text containerid = container.get('id') description_text = '' description = container.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}longDescription') if description != None and description.text != None: description_text = description.text icon = container.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}albumArtURI') if icon != None: icon = icon.text if (icon[-4:]) != '.jpg': icon = icon + '.jpg' xbmc.log('Handle browse initial icon is: ' + icon, xbmc.LOGDEBUG) dbfile = media.openKodiDB() # Open Kodi database dbsync = media.openNosyncDB() # Open Mezzmo nosync database for item in elems.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}item'): title = item.find('.//{http://purl.org/dc/elements/1.1/}title').text itemid = item.get('id') icon = None albumartUri = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}albumArtURI') if albumartUri != None: icon = albumartUri.text if (icon[-4:]) != '.jpg': icon = icon + '.jpg' xbmc.log('Handle browse second icon is: ' + icon, xbmc.LOGDEBUG) else: icon = '' res = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}res') subtitleurl = None duration_text = '' video_width = 0 video_height = 0 aspect = 0.0 validf = 0 if res != None: itemurl = res.text #xbmc.log('The current URL is: ' + itemurl, xbmc.LOGNOTICE) subtitleurl = res.get('{http://www.pv.com/pvns/}subtitleFileUri') duration_text = res.get('duration') if duration_text == None: duration_text = '00:00:00.000' resolution_text = res.get('resolution') if resolution_text != None: mid = resolution_text.find('x') video_width = int(resolution_text[0:mid]) video_height = int(resolution_text[mid + 1:]) aspect = float(float(video_width) / float(video_height)) validf = 1 # Set valid file info flag backdropurl = '' backdropurl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}cvabackdrop') if backdropurl != None: backdropurl = backdropurl.text if (backdropurl [-4:]) != '.jpg': backdropurl = backdropurl + '.jpg' trailerurl = '' trailerurl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}trailer') if trailerurl != None: trailerurl = trailerurl.text genre_text = '' genre = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}genre') if genre != None: genre_text = genre.text aired_text = '' aired = item.find('.//{http://purl.org/dc/elements/1.1/}date') if aired != None: aired_text = aired.text album_text = '' album = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}album') if album != None: album_text = album.text release_year_text = '' release_year = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}release_year') if release_year != None: release_year_text = release_year.text release_date_text = '' release_date = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}release_date') if release_date != None: release_date_text = release_date.text description_text = '' description = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}longDescription') if description != None and description.text != None: description_text = description.text imageSearchUrl = '' imageSearchUrl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}imageSearchUrl') if imageSearchUrl != None: imageSearchUrl = imageSearchUrl.text artist_text = '' artist = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}artist') if artist != None: artist_text = artist.text.encode('utf-8', 'ignore') creator_text = '' creator = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}creator') if creator != None: creator_text = creator.text date_added_text = '' date_added = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}date_added') if date_added != None: date_added_text = date_added.text tagline_text = '' tagline = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}tag_line') if tagline != None: tagline_text = tagline.text categories = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}categories') episode_text = '' episode = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}episode') if episode != None: episode_text = episode.text season_text = '' season = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}season') if season != None: season_text = season.text playcount = 0 playcount_text = '' playcountElem = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}playcount') if playcountElem != None: playcount_text = playcountElem.text playcount = int(playcount_text) last_played_text = '' last_played = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}last_played') if last_played != None: last_played_text = last_played.text writer_text = '' writer = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}writers') if writer != None: writer_text = writer.text content_rating_text = '' content_rating = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}content_rating') if content_rating != None: content_rating_text = content_rating.text imdb_text = '' imdb = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}imdb_id') if imdb != None: imdb_text = imdb.text dcmInfo_text = '' dcmInfo = item.find('.//{http://www.sec.co.kr/}dcmInfo') if dcmInfo != None: dcmInfo_text = dcmInfo.text valPos = dcmInfo_text.find('BM=') + 3 dcmInfo_text = dcmInfo_text[valPos:] rating_val = '' rating = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}rating') if rating != None: rating_val = rating.text rating_val = float(rating_val) * 2 rating_val = str(rating_val) #kodi ratings are out of 10, Mezzmo is out of 5 production_company_text = '' production_company = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}production_company') if production_company != None: production_company_text = production_company.text sort_title_text = '' sort_title = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}sort_title') if sort_title != None: sort_title_text = sort_title.text video_codec_text = '' video_codec = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}video_codec') if video_codec != None: video_codec_text = video_codec.text if video_codec_text == 'vc1': # adjust for proper Kodi codec display video_codec_text = 'vc-1' audio_codec_text = '' audio_codec = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio_codec') if audio_codec != None: audio_codec_text = audio_codec.text audio_channels_text = '' audio_channels = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio_channels') if audio_channels != None: audio_channels_text = audio_channels.text audio_lang = '' audio_streams = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio') if audio_streams != None: for stream in audio_streams.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}stream'): if stream.get('selected') == 'auto' or stream.get('selected') == 'true': audio_lang = stream.get('lang') break subtitle_lang = '' captions_streams = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}captions') if captions_streams != None: for stream in captions_streams.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}stream'): if stream.get('selected') == 'auto' or stream.get('selected') == 'true': subtitle_lang = stream.get('language') break #mediaClass mediaClass_text = 'video' mediaClass = item.find('.//{urn:schemas-sony-com:av}mediaClass') if mediaClass != None: mediaClass_text = mediaClass.text if mediaClass_text == 'V': mediaClass_text = 'video' if mediaClass_text == 'M': mediaClass_text = 'music' if mediaClass_text == 'P': mediaClass_text = 'picture' #xbmc.log('Checking title: ' + title.encode('utf-8', 'ignore'), xbmc.LOGNOTICE) mtitle = media.displayTitles(title) tvcheckval = media.tvChecker(season_text, episode_text, koditv, mtitle, categories) # Check if Ok to add if tvcheckval[1] == 1 and validf == 1: # Update nosync database live channel media.syncCount(dbsync, mtitle, "livec") if tvcheckval[2] == 1 and validf == 1: # Update nosync database nosync media.syncCount(dbsync, mtitle, "nosync") if tvcheckval[0] == 1 and validf == 1: pathcheck = media.getPath(itemurl) # Get path string for media file serverid = media.getMServer(itemurl) # Get Mezzmo server id filekey = media.checkDBpath(itemurl, mtitle, playcount, dbfile, pathcheck, serverid, \ season_text, episode_text, album_text, last_played_text, date_added_text, dupelog) #xbmc.log('Checking movie: ' + mtitle.encode('utf-8', 'ignore'), xbmc.LOGNOTICE) #xbmc.log('Mezzmo filekey is: ' + str(filekey), xbmc.LOGNOTICE) durationsecs = getSeconds(duration_text) # convert movie duration to seconds before passing kodichange = 'true' # Enable change detection during sync if filekey[4] == 1: showId = media.checkTVShow(filekey, album_text, genre_text, dbfile, content_rating_text, \ production_company_text) mediaId = media.writeEpisodeToDb(filekey, mtitle, description_text, tagline_text, \ writer_text, creator_text, aired_text, rating_val, durationsecs, genre_text, trailerurl, \ content_rating_text, icon, kodichange, backdropurl, dbfile, production_company_text, \ sort_title_text, season_text, episode_text, showId, dupelog) else: mediaId = media.writeMovieToDb(filekey, mtitle, description_text, tagline_text, \ writer_text, creator_text, release_date_text, rating_val, durationsecs, genre_text, \ trailerurl, content_rating_text, icon, kodichange, backdropurl, dbfile, \ production_company_text, sort_title_text, dupelog) if (artist != None and filekey[0] > 0) or mediaId == 999999: # Add actor information to new movie media.writeActorsToDb(artist_text, mediaId, imageSearchUrl, mtitle, dbfile, filekey) media.writeMovieStreams(filekey, video_codec_text, aspect, video_height, video_width, \ audio_codec_text, audio_channels_text, audio_lang, durationsecs, mtitle, kodichange, itemurl, \ icon, backdropurl, dbfile, pathcheck, dupelog) # Update movie stream info xbmc.log('The movie name is: ' + mtitle.encode('utf-8'), xbmc.LOGDEBUG) itemsleft = itemsleft - int(NumberReturned) xbmc.log('Mezzmo items left: ' + str(itemsleft), xbmc.LOGDEBUG) dbfile.commit() # Commit writes if itemsleft <= 0: dbfile.commit() dbfile.close() # Final commit writes and close Kodi database dbsync.commit() dbsync.close() return(TotalMatches) break # get the next items offset = (TotalMatches - itemsleft) + syncoffset requestedCount = 1000 if itemsleft < 1000: requestedCount = itemsleft pin = media.settings('content_pin') content = browse.Browse(syncurl, objectId, 'BrowseDirectChildren', offset, requestedCount, syncpin) except Exception as e: printsyncexception() pass
def ghandleBrowse(content, contenturl, objectID, parentID): contentType = 'movies' itemsleft = -1 pitemsleft = -1 media.settings('contenturl', contenturl) slideshow = media.settings('slideshow') # Check if slideshow is enabled menuitem1 = addon.getLocalizedString(30347) menuitem2 = addon.getLocalizedString(30346) menuitem3 = addon.getLocalizedString(30372) menuitem4 = addon.getLocalizedString(30373) menuitem5 = addon.getLocalizedString(30379) menuitem6 = addon.getLocalizedString(30380) menuitem7 = addon.getLocalizedString(30384) menuitem8 = addon.getLocalizedString(30412) sync.deleteTexturesCache(contenturl) # Call function to delete textures cache if user enabled. #xbmc.log('Kodi version: ' + installed_version, xbmc.LOGNOTICE) try: while True: e = xml.etree.ElementTree.fromstring(content) body = e.find('.//{http://schemas.xmlsoap.org/soap/envelope/}Body') browseresponse = body.find('.//{urn:schemas-upnp-org:service:ContentDirectory:1}BrowseResponse') result = browseresponse.find('Result') NumberReturned = browseresponse.find('NumberReturned').text TotalMatches = browseresponse.find('TotalMatches').text if int(NumberReturned) == 0: dialog_text = media.translate(30421) + '\n' + xbmc.getInfoLabel("ListItem.Label") xbmcgui.Dialog().ok(media.translate(30424), dialog_text) xbmc.executebuiltin('Action(ParentDir)') break; #sanity check if itemsleft == -1: itemsleft = int(TotalMatches) elems = xml.etree.ElementTree.fromstring(result.text.encode('utf-8')) #elems = xml.etree.ElementTree.fromstring(result.text) picnotify = 0 for container in elems.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}container'): title = container.find('.//{http://purl.org/dc/elements/1.1/}title').text containerid = container.get('id') description_text = '' description = container.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}longDescription') if description != None and description.text != None: description_text = description.text icon = container.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}albumArtURI') if icon != None: icon = icon.text if (icon[-4:]) != '.jpg': icon = icon + '.jpg' xbmc.log('Handle browse initial icon is: ' + icon, xbmc.LOGDEBUG) itemurl = build_url({'mode': 'server', 'parentID': objectID, 'objectID': containerid, \ 'contentdirectory': contenturl}) li = xbmcgui.ListItem(title) li.setArt({'banner': icon, 'poster': icon, 'icon': icon, 'fanart': addon_fanart}) mediaClass_text = 'video' info = { 'plot': description_text, } li.setInfo(mediaClass_text, info) searchargs = urllib.urlencode({'mode': 'search', 'contentdirectory': contenturl, \ 'objectID': containerid}) li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)') ]) xbmcplugin.addDirectoryItem(handle=addon_handle, url=itemurl, listitem=li, isFolder=True) picnotify += 1 if parentID == '0': contentType = 'top' else: contentType = 'folders' contentType = content_mapping(contentType) piclist = [] clearPictures() upnpnotify = 0 for item in elems.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}item'): title = item.find('.//{http://purl.org/dc/elements/1.1/}title').text itemid = item.get('id') icon = None albumartUri = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}albumArtURI') if albumartUri != None: icon = albumartUri.text if (icon[-4:]) != '.jpg': icon = icon + '.jpg' xbmc.log('Handle browse second icon is: ' + icon, xbmc.LOGDEBUG) res = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}res') subtitleurl = None duration_text = '' video_width = 0 video_height = 0 aspect = 0.0 validf = 0 protocol_text = '' if res != None: itemurl = res.text #xbmc.log('The current URL is: ' + itemurl, xbmc.LOGNOTICE) subtitleurl = res.get('{http://www.pv.com/pvns/}subtitleFileUri') duration_text = res.get('duration') if duration_text == None: duration_text = '00:00:00.000' elif len(duration_text) < 9: # Check for proper duration Twonky duration_text = duration_text + '.000' elif int(duration_text[len(duration_text)-3:len(duration_text)]) <> 0: duration_text = duration_text[:6] + '.000' #xbmc.log('The duration is: ' + str(duration_text), xbmc.LOGNOTICE) resolution_text = res.get('resolution') if resolution_text != None: mid = resolution_text.find('x') video_width = int(resolution_text[0:mid]) video_height = int(resolution_text[mid + 1:]) aspect = float(float(video_width) / float(video_height)) protocol = res.get('protocolInfo') if protocol != None: protocol_text = protocol #xbmc.log('The protocol is: ' + str(protocol), xbmc.LOGNOTICE) else: duration_text = '00:00:00.000' itemurl = getItemlUrl(contenturl, itemid) if upnpnotify == 0: # Do not repeat notification upnpCheck() # Check Kodi service uPNP setting upnpnotify = 1 if itemurl == 'None': dialog_text = media.translate(30393) xbmcgui.Dialog().ok(media.translate(30406), dialog_text) xbmc.executebuiltin('Action(ParentDir)') break backdropurl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}cvabackdrop') if backdropurl != None: backdropurl = backdropurl.text if (backdropurl [-4:]) != '.jpg': backdropurl = backdropurl + '.jpg' poster = '' thumb = '' res2 = item.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}res') for protocol in res2: protocolinfo = protocol.attrib["protocolInfo"] if 'poster' in protocolinfo: poster = protocol.text if 'thumb' in protocolinfo: thumb = protocol.text if 'fanart' in protocolinfo and backdropurl == None: backdropurl = protocol.text if 'icon' in protocolinfo and icon == None: icon = protocol.text upnpclass_text = '' upnpclass = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}class') if upnpclass != None: upnpclass_text = upnpclass.text li = xbmcgui.ListItem(title) if len(thumb) > 0 and len(poster) > 0: li.setArt({'thumb': thumb, 'poster': poster, 'icon': icon, 'fanart': backdropurl}) else: li.setArt({'thumb': icon, 'poster': icon, 'icon': icon, 'fanart': backdropurl}) if subtitleurl != None: li.setSubtitles([subtitleurl]) trailerurl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}trailer') if trailerurl != None: trailerurl = trailerurl.text genre_text = [] for genre in item.findall('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}genre'): if genre != None: genre_text.append(genre.text.encode('utf-8')) #xbmc.log('Mezzmo genre list is: ' + str(genre_text), xbmc.LOGNOTICE) aired_text = '' aired = item.find('.//{http://purl.org/dc/elements/1.1/}date') if aired != None: aired_text = aired.text album_text = '' album = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}album') if album != None: album_text = album.text release_year_text = '' release_year = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}release_year') if release_year != None: release_year_text = release_year.text release_date_text = '' release_date = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}release_date') if release_date != None: release_date_text = release_date.text description_text = '' description = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}longDescription') if description != None and description.text != None: description_text = description.text imageSearchUrl = '' imageSearchUrl = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}imageSearchUrl') if imageSearchUrl != None: imageSearchUrl = imageSearchUrl.text artist_text = '' artist = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}artist') if artist != None: artist_text = artist.text actor_list = '' cast_dict = [] # Added cast & thumbnail display from Mezzmo server cast_dict_keys = ['name','thumbnail'] actors = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}artist') if actors != None and imageSearchUrl != None: actor_list = actors.text.encode('utf-8', 'ignore').replace(', Jr.' , ' Jr.').replace(', Sr.' , ' Sr.').split(',') for a in actor_list: actorSearchUrl = imageSearchUrl + "?imagesearch=" + a.lstrip().replace(" ","+") #xbmc.log('search URL: ' + actorSearchUrl, xbmc.LOGNOTICE) # uncomment for thumbnail debugging new_record = [ a.strip() , actorSearchUrl] cast_dict.append(dict(zip(cast_dict_keys, new_record))) elif actors == None: actor_list = [] for actor in item.findall('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}actor'): if actor != None: actor_list.append(actor.text.encode('utf-8')) artist_text = actor_list #xbmc.log('Mezzmo actor list is: ' + str(actor_list), xbmc.LOGNOTICE) #if len(actor_list) == 0: # Sanity check for missing artists # artist_text = ["Unknown artist"] if isinstance(artist_text, str): # Sanity check for missing artists artist_text = ["Unknown artist"] creator_text = '' creator = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}creator') if creator != None: creator_text = creator.text elif creator == None: creator = item.find('.//{http://purl.org/dc/elements/1.1/}creator') if creator != None: creator_text = creator.text director_text = '' director = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}director') if director != None: creator_text = director.text date_added_text = '' date_added = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}date_added') if date_added != None: date_added_text = date_added.text else: # Kodi uPNP date_added = item.find('.//{urn:schemas-xbmc-org:metadata-1-0/}dateadded') if date_added != None: date_added_text = date_added.text tagline_text = '' tagline = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}tag_line') if tagline != None: tagline_text = tagline.text else: # Kodi uPNP tagline = item.find('.//{http://purl.org/dc/elements/1.1/}description') if tagline != None: tagline_text = tagline.text categories_text = 'movie' categories = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}categories') if categories != None and categories.text != None: categories_text = categories.text.split(',')[0] # Kodi can only handle 1 media type if categories_text[:7].lower() == 'tv show': categories_text = 'episode' contentType = 'episodes' elif categories_text[:5].lower() == 'movie': categories_text = 'movie' contentType = 'movies' album_text = '' elif categories_text[:11].lower() == 'music video': categories_text = 'musicvideo' contentType = 'musicvideos' album_text = '' else: categories_text = 'video' contentType = 'videos' album_text = '' episode_text = '' episode = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}episode') if episode != None: episode_text = episode.text season_text = '' season = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}season') if season != None: season_text = season.text playcount = 0 playcount_text = '' playcountElem = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}playcount') if playcountElem != None: playcount_text = playcountElem.text playcount = int(playcount_text) playcountElem = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}playbackCount') if playcountElem != None: # Kodi uPNP playcount_text = playcountElem.text playcount = int(playcount_text) last_played_text = '' last_played = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}last_played') if last_played != None: last_played_text = last_played.text last_played_text = '' # Kodi uPNP last_played = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}lastPlaybackTime') if last_played != None: last_played_text = last_played.text writer_text = '' writer = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}writers') if writer != None: writer_text = writer.text writer_text = '' # Kodi uPNP writer = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}author') if writer != None: writer_text = writer.text content_rating_text = '' content_rating = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}content_rating') if content_rating != None: content_rating_text = content_rating.text content_rating_text = '' # Kodi uPNP content_rating = item.find('.//{urn:schemas-upnp-org:metadata-1-0/upnp/}rating') if content_rating != None: content_rating_text = content_rating.text imdb_text = '' imdb = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}imdb_id') if imdb != None: imdb_text = imdb.text dcmInfo_text = '0' dcmInfo = item.find('.//{http://www.sec.co.kr/}dcmInfo') if dcmInfo != None: dcmInfo_text = dcmInfo.text valPos = dcmInfo_text.find('BM=') + 3 dcmInfo_text = dcmInfo_text[valPos:] rating_val = '' rating = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}rating') if rating != None: rating_val = rating.text rating_val = float(rating_val) * 2 rating_val = str(rating_val) #kodi ratings are out of 10, Mezzmo is out of 5 rating_val = '' # Kodi uPNP rating = item.find('.//{urn:schemas-xbmc-org:metadata-1-0/}userrating') if rating != None: rating_val = rating.text production_company_text = '' production_company = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}production_company') if production_company != None: production_company_text = production_company.text production_company_text = '' production_company = item.find('.//{http://purl.org/dc/elements/1.1/}publisher') if production_company != None: production_company_text = production_company.text sort_title_text = '' sort_title = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}sort_title') if sort_title != None: sort_title_text = sort_title.text video_codec_text = '' video_codec = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}video_codec') if video_codec != None: video_codec_text = video_codec.text if video_codec_text == 'vc1': # adjust for proper Kodi codec display video_codec_text = 'vc-1' audio_codec_text = '' audio_codec = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio_codec') if audio_codec != None: audio_codec_text = audio_codec.text audio_channels_text = '0' audio_channels = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio_channels') if audio_channels != None: audio_channels_text = audio_channels.text audio_lang = '' audio_streams = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}audio') if audio_streams != None: for stream in audio_streams.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}stream'): if stream.get('selected') == 'auto' or stream.get('selected') == 'true': audio_lang = stream.get('lang') break subtitle_lang = '' captions_streams = item.find('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}captions') if captions_streams != None: for stream in captions_streams.findall('.//{urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/}stream'): if stream.get('selected') == 'auto' or stream.get('selected') == 'true': subtitle_lang = stream.get('language') break #mediaClass if 'video' in upnpclass_text or 'video' in protocol_text: mediaClass_text = 'video' if 'audio' in upnpclass_text or 'audio' in protocol_text: mediaClass_text = 'music' if 'photo' in upnpclass_text or 'image' in protocol_text: mediaClass_text = 'pictures' if mediaClass_text == 'video': li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)') ]) info = { 'duration': sync.getSeconds(duration_text), 'genre': genre_text, 'year': release_year_text, 'title': title, 'plot': description_text, 'director': creator_text, 'tagline': tagline_text, 'writer': writer_text, 'cast': artist_text, 'artist': artist_text, 'rating': rating_val, 'imdbnumber': imdb_text, 'mediatype': categories_text, 'season': season_text, 'episode': episode_text, 'lastplayed': last_played_text, 'aired': aired_text, 'mpaa':content_rating_text, 'studio':production_company_text, 'playcount':playcount, 'trailer':trailerurl, 'tvshowtitle':album_text, 'dateadded':date_added_text, } li.setInfo(mediaClass_text, info) li.setProperty('ResumeTime', dcmInfo_text) li.setProperty('TotalTime', str(sync.getSeconds(duration_text))) video_info = { 'codec': video_codec_text, 'aspect': aspect, 'width': video_width, 'height': video_height, } li.addStreamInfo('video', video_info) li.addStreamInfo('audio', {'codec': audio_codec_text, 'language': audio_lang, 'channels': int(audio_channels_text)}) li.addStreamInfo('subtitle', {'language': subtitle_lang}) elif mediaClass_text == 'music': mtitle = media.displayTitles(title) # Normalize title pctitle = '"' + mtitle.encode('utf-8','ignore') + '"' # Handle commas li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)') ]) #offsetmenu = 'Resume from ' + time.strftime("%H:%M:%S", time.gmtime(int(dcmInfo_text))) info = { 'duration': sync.getSeconds(duration_text), 'genre': genre_text, 'year': release_year_text, 'title': pctitle, 'artist': artist_text, 'rating': rating_val, 'discnumber': season_text, 'mediatype': 'song', 'tracknumber': episode_text, 'album': album_text, 'playcount':playcount, 'lastplayed': last_played_text, } #mcomment = media.mComment(info, duration_text, offsetmenu[11:]) #info.update(comment = mcomment) li.setInfo(mediaClass_text, info) contentType = 'songs' elif mediaClass_text == 'pictures': li.addContextMenuItems([ (menuitem1, 'Container.Refresh'), (menuitem2, 'Action(ParentDir)'), \ (menuitem8, 'RunScript(%s, %s)' % ("plugin.video.mezzmo", "pictures")) ]) info = { 'title': title, } li.setInfo(mediaClass_text, info) contentType = 'files' picnotify += 1 itemdict = { 'title': title, 'url': itemurl, } piclist.append(itemdict) if picnotify == int(NumberReturned): # Update picture DB updatePictures(piclist) if slideshow == 'true': # Slideshow display prompt picDisplay() itemurl = build_url({'mode': 'picture', 'itemurl': itemurl}) xbmcplugin.addDirectoryItem(handle=addon_handle, url=itemurl, listitem=li, isFolder=False) itemsleft = itemsleft - int(NumberReturned) - 1 xbmc.log('Mezzmo items left: ' + str(itemsleft), xbmc.LOGDEBUG) if itemsleft <= 0: break if pitemsleft == itemsleft: # Detect items left not incrementing mgenlog ='Mezzmo items not displayed: ' + str(pitemsleft) xbmc.log(mgenlog, xbmc.LOGNOTICE) media.mgenlogUpdate(mgenlog) break else: pitemsleft = itemsleft # get the next items offset = int(TotalMatches) - itemsleft requestedCount = 1000 if itemsleft < 1000: requestedCount = itemsleft pin = media.settings('content_pin') content = browse.Browse(contenturl, objectID, 'BrowseDirectChildren', offset, requestedCount, pin) except Exception as e: media.printexception() pass setViewMode(contentType) if contentType == 'top' or contentType == 'folders': contentType = '' xbmcplugin.setContent(addon_handle, contentType) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_UNSORTED) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_DATE) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_GENRE) xbmcplugin.addSortMethod(addon_handle, xbmcplugin.SORT_METHOD_DURATION) xbmcplugin.endOfDirectory(addon_handle)
def getServers(): # Find uPNP servers try: timeoutval = float(settings('ssdp_timeout')) contenturl = '' msgdialogprogress = xbmcgui.DialogProgress() dialogmsg = translate(30402) dialoghead = translate(30401) msgdialogprogress.create(dialoghead, dialogmsg) servers = ssdp.discover("urn:schemas-upnp-org:device:MediaServer:1", timeout=timeoutval) srvcount = len(servers) addtlmsg = ' ' + str(srvcount) + ' uPNP servers discovered.' ddialogmsg = dialogmsg + addtlmsg msgdialogprogress.update(50, ddialogmsg) xbmc.sleep(1000) if srvcount > 0: msynclog = 'Mezzmo sync server search: ' + str( srvcount) + ' uPNP servers found.' xbmc.log(msynclog, xbmc.LOGNOTICE) mezlogUpdate(msynclog) else: msynclog = translate(30403) xbmcgui.Dialog().notification(translate(30401), msynclog, addon_icon, 5000) xbmc.log(msynclog, xbmc.LOGNOTICE) mezlogUpdate(msynclog) return 0 onlyShowMezzmo = False a = 0 mcount = 0 # Count of Mezzmo serves found for server in servers: url = server.location try: response = urllib2.urlopen(url) xmlstring = re.sub(' xmlns="[^"]+"', '', response.read(), count=1) e = xml.etree.ElementTree.fromstring(xmlstring) device = e.find('device') friendlyname = device.find('friendlyName').text manufacturer = device.find('manufacturer').text if manufacturer != None: manufacturer = manufacturer.text else: manufacturer = 'None' modelnumber = device.find('modelNumber') if modelnumber != None: modelnumber = modelnumber.text else: modelnumber = 'None' udn = device.find('UDN') if udn != None: udn = udn.text else: udn = 'None' description = device.find('modelDescription') if description != None: description = description.text else: description = 'None' serviceList = device.find('serviceList') iconList = device.find('iconList') iconurl = '' isMezzmo = False if manufacturer != None and manufacturer == 'Conceiva Pty. Ltd.': iconurl = addon_icon isMezzmo = True mcount += 1 elif iconList != None: bestWidth = 0 for icon in iconList.findall('icon'): mimetype = icon.find('mimetype').text width = icon.find('width').text height = icon.find('height').text width = int(width) if width > bestWidth: bestWidth = width iconurl = icon.find('url').text if iconurl.startswith('/'): end = url.find('/', 8) length = len(url) iconurl = url[:end - length] + iconurl else: end = url.rfind('/') length = len(url) iconurl = url[:end - length] + '/' + iconurl else: iconurl = addon_path + '/resources/media/otherserver.png' if isMezzmo or onlyShowMezzmo == False: contenturl = '' for service in serviceList.findall('service'): serviceId = service.find('serviceId') if serviceId.text == 'urn:upnp-org:serviceId:ContentDirectory': contenturl = service.find('controlURL').text if contenturl.startswith('/'): end = url.find('/', 8) length = len(url) contenturl = url[:end - length] + contenturl elif 'http' not in contenturl: end = url.rfind('/') length = len(url) contenturl = url[:end - length] + '/' + contenturl updateServers(url, friendlyname, contenturl, manufacturer, modelnumber, \ iconurl, description, udn) except urllib2.URLError, urllib2.HTTPError: # Detect Server Issues msynclog = 'Mezzmo uPNP server not responding: ' + url xbmc.log(msynclog, xbmc.LOGNOTICE) mezlogUpdate(msynclog) dialog_text = translate(30405) + url xbmcgui.Dialog().ok(translate(30404), dialog_text) pass a += 1 percent = int(a / float(srvcount) * 50) + 50 dialogmsg = str(a) + ' / ' + str(srvcount) + ' server completed.' msgdialogprogress.update(percent, dialogmsg) xbmc.sleep(500) msgdialogprogress.close() return mcount
def setViewMode(contentType): if media.settings('viewmap') == 'false': # Mezzmo view mapping is disabled return current_skin_name = xbmc.getSkinDir() #xbmc.log('The content type is ' + contentType, xbmc.LOGNOTICE) #xbmc.log('The current skin name is ' + current_skin_name, xbmc.LOGNOTICE) if current_skin_name == 'skin.aeon.nox.5' or current_skin_name == 'skin.aeon.nox.silvo': aeon_nox_views = { 'List' : 50 , 'InfoWall' : 51 , 'Landscape' : 52 , 'ShowCase1' : 53 , 'ShowCase2' : 54 , 'TriPanel' : 55 , 'Posters' : 56 , 'Shift' : 57 , 'BannerWall' : 58 , 'Logo' : 59 , 'Icons' : 500 , 'LowList' : 501 , 'Episode' : 502 , 'Wall' : 503 , 'Gallery' : 504 , 'Panel' : 505 , 'RightList' : 506 , 'BigList' : 507 , 'SongList' : 508 , 'MyFlix' : 509 , 'BigFan' : 591 , 'BannerPlex' : 601 , 'FanartList' : 602 , 'Music_JukeBox' : 603, 'Fullscreen_Wall' : 609, } view_mode = media.settings(contentType + '_view_mode' + '_aeon') if view_mode != 'Default': selected_mode = aeon_nox_views[view_mode] xbmc.executebuiltin('Container.SetViewMode(' + str(selected_mode) + ')') elif current_skin_name == 'skin.aeon.madnox': aeon_nox_views = { 'List' : 50 , 'InfoWall' : 51 , 'Landscape' : 503 , 'ShowCase1' : 501 , 'ShowCase2' : 501 , 'TriPanel' : 52 , 'Posters' : 510 , 'Shift' : 57 , 'BannerWall' : 508 , 'Logo' : 59 , 'Wall' : 500 , 'LowList' : 501 , 'Episode' : 514 , 'Wall' : 500 , 'BigList' : 510 } view_mode = media.settings(contentType + '_view_mode' + '_aeon') if view_mode != 'Default': selected_mode = aeon_nox_views[view_mode] xbmc.executebuiltin('Container.SetViewMode(' + str(selected_mode) + ')') elif current_skin_name == 'skin.estuary': estuary_views = { 'List' : 50 , 'Posters' : 51 , 'IconWall' : 52 , 'Shift' : 53 , 'InfoWall' : 54 , 'WideList' : 55 , 'Wall' : 500 , 'Banner' : 501 , 'FanArt' : 502 } view_mode = media.settings(contentType + '_view_mode' + '_estuary') if view_mode != 'Default': selected_mode = estuary_views[view_mode] xbmc.executebuiltin('Container.SetViewMode(' + str(selected_mode) + ')') elif media.settings(contentType + '_view_mode') != "0": try: if media.settings(contentType + '_view_mode') == "1": # List xbmc.executebuiltin('Container.SetViewMode(502)') elif media.settings(contentType + '_view_mode') == "2": # Big List xbmc.executebuiltin('Container.SetViewMode(51)') elif media.settings(contentType + '_view_mode') == "3": # Thumbnails xbmc.executebuiltin('Container.SetViewMode(500)') elif media.settings(contentType + '_view_mode') == "4": # Poster Wrap xbmc.executebuiltin('Container.SetViewMode(501)') elif media.settings(contentType + '_view_mode') == "5": # Fanart xbmc.executebuiltin('Container.SetViewMode(508)') elif media.settings(contentType + '_view_mode') == "6": # Media info xbmc.executebuiltin('Container.SetViewMode(504)') elif media.settings(contentType + '_view_mode') == "7": # Media info 2 xbmc.executebuiltin('Container.SetViewMode(503)') elif media.settings(contentType + '_view_mode') == "8": # Media info 3 xbmc.executebuiltin('Container.SetViewMode(515)') elif media.settings(contentType + '_view_mode') == "9": # Music info xbmc.executebuiltin('Container.SetViewMode(506)') except: xbmc.log("SetViewMode Failed: "+media.settings('_view_mode')) xbmc.log("Skin: "+xbmc.getSkinDir())
def syncMezzmo(syncurl, syncpin, count): # Sync Mezzmo to Kodi global syncoffset, dupelog ksync = media.settings('kodisyncvar') # Get sync setting if 'ContentDirectory' not in syncurl: msynclog = 'Mezzmo sync process aborted. Invalid server selected.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) return if ksync != 'Off': # Check if enabled msynclog = 'Mezzmo sync beginning.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) starttime = time.time() rows = 0 newoffset = media.settings('sync_offset') # Get saved offset setting try: syncoffset = int(newoffset) except: syncoffset = 0 media.settings('sync_offset', str(syncoffset)) clean = checkDailySync() # Check sync flag if clean == 1 and count > 12: force = 1 media.kodiCleanDB(force) # Clear Kodi database daily if count < 12: content = browse.Browse(syncurl, 'recent', 'BrowseDirectChildren', 0, 400, syncpin) rows = syncContent(content, syncurl, 'recent', syncpin, 0, 400) recs = media.countKodiRecs(syncurl) # Get record count in Kodi DB recscount = media.countsyncCount() # Get nosync record count in nosync DB nsyncount = recscount[0] lvcount = recscount[1] # Get Live Channel record count in nosync DB msynclog = 'Mezzmo total Mezzmo record count: ' + str(mezzmorecs) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total Live Channels count: ' + str(lvcount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total nosync videos count: ' + str(nsyncount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) updateRealtime(mezzmorecs, recs, lvcount, nsyncount) elif clean == 0 and ksync != 'Daily': # Hourly sync set of records content = browse.Browse(syncurl, 'recent', 'BrowseDirectChildren', 0, 400, syncpin) rows = syncContent(content, syncurl, 'recent', syncpin, 0, 400) if rows == None: # Did sync get data from Mezzmo server ? rows = 0 msynclog = 'Mezzmo sync process could not contact the Mezzmo server' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) xbmc.log('Mezzmo sync offset = ' + str(syncoffset), xbmc.LOGDEBUG) if rows == 400 and syncoffset % 400 == 0 \ and ksync != 'Newest': # Mezzmo database > 400 records syncoffset = syncoffset + rows - 400 if mezzmorecs > 5000: # Faster hourly sync for large databases fetch = (mezzmorecs // 800) // 6 * 800 else: # Number of records to get from Mezzmo fetch = 800 # Slow hourly fetch itemsleft = (mezzmorecs - syncoffset) # Items remaining in Mezzmo if itemsleft < fetch: # Detect end of Mezzmo database fetch = itemsleft xbmc.log('Mezzmo fetch = ' + str(fetch), xbmc.LOGDEBUG) content = browse.Browse(syncurl, 'recent', 'BrowseDirectChildren', syncoffset, fetch, syncpin) rows1 = syncContent(content, syncurl, 'recent', syncpin, syncoffset, fetch) xbmc.log('Mezzmo sync rows1 = ' + str(rows1), xbmc.LOGDEBUG) if rows1 != None and rows1 > 0: syncoffset = syncoffset + rows1 rows = rows + rows1 else: syncoffset = 400 xbmc.log('Mezzmo sync rows test = ' + str(rows), xbmc.LOGDEBUG) if rows % 400 <> 0: # Start back through the Mezzmo database syncoffset = 400 recs = media.countKodiRecs(syncurl) # Get record count in Kodi DB recscount = media.countsyncCount() # Get nosync record count in nosync DB nsyncount = recscount[0] lvcount = recscount[1] # Get Live Channel record count in nosync DB msynclog = 'Mezzmo total Mezzmo record count: ' + str(mezzmorecs) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total Live Channels count: ' + str(lvcount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total nosync videos count: ' + str(nsyncount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) updateRealtime(mezzmorecs, recs, lvcount, nsyncount) elif clean == 1: # Sync all daily media.settings('kodiactor', 'false') # Disable real time updating ahead of full sync media.settings('kodichange', 'false') dupelog = media.settings('mdupelog') # Check if Mezzmo duplicate logging is enabled if dupelog == 'true': msynclog = 'Mezzmo duplicate logging is enabled. ' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) syncoffset = 0 lvcount = 0 # Reset live channel skip counter nsyncount = 0 # Reset nosync skip counter content = browse.Browse(syncurl, 'recent', 'BrowseDirectChildren', 0, 1000, syncpin) rows = syncContent(content, syncurl, 'recent', syncpin, 0, 1000) recs = media.countKodiRecs(syncurl) # Get record count in Kodi DB recscount = media.countsyncCount() # Get nosync record count in nosync DB nsyncount = recscount[0] lvcount = recscount[1] # Get Live Channel record count in nosync DB msynclog = 'Mezzmo total Mezzmo record count: ' + str(mezzmorecs) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total Live Channels count: ' + str(lvcount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) msynclog = 'Mezzmo total nosync videos count: ' + str(nsyncount) xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) media.optimizeDB() # Optimize DB after resync media.settings('dailysync', '1') # Set daily sync flag endtime = time.time() duration = endtime-starttime difference = str(int(duration // 60)) + 'm ' + str(int(duration % 60)) + 's checked.' media.settings('sync_offset', str(syncoffset)) dupelog = 'false' # Set Mezzmo duplicate logging to disable if ksync != 'Daily' or count < 30 or clean == 1: # Display summary stats if restart or not daily msynclog = 'Mezzmo sync completed. ' + str(rows) + ' videos in ' + difference elif ksync == 'Daily': msynclog = 'Mezzo sync Daily set. Hourly sync not enabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) if ksync != 'Daily': msynclog = 'Mezzmo sync setting is: ' + media.settings('kodisyncvar') xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog) if media.settings('perflog') == 'true': # Check if performance logging is enabled msynclog = 'Mezzmo performance logging is enabled.' xbmc.log(msynclog, xbmc.LOGNOTICE) media.mezlogUpdate(msynclog)
from server import getItemlUrl, upnpCheck, picDisplay from server import clearPictures, updatePictures addon = xbmcaddon.Addon() base_url = sys.argv[0] addon_handle = int(sys.argv[1]) #argmod = sys.argv[2][1:].replace(';','&') # Handle change in urllib parsing to default to & args = urlparse.parse_qs(sys.argv[2][1:]) addon_path = addon.getAddonInfo("path") addon_icon = addon_path + '/resources/icon.png' addon_fanart = addon_path + '/resources/fanart.jpg' #installed_version = media.get_installedversion() gsrvrtime = int(media.settings('gsrvrtime')) if not gsrvrtime: gsrvrtime = 60 def build_url(query): return base_url + '?' + urllib.urlencode(query) def content_mapping(contentType): # Remap for skins which have limited Top / Folder views current_skin_name = xbmc.getSkinDir() if current_skin_name == 'skin.aeon.nox.5' or current_skin_name == 'skin.aeon.nox.silvo': aeonfoldermap = media.settings('aeoncontentmap') if aeonfoldermap != 'Default': contentType = aeonfoldermap.lower() if current_skin_name == 'skin.estuary':