def writeMediaList(url, name, cType='Other'): utils.addon_log('writeMediaList') existInList = False thelist = [] thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml')) theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n' if not xbmcvfs.exists(profile): xbmcvfs.mkdirs(profile) if not xbmcvfs.exists(thefile): open(thefile, 'a').close() fle = codecs.open(thefile, "r", 'UTF-8') thelist = fle.readlines() fle.close() del fle if len(thelist) > 0: for i in thelist: if i.split('|',2)[1] == name: thelist = stringUtils.replaceStringElem(thelist, theentry, theentry) existInList = True if existInList != True: thelist.append(theentry) 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())
def update(strm_name, url, media_type, thelist): plex_details = jsonUtils.requestList("plugin://plugin.video.plexbmc", media_type).get('files', []) for plex_detail in plex_details: if strm_name.replace('++RenamedTitle++', '') == stringUtils.cleanLabels( plex_detail['label']): serverurl = plex_detail['file'] 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()) return serverurl else: break return url
def writeMediaList(url, name, cType='Other', cleanName=True): utils.addon_log('writeMediaList') existInList = False thelist = [] thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml')) theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n' if not xbmcvfs.exists(profile): xbmcvfs.mkdirs(profile) if not xbmcvfs.exists(thefile): open(thefile, 'a').close() fle = codecs.open(thefile, "r", 'UTF-8') thelist = fle.readlines() fle.close() del fle if len(thelist) > 0: for i in thelist: if i.split('|',2)[1] == name: xbmcgui.Dialog().notification(str(i), "Adding to MediaList", os.path.join(ADDON_PATH, 'representerIcon.png'), 5000) thelist = stringUtils.replaceStringElem(thelist, theentry, theentry) existInList = True if existInList != True: thelist.append(theentry) 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())
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 update(strm_name, url, media_type, thelist): plex_details = jsonUtils.requestList("plugin://plugin.video.plexbmc", media_type).get('files', []) for plex_detail in plex_details: if stringUtils.getStrmname(strm_name) == stringUtils.cleanLabels( plex_detail['label']): serverurl = plex_detail['file'] if url != serverurl: for entry in thelist: splits = entry.split("|") if splits[1] == strm_name: splits[2] = serverurl newentry = '|'.join(splits) thelist = stringUtils.replaceStringElem( thelist, entry, newentry) thefile = xbmc.translatePath( os.path.join(addon.getSetting('MediaList_LOC'), 'MediaList.xml')) output_file = xbmcvfs.File(thefile.decode("utf-8"), 'w') for index, linje in enumerate(thelist): output_file.write( ('%s\n' if index < len(thelist) - 1 else '%s') % linje.strip().encode('utf-8')) return serverurl else: break return url
def writeMediaList(url, name, cType='Other', cleanName=True, albumartist=None): utils.addon_log('writeMediaList') existInList = False thefile = xbmc.translatePath(os.path.join(MEDIALIST_PATH, 'MediaList.xml')) if not xbmcvfs.exists(profile): xbmcvfs.mkdirs(profile) if not xbmcvfs.exists(thefile): xbmcvfs.File(thefile, 'w').close() fle = xbmcvfs.File(thefile, 'r') thelist = fle.read().splitlines() fle.close() del fle thelist = [x for x in thelist if x != ''] if len(thelist) > 0: for i in thelist: splits = i.strip().split('|') if stringUtils.getStrmname( splits[1]).lower() == stringUtils.getStrmname( name).lower(): existInList = True if splits[2].find(url) == -1: splits[2] = '%s<next>%s' % (splits[2], url) if albumartist: splits[4] = albumartist.decode('utf-8') newentry = '|'.join(splits) xbmcgui.Dialog().notification( str(i), "Adding to MediaList", os.path.join(ADDON_PATH, 'resources/representerIcon.png'), 5000) thelist = stringUtils.replaceStringElem( thelist, i, newentry) if existInList != True: newentry = [cType, name.decode("utf-8"), url] if albumartist: newentry.append(albumartist.decode('utf-8')) newentry = '|'.join(newentry) thelist.append(newentry) output_file = xbmcvfs.File(thefile.decode("utf-8"), 'w') for index, linje in enumerate(thelist): output_file.write(('%s\n' if index < len(thelist) - 1 else '%s') % linje.strip().encode('utf-8'))
def writeMediaList(url, name, cType='Other', cleanName=True): utils.addon_log('writeMediaList') existInList = False thelist = [] thefile = xbmc.translatePath(os.path.join(profile, 'MediaList.xml')) theentry = '|'.join([cType, name.decode("utf-8"), url]) + '\n' if not xbmcvfs.exists(profile): xbmcvfs.mkdirs(profile) if not xbmcvfs.exists(thefile): open(thefile, 'a').close() fle = codecs.open(thefile, "r", 'UTF-8') thelist = fle.readlines() fle.close() del fle if len(thelist) > 0: for i in thelist: splits = i.strip().split('|') if stringUtils.getStrmname( splits[1]) == stringUtils.getStrmname(name): splitPlugin = re.search('%s([^\/\?]*)' % ("plugin:\/\/"), splits[2]) mediaPlugin = re.search('%s([^\/\?]*)' % ("plugin:\/\/"), url) if mediaPlugin and splitPlugin and mediaPlugin.group( 1) == splitPlugin.group(1): xbmcgui.Dialog().notification( str(i), "Adding to MediaList", os.path.join(ADDON_PATH, 'resources/representerIcon.png'), 5000) thelist = stringUtils.replaceStringElem( thelist, i, theentry) existInList = True if existInList != True: thelist.append(theentry) 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())
def make_sure_path_exists(path): try: os.makedirs(path) except OSError as exception: if exception.errno != errno.EEXIST: raise else: fle = codecs.open(thefile, "r", 'UTF-8') thelist = fle.readlines() fle.close() del fle if theentry not in thelist: thelist.append(theentry) else: thelist = stringUtils.replaceStringElem(thelist, theentry, theentry) 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())
def make_sure_path_exists(path): try: os.makedirs(path) except OSError as exception: if exception.errno != errno.EEXIST: raise else: fle = codecs.open(thefile, "r", 'UTF-8') thelist = fle.readlines() fle.close() del fle if theentry not in thelist: thelist.append(theentry) else: thelist = stringUtils.replaceStringElem(thelist, theentry, theentry) 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())