def getConfigInfo(): try: _json = utils.loadJsonFromUrl(jsonurl + "config.php?version=" + __addon__.getAddonInfo('version')) if _json == None: xbmcgui.Dialog().ok(__addonname__, ' ', __language__(70111)) return filename = _json[0]['full_file_name'] urlname = _json[0]['url_name'] print filename print urlname if filename == None and urlname == None: xbmcgui.Dialog().ok(__addonname__, ' ', __language__(70117)) donotloaddir = 1 return line1 = "This is a simple example of OK dialog" line2 = "Showing this message using" line3 = "XBMC python modules" xbmcgui.Dialog().ok(__addonname__, line1, line2, line3) except Exception as e: buggalo.onExceptionRaised() print (e)
def GETLUCKY(url, mode): url = url + '?type='+mode.lower() print jsonurl + url _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): addDir(_json[0]['song_name'], 'getlink.php', 'getVideo', '', '1',_json[0]['general_id'], _json[0]['temp_key']) else: xbmcgui.Dialog().ok(__addonname__, __language__(70101), __language__(70102), __language__(70103))
def SEARCH(url, mode, pageid, searchq = ""): if searchq == None: if mode == 'searchArtists': keyboard = xbmc.Keyboard('', __language__(70000)) if mode == 'searchSongs': keyboard = xbmc.Keyboard('', __language__(70001)) if mode == 'searchIDs': keyboard = xbmc.Keyboard('', __language__(70002)) keyboard.doModal() if keyboard.isConfirmed(): searchq = keyboard.getText().replace(' ','%20') if searchq == None: return False if not re.match('[A-Za-z0-9 ]', searchq): # this part doesn't work for some reason... d = xbmcgui.Dialog() d.ok(__addonname__, __language__(70104)) HOME() return False url = url + '?type='+mode.lower() url = url + '&pageid='+ str(pageid) url = url + '&extra='+ str(searchq) print jsonurl + url if str(searchq) != 'None': pageid = int(pageid) + 1 _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): count = 0 if mode == 'searchArtists': for items in _json: count = count + 1 items["sd_id"] = str(items["sd_id"]) addDir(items['artist_name'], 'search.php', 'getSongsByArtist', '', '0',items['artist_id'], items['sd_id']) if count == 30: addDir(__language__(70100), 'search.php', 'searchArtists', '', str(pageid),'', searchq) if mode == 'searchSongs': for items in _json: count = count + 1 addDir(items['song_name'], 'getlink.php', 'getVideo', '', '1',items['general_id'], items['temp_key']) if count == 30: addDir(__language__(70100), 'search.php', 'searchSongs', '', str(pageid),'', searchq) if mode == 'searchIDs': for items in _json: # count = count + 1 addDir(items['song_name'], 'getlink.php', 'getVideo', '', '1',items['general_id'], items['temp_key']) # if count == 30: # addDir(__language__(70100), 'search.php', 'searchSongs', '', str(pageid),'', searchq) else: xbmcgui.Dialog().ok(__addonname__, __language__(70111), __language__(70112), __language__(70113)) HOME() else: HOME()
def GETPOPULAR(url, mode): url = url + '?type='+mode.lower() print jsonurl + url _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): count = 0 for items in _json: count = count + 1 addDir(str(count).zfill(2) + '.' + items['song_name'], 'getlink.php', 'getVideo', '', '1',items['general_id'], items['temp_key']) else: xbmcgui.Dialog().ok(__addonname__, __language__(70101), __language__(70102), __language__(70103))
def GETQRCODE(url, mode): url = url + '?type='+mode.lower() print jsonurl + url _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): __addon__.setSetting('session_key', _json[0]['unique_id']) # __addon__.setSetting('session_date', time.strftime("%Y%m%d%H%M%S")) __addon__.setSetting('session_date', str(time.time()+1800)) window = utils.QRWindow() window.QRlink(_json[0]['QR_link']) window.show() window.doModal() print 'session key: ' + __addon__.getSetting('session_key') print 'session unix timestamp: ' + __addon__.getSetting('session_date') else: xbmcgui.Dialog().ok(__addonname__, __language__(70101), __language__(70102), __language__(70103))
def BROWSELATEST(url, mode, pageid): url = url + '?type='+mode.lower() url = url + '&pageid='+ str(pageid) print jsonurl + url pageid = int(pageid) + 1 _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): count = 0 for items in _json: count = count + 1 addDir(items['song_name'], 'getlink.php', 'getVideo', '', '1',items['general_id'], items['temp_key']) if count == 30: addDir(__language__(70100), 'search.php', 'getLatest', '', str(pageid),id, '') else: xbmcgui.Dialog().ok(__addonname__, __language__(70101), __language__(70102), __language__(70103))
def BROWSEARTISTS(url, mode, pageid, letter): url = url + '?type='+mode.lower() url = url + '&pageid='+ str(pageid) url = url + '&extra='+ str(letter) print jsonurl + url pageid = int(pageid) + 1 _json = utils.loadJsonFromUrl(jsonurl + url) if (_json): count = 0 for items in _json: count = count + 1 items["sd_id"] = str(items["sd_id"]) addDir(items['artist_name'], 'search.php', 'getSongsByArtist', '', '0',items['artist_id'], items['sd_id']) #addDir(name, url, mode, iconimage,page, id, param1, param2="", isfolder=True): if count == 30: addDir(__language__(70100), 'search.php', 'browseArtists', '', str(pageid),'', str(letter)) else: xbmcgui.Dialog().ok(__addonname__, __language__(70101), __language__(70102), __language__(70103))
def KARAOKELINKS(url, id, tempkey): if tempkey == 'session': url = url + '?generalid='+ __addon__.getSetting('session_key') else: url = url + '?generalid='+ str(id) url = url + '&tempkey='+ str(tempkey) print jsonurl + url try: _json = utils.loadJsonFromUrl(jsonurl + url) filename = _json[0]['full_file_name'] urlname = _json[0]['url_name'] print filename print urlname if filename == None and urlname == None: xbmcgui.Dialog().ok(__addonname__, ' ', __language__(70117)) donotloaddir = 1 return timestr = time.strftime("%Y%m%d%H%M%S") fullDir = os.path.join(PATH, TEMP_DL_DIR + timestr) #delete directory deleteDir(fullDir) print 'Directory' print fullDir #download new file #fullFilePath = os.path.splitext(os.path.join(fullDir, filename))[0] #fullFilePath = fullFilePath + '.mp3' if getUnzipped(urlname, fullDir, filename, id) == 1: os.chdir(fullDir) i = 1 for files in glob.glob("*.mp3"): if i == 1: i = 2 xbmc.Player().play(os.path.join(fullDir, files)) if len(glob.glob("*.mp3")) < 1: reportFile('badzip', id, filename, urlname); xbmcgui.Dialog().ok(__addonname__, __language__(70123), __language__(70124), __language__(70125)) #xbmcplugin.endOfDirectory(int(sys.argv[1])) #while xbmc.Player().isPlaying(): # print 'sleeping...' # xbmc.sleep(1000) #def addDir(name,url,mode,iconimage,page, id, param1, param2="", isfolder=True): liz=xbmcgui.ListItem('', '', iconImage='DefaultAlbumCover.png', thumbnailImage='') #liz.setInfo( type='music', infoLabels={ 'Title': name, 'count': id} ) xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url='',listitem=liz,isFolder=0) except Exception as e: buggalo.onExceptionRaised() print (e)