def isFilePlayable(path): try: return ('.' + sfile.getextension(path) in PLAYABLE) except: return False
def DownloadFile(name, src, dst, image=None): orignalSrc = src playlist = False isSrc = src.lower().endswith('.txt') or src.lower().endswith('.%s' % SRC) if isSrc: src = urllib.quote_plus(src) src = s3.getURL(src) src = s3.convertToCloud(src) src = utils.GetHTML(src, maxAge=7*86400) src = src.replace('\r', '') src = src.split('\n') if len(src) > 1: repeatMode = GetRepeatMode() AddPlaylistToPlaylist(name, image, orignalSrc, AMAZON_FILE, isFirst=True) xbmc.executebuiltin('PlayerControl(%s)' % repeatMode) return src = src[0] #replace extension on destination dst = sfile.removeextension(dst) + '.' + sfile.getextension(src) autoPlay = True repeatMode = False thumb = ICON exists = sfile.exists(dst) if exists: if (not REPEAT) and (not utils.DialogYesNo(GETTEXT(30099), GETTEXT(30100))): exists = False utils.delete(dst, APPLICATION) else: autoPlay = True repeatMode = GetRepeatMode() name, thumb = utils.GetTitleAndImage(dst) if not exists: autoPlay = False if REPEAT or not utils.DialogYesNo(GETTEXT(30085), GETTEXT(30086), noLabel=GETTEXT(30111), yesLabel=GETTEXT(30112)): autoPlay = True repeatMode = GetRepeatMode() if autoPlay: downloaded = 0 else: downloaded = utils.DoDownload(name, dst, src, image, orignalSrc) if downloaded > 0: #not successful if downloaded == 1:#failed NOT cancelled utils.DialogOK(name, utils.GETTEXT(30081)) return if autoPlay: src = 'AMAZON@' + src #download any related files?? AddToPlaylist(name, thumb, src, AMAZON_FILE, isFirst=True) xbmc.executebuiltin('PlayerControl(%s)' % repeatMode) xbmcgui.Window(10000).setProperty('LB_AUTOPLAY', 'True') APPLICATION.containerRefresh() else: utils.DialogOK(name, utils.GETTEXT(30082)) APPLICATION.containerRefresh()