def addMovies(contentList, strm_name='', strm_type='Other'): movieList = [] pagesDone = 0 file = '' j = 100 / (len(contentList) * int(PAGINGMovies)) 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) 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 label and strm_name: label = str( utils.multiple_reSub(label.strip(), dictReplacements)) thisDialog.dialogeBG.update( j, ADDON_NAME + ": Writing File: ", " Video: " + label) movieList.append([ os.path.join(strm_type), str( utils.multiple_reSub( label.strip(), dictReplacements)), link ]) j = j + 100 / (len(contentList) * int(PAGINGMovies)) except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror) except ValueError: print("No valid integer in line.") except:
def cleanLabels(text, format=''): text = uni(text) dictresub = { '\[COLOR (.+?)\]': '', '\[/COLOR\]': '', '\[COLOR=(.+?)\]': '', '\[color (.+?)\]': '', '\[/color\]': '', '\[Color=(.+?)\]': '', '\[/Color\]': '' } ascciReplacements = { '\xc3\x84': 'Ae', '\xc3\xa4': 'ae', '\xc3\x96': 'Oe', '\xc3\xb6': 'oe', '\xc3\x9c': 'Ue', 'xc3\xbc': 'ue', '\xc3\x9f': 'ss' } replacements = ((u"[]", u''), (u"[UPPERCASE]", u''), (u"[/UPPERCASE]", u''), (u"[LOWERCASE]", u''), (u"[/LOWERCASE]", u''), (u"(de)", u" german"), (u"(en)", u" english"), (u"(TVshow)", u""), (u"[B]", u''), (u"[/B]", u''), (u"[I]", u''), (u"[/I]", u''), (u'[D]', u''), (u'[F]', u''), (u"[CR]", u''), (u"[HD]", u''), (u"()", u''), (u"[CC]", u''), (u"[Cc]", u''), (u"[Favorite]", u""), (u"[DRM]", u""), (u'(cc).', u''), (u'(n)', u''), (u"(SUB)", u''), (u"(DUB)", u''), (u'(repeat)', u''), (u"(English Subtitled)", u""), (u"*", u""), (u"\n", u""), (u"\r", u""), (u"\t", u""), (u"\ ", u''), (u"/ ", u''), (u"\\", u'/'), (u"//", u'/'), (u'plugin.video.', u''), (u'plugin.audio.', u'')) text = utils.multiple_reSub(text.rstrip(), ascciReplacements) text = utils.multiple_reSub(text, dictresub) text = utils.multiple_replace(text, *replacements) text = re.sub('[\/:*?<>|!@#$/:]', '', text) if format == 'title': text = text.title().replace("'S", "'s") elif format == 'upper': text = text.upper() elif format == 'lower': text = text.lower() else: text = text text = uni(text.strip()) return text
def cleanByDictReplacements(string): dictReplacements = {"'\(\\d+\)'" : '', '()' : '', 'Kinofilme' : '', ' ' : ' ','\(de\)':'','\(en\)':'', "\(TVshow\)":"",'Movies' : '', 'Filme' : '', 'Movie' : '', "'.'" : ' ', '\(\)' : '', ":": ' ','"?"': '','"':''} return utils.multiple_reSub(string, dictReplacements)
def delNotInMediaList(delList, thelist, replacements): for i in delList: try: path = STRM_LOC + "\\" + (thelist[i]).strip().split('|')[0].format(i) itemPath = (thelist[i].decode('utf-8')).strip().split('|')[1].format(i) print ("remove folder: %s" % itemPath) shutil.rmtree(path + "\\" + utils.multiple_reSub(itemPath, replacements) , ignore_errors=True) except OSError: print ("Unable to remove folder: %s" % itemPath)
def cleanLabels(text, formater=''): text = uni(text) dictresub = { '\[COLOR (.+?)\]': '', '\[/COLOR\]': '', '\[COLOR=(.+?)\]': '', '\[color (.+?)\]': '', '\[/color\]': '', '\[Color=(.+?)\]': '', '\[/Color\]': '' } replacements = ((u"[]", u''), (u"[UPPERCASE]", u''), (u"[/UPPERCASE]", u''), (u"[LOWERCASE]", u''), (u"[/LOWERCASE]", u''), (u"[B]", u''), (u"[/B]", u''), (u"[I]", u''), (u"[/I]", u''), (u'[D]', u''), (u'[F]', u''), (u"[CR]", u''), (u"[HD]", u''), (u"()", u''), (u"[CC]", u''), (u"[Cc]", u''), (u"[Favorite]", u""), (u"[DRM]", u""), (u'(cc).', u''), (u'(n)', u''), (u"(SUB)", u''), (u"(DUB)", u''), (u'(repeat)', u''), (u"(English Subtitled)", u""), (u"*", u""), (u"\n", u""), (u"\r", u""), (u"\t", u""), (u"\ ", u''), (u"/ ", u''), (u"\\", u'/'), (u"//", u'/'), (u'plugin.video.', u''), (u':', u''), (u'plugin.audio.', u'')) text = utils.multiple_reSub(text, dictresub) text = utils.multiple_replace(text, *replacements) text = re.sub('[\/:*?<>|!@#$/:]', '', text) text = re.sub('\(.\d*\)', "", text) if formater == 'title': text = text.title().replace("'S", "'s") elif formater == 'upper': text = text.upper() elif formater == 'lower': text = text.lower() else: text = text text = uni(text.strip()) return text
def cleanLabels(text, formater=''): text = uni(text) dictresub = {'\[COLOR (.+?)\]' : '', '\[/COLOR\]' : '', '\[COLOR=(.+?)\]' : '', '\[color (.+?)\]': '', '\[/color\]': '', '\[Color=(.+?)\]': '', '\[/Color\]': ''} replacements = ((u"[]", u''), (u"[UPPERCASE]", u''), (u"[/UPPERCASE]", u''), (u"[LOWERCASE]", u''), (u"[/LOWERCASE]", u''), (u"[B]", u''), (u"[/B]", u''), (u"[I]", u''), (u"[/I]", u''), (u'[D]', u''), (u'[F]', u''), (u'MULTi BluRay x264-PopHD', u''), (u'WwW.Zone-Telechargement.Ws', u''), (u"[CR]", u''), (u"[HD]", u''), (u"Uptobox", u''), (u"[]", u''), (u"540p", u''),(u"BluRayx264-LOST", u''), (u"[CC]", u''), (u"1080p", u''), (u"720p", u''), (u"h264", u''), (u"AC3-6ch", u''), (u"AC3-6ch", u''), (u"&133", u''), (u"[Cc]", u''), (u"[Favorite]", u""), (u".MULTi.TRUEFRENCH.1080p.BluRay.DTS.x264-MeToO-Shanks@Zone-Telechargement", u""), (u"[DRM]", u""), (u'(cc).', u''), (u'(n)', u''), (u"(SUB)", u''), (u"(DUB)", u''), (u'(repeat)', u''), (u"(English Subtitled)", u""), (u"*", u""), (u"\n", u""), (u"\r", u""), (u".", u" "), (u"\t", u""), (u"\ ", u''), (u"/ ", u''), (u"\\", u'/'), (u"//", u'/'), (u'plugin.video.', u''), (u'mkv', u''), (u'avi', u''), (u'1080p.', u''), (u':', u''), (u'FRENCH', u''), (u'MULTI', u''), (u'plugin.audio.', u'')) text = utils.multiple_reSub(text, dictresub) text = utils.multiple_replace(text, *replacements) text = re.sub('[\/:*?<>|!@#$/:]', '', text) #text = re.sub('\(.\d*\)',"", text) if formater == 'title': text = text.title().replace("'S", "'s") elif formater == 'upper': text = text.upper() elif formater == 'lower': text = text.lower() else: text = text text = uni(text.strip()) return text
def cleanLabels(text, formater=''): text = uni(text) dictresub = {'\[COLOR (.+?)\]' : '', '\[/COLOR\]' : '', '\[COLOR=(.+?)\]' : '', '\[color (.+?)\]': '', '\[/color\]': '', '\[Color=(.+?)\]': '', '\[/Color\]': ''} replacements = ((u"[]", u''), (u"[UPPERCASE]", u''), (u"[/UPPERCASE]", u''), (u"[LOWERCASE]", u''), (u"[/LOWERCASE]", u''), (u"[B]", u''), (u"[/B]", u''), (u"[I]", u''), (u"[/I]", u''), (u'[D]', u''), (u'[F]', u''), (u"[CR]", u''), (u"[HD]", u''), (u"()", u''), (u"[CC]", u''), (u"[Cc]", u''), (u"[Favorite]", u""), (u"[DRM]", u""), (u'(cc).', u''), (u'(n)', u''), (u"(SUB)", u''), (u"(DUB)", u''), (u'(repeat)', u''), (u"(English Subtitled)", u""), (u"*", u""), (u"\n", u""), (u"\r", u""), (u"\t", u""), (u"\ ", u''), (u"/ ", u''), (u"\\", u'/'), (u"//", u'/'), (u'plugin.video.', u''),(u':', u''), (u'plugin.audio.', u'')) text = utils.multiple_reSub(text, dictresub) text = utils.multiple_replace(text, *replacements) text = re.sub('[\/:*?<>|!@#$/:]', '', text) if formater == 'title': text = text.title().replace("'S", "'s") elif formater == 'upper': text = text.upper() elif formater == 'lower': text = text.lower() else: text = text text = uni(text.strip()) return text
def cleanLabels(text, formater=''): dictresub = { '\[COLOR (.+?)\]': '', '\[/COLOR\]': '', '\[COLOR=(.+?)\]': '', '\[color (.+?)\]': '', '\[/color\]': '', '\[Color=(.+?)\]': '', '\[/Color\]': '' } replacements = (('[]', ''), ('[UPPERCASE]', ''), ('[/UPPERCASE]', ''), ('[LOWERCASE]', ''), ('[/LOWERCASE]', ''), ('[B]', ''), ('[/B]', ''), ('[I]', ''), ('[/I]', ''), ('[D]', ''), ('[F]', ''), ('[CR]', ''), ('[HD]', ''), ('()', ''), ('[CC]', ''), ('[Cc]', ''), ('[Favorite]', ''), ('[DRM]', ''), ('(cc).', ''), ('(n)', ''), ('(SUB)', ''), ('(DUB)', ''), ('(repeat)', ''), ('(English Subtitled)', ''), ('*', ''), ('\n', ''), ('\r', ''), ('\t', ''), ('\ ', ''), ('/ ', ''), ('\\', '/'), ('//', '/'), ('plugin.video.', ''), ('plugin.audio.', '')) text = utils.multiple_reSub(text, dictresub) text = utils.multiple_replace(text, *replacements) text = cleanStrmFilesys(text) text = re.sub('\(.\d*\)', '', text) if formater == 'title': text = text.title().replace('\'S', '\'s') elif formater == 'upper': text = text.upper() elif formater == 'lower': text = text.lower() else: text = text return text.strip()
def getEpisodes(episodesListRaw, strm_name, strm_type, j=0): episodesList = [] typeChange = [] try: if type(episodesListRaw) is unicode: typeChange.append(episodesListRaw) episodesListRaw = typeChange for detailInfo in episodesListRaw: 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) if filetypes: 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( utils.multiple_reSub(strm_name.strip(), dictReplacements)) showtitle = utils.multiple_reSub((showtitles.group(1)), dictReplacements) season = (utils.multiple_reSub( (seasons.group(1)).replace("-", ""), dictReplacements)) episode = (utils.multiple_reSub( (episodes.group(1)).replace("-", ""), dictReplacements)) 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 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_name.find("++RenamedTitle++") != -1: showtitle = strm_name.strip().replace( '++RenamedTitle++', '') if showtitle != "" and strm_type != "": episodesList.append([ os.path.join( xbmc.translatePath(strm_type + "//" + (utils.multiple_reSub( showtitle.strip(), dictReplacements)))), str('s' + season), str('e' + episode), link ]) except IOError as (errno, strerror): print("I/O error({0}): {1}").format(errno, strerror)
def findEpisodeByName(show_data, episodeSeason, episodeNr, episodeName, lang, silent=False, fallback_en=False): utils.addon_log( 'tvdb findEpisodeByName: show_data = {0}'.format(show_data)) showid = show_data.get('id') showname = show_data.get('seriesName') utils.addon_log_notice( 'tvdb findEpisodeByName: \'{0}\'; showname = \'{1}\', showid = {2}, lang = {3}' .format(episodeName, showname, showid, lang)) episode_data = getEpisodeFromCache(episodeSeason, episodeName, showid) if episode_data and episode_data.get( 'user_entry') == True and CONFIRM_USER_ENTRIES == 'true': if silent == False and fallback_en == False: confirmed = xbmcgui.Dialog().yesno( 'Confirm user entry for {0} is correct?'.format(showname), 'S{0:02d}E{1:02d} - {2}'.format(episodeSeason, episodeNr, episodeName), 'User Entry: S{0:02d}E{1:02d} - {2}'.format( episode_data.get('season'), episode_data.get('episode'), episode_data.get('episodeName', None)), autoclose=dialog_autoclose_time * 1000) if confirmed == False: episode_data = None else: episode_data = None if episode_data is None: ratio_max = 0 ratio_max2 = 100 ratio_max_season = -1 ratio_max_episode = -1 episodeListData = [] episodeListDialog = [] episodecount = 0 episodecountcurrentseason = 0 preselected = None json_data = cache.getTvdbDataCache().cacheFunction( getEpisodeDataFromTVDB, showid, lang) json_data = sorted( json_data, key=lambda x: (x['airedSeason'] == 0, x['airedSeason'] != episodeSeason or x[ 'airedEpisodeNumber'] != episodeNr, x['airedSeason'] != episodeSeason, x['airedSeason'], x['airedEpisodeNumber'])) dictresubList = [] regex_match_start = '([ \.,:;\(]+|^)' regex_match_end = '(?=[ \.,:;\)]+|$)' dictresubList.append({ ' *(?:-|\(|:)* *(?:[tT]eil|[pP]art|[pP]t\.) (\d+|\w+)\)*': r' (\g<1>)', ' *(?:-|\(|:)* *(?:[tT]eil 1 und 2|[pP]art[s]* 1 (&|and) 2)': ' (1)', }) dictresubList.append({ ' *(?:-|\(|:)* *(?:[tT]eil|[pP]art|[pP]t\.) (\d+|\w+)\)*': r' (\g<1>)', ' *(?:-|\(|:)* *(?:[tT]eil 1 und 2|[pP]art[s]* 1 (&|and) 2)': ' (1)', '[\s:;\.]\([\w\d\. ]*\)[\s:;\.]': ' ', }) dictresubList.append({ ' *(?:-|\(|:)* *(?:[tT]eil|[pP]art|[pP]t\.) (\d+|\w+)\)*': r' (\g<1>)', ' *(?:-|\(|:)* *(?:[tT]eil 1 und 2|[pP]art[s]* 1 (&|and) 2)': ' (1)', '[\s:;\.]\([\w\d\. ]*\)$': ' ', }) dictresubList.append({ ' *(?:-|\(|:)* *(?:[tT]eil|[pP]art|[pP]t\.) (\d+|\w+)\)*': r' (\g<1>)', ' *(?:-|\(|:)* *(?:[tT]eil 1 und 2|[pP]art[s]* 1 (&|and) 2)': ' (1)', '[\w\s\']{8,}\Z[:;] ([\w\s\']{8,}\Z)': '\g<1>', }) dictresubList.append({ '[pP]art [oO]ne': 'Part (1)', '[pP]art [tT]wo': 'Part (2)', }) dictresubList.append({ '[pP]art [oO]ne': '(1)', '[pP]art [tT]wo': '(2)', }) dictresubList.append({ '[pP]art 1': 'part one', '[pP]art 2': 'part two', }) dictresubList.append({ '{0}[eE]ins{1}'.format(regex_match_start, regex_match_end): r'\g<1>1', '{0}[zW]wei{1}'.format(regex_match_start, regex_match_end): r'\g<1>2', '{0}[dD]drei{1}'.format(regex_match_start, regex_match_end): r'\g<1>3', }) dictresubList.append({ '{0}[oO]ne{1}'.format(regex_match_start, regex_match_end): '\g<1>1', '{0}[tT]wo{1}'.format(regex_match_start, regex_match_end): '\g<1>2', '{0}[tT]hree{1}'.format(regex_match_start, regex_match_end): '\g<1>3', }) dictresubList.append({ '{0}1{1}'.format(regex_match_start, regex_match_end): r'\g<1>eins', '{0}2{1}'.format(regex_match_start, regex_match_end): r'\g<1>zwei', '{0}3{1}'.format(regex_match_start, regex_match_end): r'\g<1>drei', }) dictresubList.append({ '{0}1{1}'.format(regex_match_start, regex_match_end): r'\g<1>one', '{0}2{1}'.format(regex_match_start, regex_match_end): r'\g<1>two', '{0}3{1}'.format(regex_match_start, regex_match_end): r'\g<1>thre', }) epNames = {episodeName} for dictresub in dictresubList: utils.addon_log('dictresub = {0}'.format(dictresub)) epNames.add(utils.multiple_reSub(episodeName, dictresub)) epNames_split = list(filter(None, re.split(' / | , ', episodeName))) if epNames_split[0] != episodeName: epNames.add(epNames_split[0]) utils.addon_log( 'tvdb findEpisodeByName: epNames = {0}'.format(epNames)) delta_selected = 2 ListItem = xbmcgui.ListItem() ListItem.setLabel('Ignore') ListItem.setLabel2('This episode will not be exported') episodeListDialog.append(ListItem) ListItem = xbmcgui.ListItem() ListItem.setLabel('Enter manually') ListItem.setLabel2('Enter season and episode number') episodeListDialog.append(ListItem) if lang != 'en': ListItem = xbmcgui.ListItem() ListItem.setLabel('Try english') ListItem.setLabel2( 'Search TVDB again with language set to english') episodeListDialog.append(ListItem) delta_selected = 3 for episode in json_data: utils.addon_log( 'tvdb findEpisodeByName: episode = {0}'.format(episode)) ListItem = xbmcgui.ListItem() ListItem.setLabel('S{0:02d}E{1:02d} - {2}'.format( episode.get('airedSeason'), episode.get('airedEpisodeNumber'), episode.get('episodeName', episodeName))) ListItem.setLabel2(episode.get('overview')) episodeListDialog.append(ListItem) episodeListData.append({ 'season': episode.get('airedSeason'), 'episode': episode.get('airedEpisodeNumber'), 'episodeName': episode.get('episodeName'), 'match_ratio': -1 }) if episode.get('airedEpisodeNumber') == episodeNr and episode.get( 'airedSeason') == episodeSeason: preselected = episodecount episodecount = episodecount + 1 for epName in epNames: if use_fuzzy_matching == True: if episode.get('episodeName', None): episodeNameTVDB = episode.get('episodeName').lower() epNameL = epName.lower() if re.sub('( |:|,|\.)', '', episodeNameTVDB) == re.sub( '( |:|,|\.)', '', epNameL): ratio1 = 100 ratio2 = 100 ratio3 = 100 ratio4 = 100 else: ratio1 = fuzz.token_sort_ratio( re.sub('(:|,|\.)', '', episodeNameTVDB), re.sub('(:|,|\.)', '', epNameL)) ratio2 = fuzz.token_sort_ratio( re.sub('( |:|,|\.)', '', episodeNameTVDB), re.sub('( |:|,|\.)', '', epNameL)) ratio3 = fuzz.token_set_ratio( episodeNameTVDB, epNameL) ratio4 = fuzz.partial_ratio( re.sub('(:|,|\.)', '', episodeNameTVDB), re.sub('(:|,|\.)', '', epNameL)) if min(len(episodeNameTVDB), len(epNameL)) < 6: ratio = (ratio1 + ratio2) / 2.0 else: ratio = (ratio1 + ratio2 + ratio3 + ratio4) / 4.0 if episodeSeason != episode.get('airedSeason'): if episode.get('airedSeason') == 0: ratio = 0.72 * ratio else: ratio = 0.80 * ratio utils.addon_log( 'tvdb ratio: \'{0}\'; \'{1}\' (TVDB); ratio={2:0.1f} ({3:0.1f} {4:0.1f} {5:0.1f} {6:%0.1f})' .format(epName, episode.get('episodeName'), ratio, ratio1, ratio2, ratio3, ratio4)) if ratio > ratio_max: if ratio_max > 0 and not ( ratio_max_season == episode.get('airedSeason') and ratio_max_episode == episode.get('airedEpisodeNumber')): ratio_max2 = ratio_max ratio_max = ratio ratio_max_season = episode.get('airedSeason') ratio_max_episode = episode.get( 'airedEpisodeNumber') episode_data = { 'season': episode.get('airedSeason'), 'episode': episode.get('airedEpisodeNumber'), 'episodeName': episode.get('episodeName'), 'match_ratio': ratio } else: if (ratio_max2 == 100 or ratio_max2 < ratio) and not ( ratio_max_season == episode.get('airedSeason') and ratio_max_episode == episode.get('airedEpisodeNumber')): ratio_max2 = max(ratio, 0.1) if ratio_max > 99.0: break else: if episode.get('episodeName', None) and ( episode.get('episodeName').lower().replace( ' ', '').find(epName.lower().replace(' ', '')) >= 0 or epName.lower().replace(' ', '').find( episode.get('episodeName').lower().replace( ' ', '')) >= 0): if episodeSeason == episode.get('airedSeason'): ratio_max = 99.5 else: ratio_max = 80 episode_data = { 'season': episode.get('airedSeason'), 'episode': episode.get('airedEpisodeNumber'), 'episodeName': episode.get('episodeName'), 'match_ratio': ratio_max } setEpisodeCache(episodeSeason, episodeName, showid, episode_data, user_entry=False) if ratio_max > 99.0: break match_found = False match_userentry = False if ratio_max >= 95 or (use_fuzzy_matching == False and ratio_max >= 80): match_found = True elif ((ratio_max >= 85 and ratio_max / ratio_max2 >= 1.05) or (ratio_max >= 75 and ratio_max / ratio_max2 >= 1.15) or (ratio_max >= 68 and ratio_max / ratio_max2 >= 1.48)): match_found = True else: utils.addon_log( 'tvdb \'{0}\' \'{1}\'; ratio={2:0.1f} (ratio2={3:0.1f}) [{4:0.1f}]' .format(showname, episodeName, ratio_max, ratio_max2, ratio_max / ratio_max2)) match_found_fallback_en = False if match_found == False and lang != 'en': episode_data_en = findEpisodeByName(show_data, episodeSeason, episodeNr, episodeName, 'en', silent=True, fallback_en=True) if episode_data_en: episode_data = episode_data_en match_found = True match_found_fallback_en = True # if match_found == False and silent == False and ratio_max >= 60 and ratio_max/ratio_max2 > 1.05: # match_found = xbmcgui.Dialog().yesno('Match for {0}?'.format(showname), # 'from Addon: \'S{0:02d}E{1:02d} - {2}\''.format( episodeSeason, episodeNr, episodeName), # 'TVDB: \'S{0:02d}E{1:02d} - {2}\''.format(episode_data.get('season'), episode_data.get('episode'), episode_data.get('episodeName')), # 'ratio = {0:0.1f} ({1:0.1f}) [{2:0.1f}]'.format(ratio_max, ratio_max2, ratio_max/ratio_max2), # autoclose = dialog_autoclose_time*1000 ) if match_found == True: match_userentry = True if match_found == False and silent == False: dialog = xbmcgui.Dialog() time1 = time.time() selected = dialog.select( 'No match found for {0}: \'S{1:02d}E{2:02d} - {3}\''.format( showname, episodeSeason, episodeNr, episodeName), episodeListDialog, useDetails=True, autoclose=dialog_autoclose_time * 1000, preselect=int(0 if preselected is None else preselected + delta_selected)) time2 = time.time() if dialog_autoclose_time > 0 and int( time2 - time1) >= dialog_autoclose_time: selected = -1 if selected >= delta_selected and selected < episodecount + delta_selected: episode_data = episodeListData[selected - delta_selected] match_found = True match_userentry = True elif selected == 1: try: season_input = int( dialog.numeric( 0, 'Season for \'{0}\': \'S{1:02d}E{2:02d} - {3}\''. format(showname, episodeSeason, episodeNr, episodeName), str(episodeSeason))) episode_input = int( dialog.numeric( 0, 'Episode for \'{0}\': \'S{1:02d}E{2:02d} - {3}\''. format(showname, episodeSeason, episodeNr, episodeName), str(episodeNr))) episode_data = { 'season': season_input, 'episode': episode_input, 'episodeName': episodeName, 'match_ratio': -1 } setEpisodeCache(episodeSeason, episodeName, showid, episode_data, user_entry=True) match_found = True match_userentry = True except: pass elif lang != 'en' and selected == 2: episode_data_en = findEpisodeByName(show_data, episodeSeason, episodeNr, episodeName, 'en', fallback_en=True) if episode_data_en: episode_data = episode_data_en match_found = True match_found_fallback_en = True elif selected == 0: episode_data = { 'season': episodeSeason, 'episode': episodeNr, 'episodeName': episodeName, 'ignore': True } setEpisodeCache(episodeSeason, episodeName, showid, episode_data, user_entry=True) utils.addon_log_notice( 'tvdb findEpisodeByName: ignore episodeName = \'{0}\'; lang = {1}' .format(episodeName, lang)) if match_found == True: if match_found_fallback_en != True: setEpisodeCache(episodeSeason, episodeName, showid, episode_data, user_entry=match_userentry) utils.addon_log_notice( 'tvdb findEpisodeByName: \'{0}\' <-> \'{1}\' (TVDB); lang={2}; ratio={3:0.2f}' .format(episodeName, episode_data.get('episodeName'), lang, episode_data.get('match_ratio'))) else: episode_data = None utils.addon_log_notice( 'tvdb findEpisodeByName: could not match episodeName = \'{0}\'; lang = {1}' .format(episodeName, lang)) if episode_data and episode_data.get('ignore', False): return None return episode_data
def addMovies(contentList, strm_name="", strm_type="Other"): movieList = [] pagesDone = 0 file = "" while pagesDone < int(PAGINGMovies): for detailInfo in contentList: 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) 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 label and strm_name and label: label = str(utils.multiple_reSub(label.rstrip(), dictReplacements)) movieList.append( [ os.path.join(strm_type, strm_name, label), str(utils.multiple_reSub(label.rstrip(), dictReplacements)), link, ] ) except: pass pagesDone += 1 if filetype != "file" and pagesDone < int(PAGINGMovies): contentList = stringUtils.uni(jsonUtils.requestList(file, "video")) else: pagesDone = int(PAGINGMovies) # Write strms for all values in movieList for i in movieList: # path,name,url(+name) fileSys.writeSTRM( stringUtils.cleanStrms((i[0].rstrip("."))), stringUtils.cleanStrms(i[1].rstrip(".")), i[2] + "|" + i[1] ) return movieList
def fillPluginItems( url, media_type="video", file_type=False, strm=False, strm_name="", strm_type="Other", showtitle="None" ): utils.addon_log("fillPluginItems") if not file_type: detail = stringUtils.uni(jsonUtils.requestList(url, media_type)) listLength = len(detail) else: detail = stringUtils.uni(jsonUtils.requestItem(url, media_type)) if strm_type.find("Cinema") != -1: addMovies(detail, strm_name, strm_type) return if strm_type.find("TV-Show") != -1: addTVShows(detail, strm_name, strm_type) return if strm_type.find("Shows-Collection") != -1: getTVShowFromList(detail, strm_name, strm_type) return # 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) if filetypes and labels and files: filetype = filetypes.group(1) label = stringUtils.cleanLabels(labels.group(1)) file = files.group(1).replace("\\\\", "\\") strm_name = str(utils.multiple_reSub(strm_name.rstrip(), dictReplacements)) 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.find("TV(") != -1: path = os.path.join(strm_type, strm_name) filename = str(label) if strm_type.find("Movie") != -1: path = os.path.join(strm_type, strm_name) filename = str(label) if strm_type in ["Audio-Album"]: path = os.path.join(strm_type, strm_name) try: album = re.search('"album" *: *"(.*?)",', f).group(1) try: artist = re.search('"artist" *: *"(.*?)",', f).group(1) except: artist = re.search('"artist"*:*."(.*?)".,', f).group(1) pass titl = re.search('"title" *: *(.*?),', f).group(1) types = re.search('"type" *: *(.*?),', f).group(1) filename = str(strm_name + " - " + label) except: filename = str(strm_name + " - " + label) if strm_type in ["Audio-Single"]: path = os.path.join("Singles", str(strm_name)) try: album = re.search('"album" *: *"(.*?)",', f).group(1) try: artist = re.search('"artist" *: *"(.*?)",', f).group(1) except: artist = re.search('"artist"*:*."(.*?)".,', f).group(1) pass titl = re.search('"title" *: *(.*?),', f).group(1) types = re.search('"type" *: *(.*?),', f).group(1) filename = str(strm_name + " - " + label) except: filename = str(strm_name + " - " + label) 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 == "Audio-Album": 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, ) # 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, "", "", "")
def getEpisodes(episodesListRaw, strm_name, strm_type): episodesList = [] typeChange = [] try: if type(episodesListRaw) is unicode: typeChange.append(episodesListRaw) episodesListRaw = typeChange for detailInfo in episodesListRaw: 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) if filetypes: if re.search('"filetype" *: *"(.*?)",', detailInfo).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(utils.multiple_reSub(strm_name.rstrip(), dictReplacements)) showtitle = utils.multiple_reSub((showtitles.group(1)), dictReplacements) season = utils.multiple_reSub((seasons.group(1)).replace("-", ""), dictReplacements) episode = utils.multiple_reSub((episodes.group(1)).replace("-", ""), dictReplacements) if not descriptions: description = "" else: description = stringUtils.cleanLabels(descriptions.group(1)) 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 showtitle.find('10-8:') != -1: # x= showtitle episodesList.append( [ os.path.join( xbmc.translatePath( strm_type + "//" + (utils.multiple_reSub(showtitle, dictReplacements)) ) ), str("s" + season), str("e" + episode), link, ] ) except IOError as (errno, strerror): print "I/O error({0}): {1}".format(errno, strerror)
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(utils.multiple_reSub(label.strip(), dictReplacements)), 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.")
def fillPluginItems(url, media_type='video', file_type=False, strm=False, strm_name='', strm_type='Other', showtitle='None'): addon_log('fillPluginItems') if not file_type: detail = uni(requestList(url, media_type)) else: detail = uni(requestItem(url, media_type)) 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) episodes = re.search('"episode" *: *(.*?),', f) seasons = re.search('"season" *: *(.*?),', f) showtitles = re.search('"showtitle" *: *"(.*?)",', f) dictReplacements = { "'(\\d+)'": '', '()': '', 'Kinofilme': '', ' ': ' ', 'Movies': '', 'Filme': '', 'Movie': '', "'.'": ' ', '\xc3\x84': 'Ae', '\xc3\xa4': 'ae', '\xc3\x96': 'Oe', '\xc3\xb6': 'oe', '\xc3\x9c': 'Ue', 'xc3\xbc': 'ue', '\xc3\x9f': 'ss' } if filetypes and labels and files: filetype = filetypes.group(1) label = cleanLabels(labels.group(1)) file = (files.group(1).replace("\\\\", "\\")) if showtitles != None: if showtitle == 'None': showtitle = strm_name elif showtitles.group(1) != "" and showtitle == 'None': showtitle = utils.multiple_reSub( (showtitles.group(1)).rstrip(), dictReplacements) showtitle = utils.multiple_reSub(showtitle.rstrip(), dictReplacements) if (seasons) != None: season = (seasons.group(1)) else: season = False if (episodes) != None: episode = (episodes.group(1).replace("-", "")) else: episode = False if not descriptions: description = '' else: description = cleanLabels(descriptions.group(1)) thumbnail = removeNonAscii(thumbnails.group(1)) fanart = 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 ['TV']: path = os.path.join('TV', strm_name) filename = strm_name + ' - ' + label if strm_type in ['Cinema']: path = os.path.join('Cinema', strm_name) filename = utils.multiple_reSub(label.rstrip(), dictReplacements) if strm_type in ['TV-Shows']: if showtitle and season and episode: # if showtitle == "": # showtitle = strm_name path = os.path.join('TV-Shows', showtitle) filename = 's' + season + 'e' + episode addon_log( utils.multiple_reSub(path.rstrip(), dictReplacements) + " - " + utils.multiple_reSub(filename.rstrip(), dictReplacements)) else: path = os.path.join('Other', strm_name) filename = strm_name + ' - ' + label if strm_type in ['Audio-Album']: path = os.path.join('Albums', strm_name) try: album = re.search('"album" *: *"(.*?)",', f).group(1) try: artist = re.search('"artist" *: *"(.*?)",', f).group(1) except: artist = re.search('"artist"*:*."(.*?)".,', f).group(1) pass titl = re.search('"title" *: *(.*?),', f).group(1) types = re.search('"type" *: *(.*?),', f).group(1) filename = strm_name + ' - ' + label except: filename = strm_name + ' - ' + label if strm_type in ['Audio-Single']: path = os.path.join('Singles', strm_name) try: album = re.search('"album" *: *"(.*?)",', f).group(1) try: artist = re.search('"artist" *: *"(.*?)",', f).group(1) except: artist = re.search('"artist"*:*."(.*?)".,', f).group(1) pass titl = re.search('"title" *: *(.*?),', f).group(1) types = re.search('"type" *: *(.*?),', f).group(1) filename = strm_name + ' - ' + label except: filename = strm_name + ' - ' + label if strm_type in ['Other']: path = os.path.join('Other', strm_name) filename = strm_name + ' - ' + label addon_log(path + ' ' + filename) if filetype == 'file': if strm: if strm_type == 'Audio-Album': utils.createSongNFO(cleanStrms(path), cleanStrms(filename), strm_ty=strm_type, artists=artist, albums=album, titls=titl, typese=types) # xbmc.executebuiltin('Notification(%s, %s, %d, %s)'%(path + " - " + filename, " writing...",5000,"")) writeSTRM(cleanStrms(path), cleanStrms(filename), link) else: 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, showtitle) else: addDir(label, file, 101, thumbnail, fanart, description, '', '', '')
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: try: initialize_DialogBG("Movie", "Adding") addMovies(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('TVShows sub structures') != -1: try: initialize_DialogBG("TV-Show SST", "Adding") addTVShowsSST(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('TV-Show') != -1: try: initialize_DialogBG("TV-Show", "Adding") addTVShows(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('Shows-Collection') != -1: try: initialize_DialogBG("Shows-Collection", "Adding") 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( utils.multiple_reSub(strm_name.strip(), dictReplacements)) 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 = utils.multiple_reSub( re.search('"artist" *: *"(.*?)",', f).group(1).strip(), dictReplacements) except: artist = utils.multiple_reSub( re.search('"artist"*:*."(.*?)".,', f).group(1).strip(), dictReplacements) pass titl = utils.multiple_reSub( re.search('"title" *: *(.*?),', f).group(1).strip(), dictReplacements) types = utils.multiple_reSub( re.search('"type" *: *(.*?),', f).group(1).strip(), dictReplacements) filename = utils.multiple_reSub( str(label).strip(), dictReplacements) except: filename = utils.multiple_reSub( str(label).strip(), dictReplacements) 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, '', '', '')
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( utils.multiple_reSub(label.strip(), dictReplacements)) if tracks: track = tracks.group(1) try: album = re.search('"album" *: *"(.*?)",', detailInfo).group(1).strip() try: artist = utils.multiple_reSub( re.search('"artist" *: *"(.*?)",', detailInfo).group(1).strip(), dictReplacements) except: artist = utils.multiple_reSub( re.search('"artist"*:*."(.*?)".,', detailInfo).group(1).strip(), dictReplacements) pass titl = utils.multiple_reSub( re.search('"title" *: *(.*?),', detailInfo).group(1).strip(), dictReplacements) types = utils.multiple_reSub( re.search('"type" *: *(.*?),', detailInfo).group(1).strip(), dictReplacements) filename = utils.multiple_reSub( str(label).strip(), dictReplacements) except: filename = utils.multiple_reSub( str(label).strip(), dictReplacements) 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: