def addMovies(contentList, strm_name='', strm_type='Other', provider="n.a"): movieList = [] listName = strm_name pagesDone = 0 file = '' filetype = '' j = len(contentList) * int(PAGINGMovies) / 100 if len(contentList) == 0: return contentList while pagesDone < int(PAGINGMovies): if not contentList[0] == "palyableSingleMedia": for detailInfo in contentList: file = detailInfo.get('file').replace( "\\\\", "\\") if detailInfo.get('file', None) is not None else None filetype = detailInfo.get('filetype', None) label = detailInfo.get('label').strip() if detailInfo.get( 'label', None) is not None else None try: if label and strm_name: label = stringUtils.cleanByDictReplacements(label) if HIDE_tile_in_OV == "true" and label.find( "[OV]") > -1: get_title_with_OV = False else: get_title_with_OV = True provider = getProvider(file) thisDialog.dialogeBG.update( j, ADDON_NAME + ": Getting Movies: ", " Video: " + label) if filetype is not None and filetype == 'file' and get_title_with_OV == True: m_path = stringUtils.getMovieStrmPath( strm_type, strm_name, label) m_title = stringUtils.cleanByDictReplacements( stringUtils.getStrmname(label)) movieList.append({ 'path': m_path, 'title': m_title, 'url': file, 'provider': provider }) j = j + len(contentList) * int(PAGINGMovies) / 100 except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror) except ValueError: print("No valid integer in line.") except:
def update(strm_name, url, media_type, thelist): plex_details = stringUtils.uni( jsonUtils.requestList("plugin://plugin.video.plexbmc", media_type)) for plex_detail in plex_details: plex_detail = stringUtils.removeHTMLTAGS(plex_detail) label = re.search('"label" *: *"(.*?)",', plex_detail) if label and strm_name.replace( '++RenamedTitle++', '') == stringUtils.cleanByDictReplacements( label.group(1)): serverurl = re.search('"file" *: *"(.*?)",', plex_detail).group(1) if url != serverurl: for entry in thelist: if entry.split("|")[1] == strm_name: newentry = '|'.join([ entry.split("|")[0], entry.split("|")[1].decode("utf-8"), serverurl ]) + '\n' thelist = stringUtils.replaceStringElem( thelist, entry, newentry) thefile = xbmc.translatePath( os.path.join(profile, 'MediaList.xml')) with open(thefile.decode("utf-8"), 'w') as output_file: for linje in thelist: if not linje.startswith('\n'): output_file.write( linje.strip().encode('utf-8') + '\n') else: output_file.write(linje.strip()) break url = serverurl return url
def delNotInMediaList(delList, thelist): for i in delList: try: path = completePath(STRM_LOC) + ( thelist[i]).strip().split('|')[0].format(i) itemPath = ( thelist[i].decode('utf-8')).strip().split('|')[1].replace( '++RenamedTitle++', '').format(i).format(i) print("remove folder: %s" % itemPath) shutil.rmtree(completePath(path) + stringUtils.cleanByDictReplacements(itemPath), ignore_errors=True) except OSError: print("Unable to remove folder: %s" % itemPath)
def delNotInMediaList(delList): for entry in delList: try: splits = entry.split('|') type = splits[0] isAudio = True if type.lower().find('audio') > -1 else False path = completePath(STRM_LOC) + type if isAudio and len(splits) > 3: path = completePath( path) + stringUtils.cleanByDictReplacements(splits[3]) itemPath = stringUtils.getStrmname(splits[1]) path = completePath( completePath(path) + stringUtils.cleanStrmFilesys(itemPath)) utils.addon_log("remove: %s" % path) xbmcvfs.rmdir(path, force=True) if isAudio: xbmc.executeJSONRPC( '{"jsonrpc": "2.0", "method": "AudioLibrary.Clean", "id": 1}' ) except OSError: print("Unable to remove: %s" % path)
def fillPluginItems(url, media_type='video', file_type=False, strm=False, strm_name='', strm_type='Other', showtitle='None'): initialize_DialogBG("Updating", "Getting content..") thisDialog.dialogeBG.update(0, ADDON_NAME + ": Getting: ", stringUtils.getStrmname(strm_name)) utils.addon_log('fillPluginItems') details = [] if url.find("playMode=play") == -1: if not file_type: details = jsonUtils.requestList(url, media_type).get('files', []) else: details = jsonUtils.requestItem(url, media_type).get('files', []) else: details.append("palyableSingleMedia") details.append(url) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None if strm_type.find('Cinema') != -1 or strm_type.find('YouTube') != -1 or strm_type.find('Movies') != -1: try: initialize_DialogBG("Movie", "Adding") movieList = addMovies(details, strm_name, strm_type) dbMovList = kodiDB.writeMovie(movieList) j = 100 / len(dbMovList) if len(dbMovList) > 0 else 1 # Write strms for all values in movieList for entry in dbMovList: thisDialog.dialogeBG.update(j, ADDON_NAME + ": Writing Movies: ", " Video: " + entry.get('title')) fileSys.writeSTRM(stringUtils.cleanStrms(entry.get('path')), stringUtils.cleanStrms(entry.get('title')) , "plugin://plugin.video.osmosix/?url=plugin&mode=10&mediaType=movie&id=" + str(entry.get('movieID')) + "|" + entry.get('title')) j = j + 100 / len(movieList) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print ("Unexpected error:"), sys.exc_info()[0] raise if strm_type.find('TV-Show') != -1 or strm_type.find('Shows-Collection') != -1: try: initialize_DialogBG("Adding TV-Shows", "working..") getTVShowFromList(details, strm_name, strm_type) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print ("Unexpected error:"), sys.exc_info()[0] raise if strm_type.find('Album') != -1 : try: initialize_DialogBG("Album", "Adding") addAlbum(details, strm_name, strm_type) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1])+ (". See your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print ("Unexpected error:"), sys.exc_info()[0] raise for detail in details: filetype = detail['filetype'] label = stringUtils.cleanLabels(detail['label']) file = detail['file'].replace("\\\\", "\\") strm_name = str(stringUtils.cleanByDictReplacements(strm_name.strip())) plot = stringUtils.cleanLabels(detail.get('plot','')) art = detail.get('art',{}) if addon.getSetting('Link_Type') == '0': link = sys.argv[0] + "?url=" +urllib.quote_plus(stringUtils.uni(file)) + "&mode=" + str(10) + "&name=" +urllib.quote_plus(stringUtils.uni(label)) + "&fanart=" + urllib.quote_plus(art.get('fanart','')) else: link = file if strm_type == 'Audio-Single': path = os.path.join('Singles', str(strm_name)) try: album = detail['album'].strip() artist = stringUtils.cleanByDictReplacements(", ".join(artist.strip() for artist in detailInfo['artist']) if isinstance(detailInfo['artist'], (list, tuple)) else detailInfo['artist'].strip()) title = detail['title'].strip() type = detail['type'].strip() filename = str(strm_name + ' - ' + label).strip() except: filename = str(strm_name + ' - ' + label).strip() if strm_type.find('Audio-Album') != -1: path = os.path.join(strm_type, strm_name) track = detail.get('track', 0) try: album = detail['album'].strip() artist = stringUtils.cleanByDictReplacements(", ".join(artist.strip() for artist in detailInfo['artist']) if isinstance(detailInfo['artist'], (list, tuple)) else detailInfo['artist'].strip()) title = stringUtils.cleanByDictReplacements(detail['title'].strip()) type = stringUtils.cleanByDictReplacements(detail['type'].strip()) filename = stringUtils.cleanByDictReplacements(label.strip()) except: filename = stringUtils.cleanByDictReplacements(label.strip()) if strm_type in ['Other']: path = os.path.join('Other', strm_name) filename = str(strm_name + ' - ' + label) if filetype == 'file': if strm: if strm_type.find('Audio-Albums') != -1: kodiDB.musicDatabase(album, artist, label, path, link, track) fileSys.writeSTRM(stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")) , link) else: guiTools.addLink(label, file, 10, art, plot, '', '', '', None, '', total=len(details)) else: if strm: fillPluginItems(file, media_type, file_type, strm, label, strm_type) else: guiTools.addDir(label, file, 101, art, plot, '', '', '')
def addAlbum(contentList, strm_name='', strm_type='Other', PAGINGalbums="1"): albumList = [] dirList = [] pagesDone = 0 file = '' filetype = '' j = 100 / (len(contentList) * int(PAGINGalbums)) if len(contentList) > 0 else 1 if len(contentList) == 0: return contentList while pagesDone < int(PAGINGalbums): if not contentList[0] == "palyableSingleMedia": artThumb = contentList[0].get('art', {}) aThumb = urlUtils.stripUnquoteURL(artThumb.get('thumb', '')) for index, detailInfo in enumerate(contentList): art = detailInfo.get('art',{}) file = detailInfo['file'].replace("\\\\", "\\").encode('utf-8') filetype = detailInfo['filetype'] label = stringUtils.cleanLabels(detailInfo['label'].strip()) thumb = art.get('thumb','') fanart = art.get('fanart','') description = detailInfo.get('description', '') track = detailInfo.get('track', 0) if detailInfo.get('track', 0) > 0 else index + 1 duration = detailInfo.get('duration', 0) if duration == 0: duration = 200 try: if filetype == 'directory': dirList.append(jsonUtils.requestList(file, 'music').get('files', [])) continue if addon.getSetting('Link_Type') == '0': link = sys.argv[0] + "?url=" + urllib.quote_plus(file) + "&mode=" + str(10) + "&name=" + urllib.quote_plus(label) + "&fanart=" + urllib.quote_plus(fanart) else: link = file try: album = detailInfo['album'].strip() artist = stringUtils.cleanByDictReplacements(", ".join(artist.strip() for artist in detailInfo['artist']) if isinstance(detailInfo['artist'], (list, tuple)) else detailInfo['artist'].strip()) artistList = [] #Check for Various Artists for i, sArtist in enumerate(contentList): artistList.append(sArtist.get('artist')) if len(artistList) > 1: try: if artistList[0] != artistList[1] and artistList[1] != artistList[2]: artist = 'Various Artists' except IndexError: if artistList[0] != artistList[1]: artist = 'Various Artists' title = stringUtils.cleanByDictReplacements(detailInfo['title'].strip()) type = stringUtils.cleanByDictReplacements(detailInfo['type'].strip()) filename = stringUtils.cleanByDictReplacements(label.strip()) except: filename = stringUtils.cleanByDictReplacements(label.strip()) pass thisDialog.dialogeBG.update(j, ADDON_NAME + ": Writing File: ", " Title: " + label) path = os.path.join(strm_type, artist, strm_name.replace('++RenamedTitle++', '')) if album and artist and label and path and link and track: albumList.append([path, label, link, album, artist, track, duration, thumb]) j = j + 100 / (len(contentList) * int(PAGINGalbums)) except IOError as (errno, strerror): print ("I/O error({0}): {1}").format(errno, strerror) except ValueError: print ("No valid integer in line.") except:
print ("Unexpected error:"), sys.exc_info()[0] raise pagesDone += 1 contentList = [] if pagesDone < int(PAGINGalbums) and len(dirList) > 0: contentList = [item for sublist in dirList for item in sublist] dirList = [] if False: try: urlUtils.downloadThumb(aThumb, album, os.path.join(STRM_LOC, strm_type, artist)) except: pass else: albumList.append([os.path.join(strm_type, stringUtils.getStrmname(strm_name) , label), stringUtils.cleanByDictReplacements(label), link]) pagesDone = int(PAGINGalbums) try: # Write strms for all values in albumList thelist = fileSys.readMediaList(purge=False) items = [] for entry in thelist: splits = entry.strip().split('|') splitsstrm = splits[0] splitsname = splits[1] if splitsstrm.find('Album') != -1 and splitsname.find(strm_name) != -1: url = splits[2] cType = splits[0] albumartist = artist fileSys.rewriteMediaList(url, strm_name, albumartist, cType)
if pagesDone < int(PAGINGalbums) and len(dirList) > 0: contentList = [item for sublist in dirList for item in sublist] dirList = [] if False: try: urlUtils.downloadThumb( aThumb, album, os.path.join(STRM_LOC, strm_type, artist)) except: pass else: albumList.append([ os.path.join(strm_type, stringUtils.getStrmname(strm_name), label), stringUtils.cleanByDictReplacements(label), link ]) pagesDone = int(PAGINGalbums) try: # Write strms for all values in albumList thelist = fileSys.readMediaList(purge=False) for entry in thelist: splits = entry.strip().split('|') splitsstrm = splits[0] splitsname = splits[1] if splitsstrm.find('Album') != -1 and splitsname.find( strm_name) != -1: url = splits[2] cType = splits[0] albumartist = artist
def getEpisodes(episodesListRaw, strm_name, strm_type, j=0, pagesDone=0): episodesList = [] typeChange = [] try: if type(episodesListRaw) is unicode: typeChange.append(episodesListRaw) episodesListRaw = typeChange for detailInfo in episodesListRaw: utils.addon_log("detailInfo: " + detailInfo) detailInfo = stringUtils.removeHTMLTAGS(detailInfo) files = re.search('"file" *: *"(.*?)",', detailInfo) filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo) labels = re.search('"label" *: *"(.*?)",', detailInfo) thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo) fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo) descriptions = re.search('"description" *: *"(.*?)",', detailInfo) episodes = re.search('"episode" *: *(.*?),', detailInfo) seasons = re.search('"season" *: *(.*?),', detailInfo) showtitles = re.search('"showtitle" *: *"(.*?)",', detailInfo) provGeneral = re.search( '%s(.*)' "\\/\\?" '' % (r"plugin://plugin.video."), detailInfo) provXST = re.search('%s(.*)' "\&function" '' % (r"site="), detailInfo) listName = strm_name if filetypes: if provGeneral: listName = provGeneral.group(1) if provXST: listName = listName + ": " + provXST.group(1) if filetypes.group(1) == 'directory': contentList = stringUtils.uni( jsonUtils.requestList(files.group(1), 'video')) continue if showtitles and seasons and episodes: filetype = filetypes.group(1) label = (stringUtils.cleanLabels(labels.group(1))) file = (files.group(1).replace("\\\\", "\\")) strm_name = str( stringUtils.cleanByDictReplacements(strm_name.strip())) showtitle = stringUtils.cleanByDictReplacements( (showtitles.group(1))) season = stringUtils.cleanByDictReplacements( seasons.group(1).replace("-", "")) episode = stringUtils.cleanByDictReplacements( episodes.group(1).replace("-", "")) episodesHDF = re.search('Folge.(\\d+)&', file) if file.find("hdfilme") != "-1" and episodesHDF: episode = re.search('Folge.(\\d+)&', file).group(1) if not descriptions: description = '' else: description = stringUtils.cleanLabels( descriptions.group(1)) if fanarts: fanart = fanarts.group(1) else: fanart = '' if strm_name.find("++RenamedTitle++") != -1: showtitle = strm_name.strip().replace( '++RenamedTitle++', '') if showtitle != "" and strm_type != "": episodesList.append([ strm_type, str('s' + season), str('e' + episode), file, stringUtils.cleanByDictReplacements( showtitle.strip()), listName ]) except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror)
def addMovies(contentList, strm_name='', strm_type='Other', provider="n.a"): movieList = [] listName = strm_name pagesDone = 0 file = '' filetype = '' j = len(contentList) * int(PAGINGMovies) / 100 while pagesDone < int(PAGINGMovies): if not contentList[0] == "palyableSingleMedia": for detailInfo in contentList: detailInfo = stringUtils.removeHTMLTAGS(detailInfo) files = re.search('"file" *: *"(.*?)",', detailInfo) filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo) labels = re.search('"label" *: *"(.*?)",', detailInfo) thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo) fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo) descriptions = re.search('"description" *: *"(.*?)",', detailInfo) provGeneral = re.search( '%s(.*)' "\\/\\?" '' % (r"plugin://plugin.video."), detailInfo) provXST = re.search('%s(.*)' "\&function" '' % (r"site="), detailInfo) try: if filetypes and labels and files: filetype = filetypes.group(1) label = (stringUtils.cleanLabels(labels.group(1))) file = (files.group(1).replace("\\\\", "\\")) if provGeneral: listName = provGeneral.group(1) if provXST: listName = listName + ": " + provXST.group(1) if fanarts: fanart = fanarts.group(1) else: fanart = '' link = file if label and strm_name: label = str( stringUtils.cleanByDictReplacements( label.strip())) thisDialog.dialogeBG.update( j, ADDON_NAME + ": Gettin Movies: ", " Video: " + label) if filetype == 'file': movieList.append([ os.path.join( strm_type, strm_name.strip().replace( '++RenamedTitle++', '')), str( stringUtils.cleanByDictReplacements( label.strip())), link, listName ]) j = j + len(contentList) * int(PAGINGMovies) / 100 except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror) except ValueError: print("No valid integer in line.") except:
def addAlbum(contentList, strm_name='', strm_type='Other', PAGINGalbums="1"): albumList = [] pagesDone = 0 file = '' j = 100 / (len(contentList) * int(PAGINGalbums)) while pagesDone < int(PAGINGalbums): if not contentList[0] == "palyableSingleMedia": albumThumbnails = re.search('"thumbnail" *: *"(.*?)",', str(contentList)) if albumThumbnails: aThumb = urlUtils.stripUnquoteURL(albumThumbnails.group(1)) for detailInfo in contentList: detailInfo = stringUtils.removeHTMLTAGS(detailInfo) files = re.search('"file" *: *"(.*?)",', detailInfo) filetypes = re.search('"filetype" *: *"(.*?)",', detailInfo) labels = re.search('"label" *: *"(.*?)",', detailInfo) thumbnails = re.search('"thumbnail" *: *"(.*?)",', detailInfo) fanarts = re.search('"fanart" *: *"(.*?)",', detailInfo) descriptions = re.search('"description" *: *"(.*?)",', detailInfo) tracks = re.search('"track" *: *(.*?),', detailInfo) durations = re.search('"duration" *: *"(.*?)",', detailInfo) try: if filetypes and labels and files: filetype = filetypes.group(1) label = (stringUtils.cleanLabels(labels.group(1))) file = (files.group(1).replace("\\\\", "\\")) if fanarts: fanart = fanarts.group(1) else: fanart = '' if addon.getSetting('Link_Type') == '0': link = sys.argv[0] + "?url=" + urllib.quote_plus( file) + "&mode=" + str( 10) + "&name=" + urllib.quote_plus( label ) + "&fanart=" + urllib.quote_plus(fanart) else: link = file if thumbnails: thumb = urlUtils.stripUnquoteURL( thumbnails.group(1)) else: thumb = "" if label and strm_name: label = str( stringUtils.cleanByDictReplacements( label.strip())) if tracks: track = tracks.group(1) try: album = re.search('"album" *: *"(.*?)",', detailInfo).group(1).strip() try: artist = stringUtils.cleanByDictReplacements( re.search('"artist" *: *"(.*?)",', detailInfo).group(1).strip()) except: artist = stringUtils.cleanByDictReplacements( re.search('"artist"*:*."(.*?)".,', detailInfo).group(1).strip()) pass titl = stringUtils.cleanByDictReplacements( re.search('"title" *: *(.*?),', detailInfo).group(1).strip()) types = stringUtils.cleanByDictReplacements( re.search('"type" *: *(.*?),', detailInfo).group(1).strip()) filename = stringUtils.cleanByDictReplacements( str(label).strip()) except: filename = stringUtils.cleanByDictReplacements( str(label).strip()) pass thisDialog.dialogeBG.update( j, ADDON_NAME + ": Writing File: ", " Title: " + label) path = os.path.join(strm_type, artist.strip(), album.strip()) if album and artist and label and path and link and track: albumList.append([ path, label.strip(), link, album, artist, track, thumb ]) j = j + 100 / (len(contentList) * int(PAGINGalbums)) except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror) except ValueError: print("No valid integer in line.") except:
def fillPluginItems(url, media_type='video', file_type=False, strm=False, strm_name='', strm_type='Other', showtitle='None'): initialize_DialogBG("Updating", "Getting content..") thisDialog.dialogeBG.update(0, ADDON_NAME + ": Getting: ", strm_name.replace('++RenamedTitle++', '')) utils.addon_log('fillPluginItems') detail = [] if url.find("playMode=play") == -1: if not file_type: detail = stringUtils.uni(jsonUtils.requestList(url, media_type)) listLength = len(detail) else: detail = stringUtils.uni(jsonUtils.requestItem(url, media_type)) else: detail.append("palyableSingleMedia") detail.append(url) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None if strm_type.find('Cinema') != -1 or strm_type.find( 'YouTube') != -1 or strm_type.find('Movies') != -1: try: initialize_DialogBG("Movie", "Adding") movieList = addMovies(detail, strm_name, strm_type) dbMovList = kodiDB.writeMovie(movieList) j = 100 / len(dbMovList) if len(dbMovList) > 0 else 1 # Write strms for all values in movieList for i in dbMovList: # path,name,url(+name) thisDialog.dialogeBG.update(j, ADDON_NAME + ": Writing Movies: ", " Video: " + i[1].rstrip(".")) #fileSys.writeSTRM(stringUtils.cleanStrms((i[0].rstrip("."))), stringUtils.cleanStrms(i[1].rstrip(".")) , i[2] + "|" + i[1]) # plugin://plugin.video.osmosis/?url=plugin&mode=10&mediaType=show&episode= fileSys.writeSTRM( stringUtils.cleanStrms(i[0].rstrip(".")), stringUtils.cleanStrms((i[1].rstrip("."))), "plugin://plugin.video.osmosis/?url=plugin&mode=10&mediaType=movie&id=" + str(i[2]) + "|" + i[1]) j = j + 100 / len(movieList) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) + (". Se your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print("Unexpected error:"), sys.exc_info()[0] raise if strm_type.find('OLDTV-Show') != -1: try: initialize_DialogBG("TV-Show", "Adding") tvShowList = addTVShows(detail, strm_name, strm_type) #dbShows = kodiDB.writeShow(tvShowList) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) + (". Se your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print("Unexpected error:"), sys.exc_info()[0] raise if strm_type.find('TV-Show') != -1 or strm_type.find( 'Shows-Collection') != -1: try: initialize_DialogBG("Adding TV-Shows", "working..") getTVShowFromList(detail, strm_name, strm_type) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) + (". Se your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print("Unexpected error:"), sys.exc_info()[0] raise if strm_type.find('Album') != -1: try: initialize_DialogBG("Album", "Adding") addAlbum(detail, strm_name, strm_type) thisDialog.dialogeBG.close() thisDialog.dialogeBG = None return except: thisDialog.dialogeBG.close() thisDialog.dialogeBG = None guiTools.infoDialog("Unexpected error: " + str(sys.exc_info()[1]) + (". Se your Kodi.log!")) utils.addon_log(("Unexpected error: ") + str(sys.exc_info()[1])) print("Unexpected error:"), sys.exc_info()[0] raise # if strm_type.find('YouTube') != -1: # # video = pafy.new(url) # bestaudio = video.getbestaudio() # bestaudio.bitrate #get bit rate # bestaudio.extension #extension of audio fileurl # # bestaudio.url #get url # # #download if you want # bestaudio.download() # return for f in detail: files = re.search('"file" *: *"(.*?)",', f) filetypes = re.search('"filetype" *: *"(.*?)",', f) labels = re.search('"label" *: *"(.*?)",', f) thumbnails = re.search('"thumbnail" *: *"(.*?)",', f) fanarts = re.search('"fanart" *: *"(.*?)",', f) descriptions = re.search('"description" *: *"(.*?)",', f) tracks = re.search('"track" *: *(.*?),', f) durations = re.search('"duration" *: *"(.*?)",', f) if filetypes and labels and files: filetype = filetypes.group(1) label = (stringUtils.cleanLabels(labels.group(1))) file = (files.group(1).replace("\\\\", "\\")) strm_name = str( stringUtils.cleanByDictReplacements(strm_name.strip())) if not descriptions: description = '' else: description = stringUtils.cleanLabels(descriptions.group(1)) thumbnail = thumbnails.group( 1) #stringUtils.removeNonAscii(thumbnails.group(1)) fanart = fanarts.group( 1) #stringUtils.removeNonAscii(fanarts.group(1)) if addon.getSetting('Link_Type') == '0': link = sys.argv[0] + "?url=" + urllib.quote_plus( file) + "&mode=" + str(10) + "&name=" + urllib.quote_plus( label) + "&fanart=" + urllib.quote_plus(fanart) else: link = file if strm_type in ['Audio-Single']: path = os.path.join('Singles', str(strm_name)) try: album = re.search('"album" *: *"(.*?)",', f).group(1).strip() try: artist = re.search('"artist" *: *"(.*?)",', f).group(1).strip() except: artist = re.search('"artist"*:*."(.*?)".,', f).group(1).strip() pass titl = re.search('"title" *: *(.*?),', f).group(1).strip() types = re.search('"type" *: *(.*?),', f).group(1).strip() filename = str(strm_name + ' - ' + label).strip() except: filename = str(strm_name + ' - ' + label).strip() if strm_type.find('Audio-Album') != -1: path = os.path.join(strm_type, strm_name) if tracks: track = tracks.group(1) try: album = re.search('"album" *: *"(.*?)",', f).group(1).strip() try: artist = stringUtils.cleanByDictReplacements( re.search('"artist" *: *"(.*?)",', f).group(1).strip()) except: artist = stringUtils.cleanByDictReplacements( re.search('"artist"*:*."(.*?)".,', f).group(1).strip()) pass titl = stringUtils.cleanByDictReplacements( re.search('"title" *: *(.*?),', f).group(1).strip()) types = stringUtils.cleanByDictReplacements( re.search('"type" *: *(.*?),', f).group(1).strip()) filename = stringUtils.cleanByDictReplacements( str(label).strip()) except: filename = stringUtils.cleanByDictReplacements( str(label).strip()) if strm_type in ['Other']: path = os.path.join('Other', strm_name) filename = str(strm_name + ' - ' + label) if filetype == 'file': if strm: if strm_type.find('Audio-Albums') != -1: utils.addon_log(str(path + ' ' + filename)) #utils.createSongNFO(stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")), strm_ty=strm_type, artists=artist,albums=album , titls=titl, typese=types) kodiDB.musicDatabase(album, artist, label, path, link, track) # xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(path + " - " + filename, " writing...",5000,"")) fileSys.writeSTRM( stringUtils.cleanStrms((path.rstrip("."))), stringUtils.cleanStrms(filename.rstrip(".")), link) else: guiTools.addLink(label, file, 10, thumbnail, fanart, description, '', '', '', None, '', total=len(detail)) # xbmc.executebuiltin("Container.SetViewMode(500)") else: if strm: fillPluginItems(file, media_type, file_type, strm, label, strm_type) else: guiTools.addDir(label, file, 101, thumbnail, fanart, description, '', '', '')
jsonUtils.requestList(file, 'video')) else: pagesDone = int(PAGINGalbums) if False: try: urlUtils.downloadThumb( aThumb, album, os.path.join(STRM_LOC, strm_type, artist)) except: pass else: albumList.append([ os.path.join(strm_type, strm_name.strip().replace('++RenamedTitle++', ''), label.strip()), str(stringUtils.cleanByDictReplacements(label.strip())), link ]) pagesDone = int(PAGINGalbums) try: # Write strms for all values in albumList for i in albumList: fileSys.writeSTRM(path, stringUtils.cleanStrms(i[1].rstrip(".")), i[2] + "|" + i[1]) kodiDB.musicDatabase(i[3], i[4], i[1], i[0], i[2], i[5], aThumb) thisDialog.dialogeBG.close() except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror) except ValueError: print("No valid integer in line.") except:
if pagesDone < int(PAGINGalbums) and len(dirList) > 0: contentList = [item for sublist in dirList for item in sublist] dirList = [] if False: try: urlUtils.downloadThumb( aThumb, album, os.path.join(STRM_LOC, strm_type, artist)) except: pass else: albumList.append([ os.path.join(strm_type, stringUtils.getStrmname(strm_name), label), stringUtils.cleanByDictReplacements(label), link ]) pagesDone = int(PAGINGalbums) try: # Write strms for all values in albumList thelist = fileSys.readMediaList(purge=False) items = [] for entry in thelist: splits = entry.strip().split('|') splitsstrm = splits[0] splitsname = splits[1] if splitsstrm.find('Album') != -1 and splitsname.find( strm_name) != -1: url = splits[2] cType = splits[0]