def update_playlist(id, type=''): settings = m_xml.xml_get_elem('playlists/playlist', 'playlist', {'id': id}, type=type) #Grab the xml settings for this playlist if settings is None: dev.log('Could not find playlist '+id+' in the '+dev.typeXml(type)+' file', True) return False else: dev.log('Updating playlist %s (Id: %s)' % (settings.find('title').text.encode('utf-8'), id)) #Check in which folder the show should be added folder = settings.find('overwritefolder').text if folder is None or folder == '': folder = dev.legal_filename(settings.find('title').text) #Overwrite folder is not set in settings.xml, so set the folder to the title of the show else: folder = dev.legal_filename(folder) #Create the tvshow.nfo writenfo = settings.find('writenfo').text if writenfo != 'no': if type == '' or type == 'tv': generators.write_tvshow_nfo(folder, settings) update_playlist_vids(id, folder, settings, type=type) #Save the time this playlist got updated in the xml import datetime d=datetime.datetime.now() m_xml.xml_update_playlist_attr(id, 'scansince', d.strftime("%d/%m/%Y %H:%M:%S"), type=type) return True
def delete_playlist(id, type=''): #Grab the settings from this playlist settings = m_xml.xml_get_elem('playlists/playlist', 'playlist', {'id': id}, type=type) #Grab the xml settings for this playlist if settings is None: dev.log('deletePlaylist: Could not find playlist '+id+' in the '+dev.typeXml(type)+' file', True) return False else: i = xbmcgui.Dialog().yesno("Delete Playlist", "Are you sure you want to delete this playlist?") if i == 0: editPlaylist(id, type=type) else: if m_xml.xml_remove_playlist(id, type=type) is True: #Remove the episodenr xml file to file = os.path.join(vars.settingsPath+dev.typeEpnr(type), id+'.xml' ) if os.path.isfile(file): success = os.remove(file) #Remove the episodenr xml file xbmcgui.Dialog().ok('Removed Playlist', 'Succesfully removed playlist '+id) i = xbmcgui.Dialog().yesno('Delete from library', 'Do you also want to delete the videos from your library?') if i != 0: #Check in which folder the show resides folder = settings.find('overwritefolder').text if folder is None or folder == '': folder = dev.legal_filename(settings.find('title').text) #Overwrite folder is not set in settings.xml, so set the folder to the title of the show else: folder = dev.legal_filename(folder) movieLibrary = vars.tv_folder #Use the directory from the addon settings if type == 'musicvideo': movieLibrary = vars.musicvideo_folder elif type == 'movies': movieLibrary = vars.movies_folder dir = os.path.join(movieLibrary, folder) #Set the folder to the maindir/dir success = shutil.rmtree(dir, ignore_errors=True) #Remove the directory xbmcgui.Dialog().ok('Removed from library', 'Deleted the videos from your library (You should clean your library, otherwise they will still show in your library)')
def refresh_playlist(id, type=''): #Grab the settings from this playlist settings = m_xml.xml_get_elem( 'playlists/playlist', 'playlist', {'id': id}, type=type) #Grab the xml settings for this playlist if settings is None: dev.log( 'refreshPlaylist: Could not find playlist ' + id + ' in the ' + typeXml(type) + ' file', True) return False else: i = xbmcgui.Dialog().yesno( "Refresh Playlist", "Are you sure you want to refresh this playlist?") if i != 0: m_xml.xml_update_playlist_setting(id, 'lastvideoId', '', type=type) #Delete the .xml containing all scanned videoId's as well file = os.path.join(vars.settingsPath, dev.typeEpnr(type)) file = os.path.join(file, id + '.xml') if os.path.isfile(file): success = os.remove(file) #Remove the episodenr xml file xbmcgui.Dialog().ok('Refreshed Playlist', 'Succesfully refreshed playlist ' + id) i = xbmcgui.Dialog().yesno( 'Delete from library', 'Do you also want to delete the previous videos from your library?' ) if i != 0: #Check in which folder the show resides folder = settings.find('overwritefolder').text if folder is None or folder == '': folder = dev.legal_filename( settings.find('title').text ) #Overwrite folder is not set in settings.xml, so set the folder to the title of the show else: folder = dev.legal_filename(folder) movieLibrary = vars.tv_folder #Use the directory from the addon settings if type == 'musicvideo': movieLibrary = vars.musicvideo_folder elif type == 'movies': movieLibrary = vars.movies_folder dir = os.path.join(movieLibrary, folder) #Set the folder to the maindir/dir success = shutil.rmtree( dir, ignore_errors=True) #Remove the directory #if vars.update_videolibrary == "true" and type=='': # update_dir = vars.tv_folder_path # if type == 'musicvideo': # update_dir = vars.musicvideo_folder_path # dev.log('Updating video library is enabled. Cleaning librarys directory %s' % update_dir, True) # xbmc.executebuiltin('xbmc.updatelibrary(Video,'+update_dir+')') xbmcgui.Dialog().ok( 'Removed from library', 'Deleted the previous videos from your library (You should clean your library, otherwise they will still show in your library)' ) editPlaylist(id, type=type) #Load the editplaylist view
def write_strm(name, fold, videoid, show=None, season=None, episode=None, startpoint = None, endpoint = None, artist='', album='', song='', year='', type=''): #dev.log('strm('+name+', '+fold+', '+videoid+')') movieLibrary = vars.tv_folder #The path we should save in is the vars.tv_folder setting from the addon settings if type=='musicvideo': movieLibrary = vars.musicvideo_folder sysname = urllib.quote_plus(videoid) #Escape strings in the videoid if needed enc_name = dev.legal_filename(name) #Encode the filename to a legal filename if vars.__settings__.getSetting("strm_link") == "Youtube Library": if type == 'musicvideo': content = 'plugin://plugin.video.youtubelibrary/?mode=playmusicvideo' if startpoint != None: content += '&startpoint='+startpoint if endpoint != None: content += '&endpoint='+endpoint content += '&id=%s&artist=%s&song=%s&album=%s&year=%s&filename=%s' % (sysname, artist, song, album, year, enc_name) #Set the content of the strm file with a link back to this addon for playing the video else: content = 'plugin://plugin.video.youtubelibrary/?mode=play&id=%s&show=%s&season=%s&episode=%s&filename=%s' % (sysname, show, season, episode, enc_name) #Set the content of the strm file with a link back to this addon for playing the video else: content = vars.KODI_ADDONLINK+'%s' % ( sysname) #Set the content of the strm file with a link to the official Kodi Youtube Addon xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exists yet folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet stream = os.path.join(folder, enc_name + '.strm') #Set the file to maindir/name/name.strm file = xbmcvfs.File(stream, 'w') #Open / create this file for writing file.write(str(content.encode('UTF-8'))) #Write the content in the file file.close() #Close the file dev.log('write_strm: Written strm file: '+fold+'/'+enc_name+'.strm') return enc_name
def downloadYoutubeVid(name, fold, videoid, settings, type='', season=None): #youtube-dl command to download best quality: -f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm] #YDStreamExtractor.disableDASHVideo(True) movieLibrary = vars.tv_folder #The path we should save in is the vars.tv_folder setting from the addon settings if type == 'musicvideo': movieLibrary = vars.musicvideo_folder if type == 'movies': movieLibrary = vars.movies_folder folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir enc_name = dev.legal_filename( name) #Encode the filename to a legal filename xbmcvfs.mkdir( movieLibrary) #Create the maindirectory if it does not exist yet xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet if type == '' or type == 'tv': folder = os.path.join(folder, 'Season ' + season) #Set the folder to the maindir/dir xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet full_file_path = os.path.join(folder, enc_name) #Set the file to maindir/name/name dev.log('Downloading ' + videoid, 1) #vid = YDStreamExtractor.getVideoInfo(videoid,quality=1) path = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir #url = "https://www.youtube.com/watch?v=YKSU82afy1w" #ducktales intro to test url = "https://www.youtube.com/watch?v=" + videoid vid = YDStreamExtractor.getVideoInfo(url, quality=1) if vid == None: dev.log('Failed to retrieve video from url: ' + url) return False if settings.find('download_videos').text == '720p': dev.log('%%%%%%% QUALITY: 720p quality selected') format = 'bestvideo[height<=?720]+bestaudio/best[height<=?720]' elif settings.find('download_videos').text == '1080p': dev.log('%%%%%%% QUALITY: 1080p quality selected') format = 'bestvideo[height<=?1080]+bestaudio/best[height<=?1080]' else: dev.log('%%%%%%% QUALITY: best quality selected') format = 'bestvideo+bestaudio/best' ydl_opts = { 'format': format, 'logger': MyLogger(), 'progress_hooks': [my_hook], 'outtmpl': full_file_path + '.%(ext)s', #'-o' : enc_name+'.%(ext)s', } with youtube_dl.YoutubeDL(ydl_opts) as ydl: return ydl.download(['https://www.youtube.com/watch?v=' + videoid]) """
def downloadYoutubeVid(name, fold, videoid, settings, type='', season=None): #youtube-dl command to download best quality: -f bestvideo[ext!=webm]+bestaudio[ext!=webm]/best[ext!=webm] #YDStreamExtractor.disableDASHVideo(True) movieLibrary = vars.tv_folder #The path we should save in is the vars.tv_folder setting from the addon settings if type=='musicvideo': movieLibrary = vars.musicvideo_folder if type=='movies': movieLibrary = vars.movies_folder folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir enc_name = dev.legal_filename(name) #Encode the filename to a legal filename xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exist yet xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet if type == '' or type == 'tv': folder = os.path.join(folder, 'Season '+season) #Set the folder to the maindir/dir xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet full_file_path = os.path.join(folder, enc_name) #Set the file to maindir/name/name dev.log('Downloading '+videoid, 1) #vid = YDStreamExtractor.getVideoInfo(videoid,quality=1) path = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir #url = "https://www.youtube.com/watch?v=YKSU82afy1w" #ducktales intro to test url = "https://www.youtube.com/watch?v="+videoid vid = YDStreamExtractor.getVideoInfo(url,quality=1) if vid == None: dev.log('Failed to retrieve video from url: '+url) return False if settings.find('download_videos').text == '720p': dev.log('%%%%%%% QUALITY: 720p quality selected') format = 'bestvideo[height<=?720]+bestaudio/best[height<=?720]' elif settings.find('download_videos').text == '1080p': dev.log('%%%%%%% QUALITY: 1080p quality selected') format = 'bestvideo[height<=?1080]+bestaudio/best[height<=?1080]' else: dev.log('%%%%%%% QUALITY: best quality selected') format = 'bestvideo+bestaudio/best' ydl_opts = { 'format': format, 'logger': MyLogger(), 'progress_hooks': [my_hook], 'outtmpl' : full_file_path+'.%(ext)s', #'-o' : enc_name+'.%(ext)s', } with youtube_dl.YoutubeDL(ydl_opts) as ydl: return ydl.download(['https://www.youtube.com/watch?v='+videoid]) """
def refresh_playlist(id, type=''): #Grab the settings from this playlist settings = m_xml.xml_get_elem('playlists/playlist', 'playlist', {'id': id}, type=type) #Grab the xml settings for this playlist if settings is None: dev.log('refreshPlaylist: Could not find playlist '+id+' in the '+typeXml(type)+' file', True) return False else: i = xbmcgui.Dialog().yesno("Refresh Playlist", "Are you sure you want to refresh this playlist?") if i != 0: m_xml.xml_update_playlist_setting(id, 'lastvideoId', '', type=type) #Delete the .xml containing all scanned videoId's as well file = os.path.join(vars.settingsPath, dev.typeEpnr(type)) file = os.path.join(file, id+'.xml') if os.path.isfile(file): success = os.remove(file) #Remove the episodenr xml file xbmcgui.Dialog().ok('Refreshed Playlist', 'Succesfully refreshed playlist '+id) i = xbmcgui.Dialog().yesno('Delete from library', 'Do you also want to delete the previous videos from your library?') if i != 0: #Check in which folder the show resides folder = settings.find('overwritefolder').text if folder is None or folder == '': folder = dev.legal_filename(settings.find('title').text) #Overwrite folder is not set in settings.xml, so set the folder to the title of the show else: folder = dev.legal_filename(folder) movieLibrary = vars.tv_folder #Use the directory from the addon settings if type == 'musicvideo': movieLibrary = vars.musicvideo_folder elif type == 'movies': movieLibrary = vars.movies_folder dir = os.path.join(movieLibrary, folder) #Set the folder to the maindir/dir success = shutil.rmtree(dir, ignore_errors=True) #Remove the directory #if vars.update_videolibrary == "true" and type=='': # update_dir = vars.tv_folder_path # if type == 'musicvideo': # update_dir = vars.musicvideo_folder_path # dev.log('Updating video library is enabled. Cleaning librarys directory %s' % update_dir, True) # xbmc.executebuiltin('xbmc.updatelibrary(Video,'+update_dir+')') xbmcgui.Dialog().ok('Removed from library', 'Deleted the previous videos from your library (You should clean your library, otherwise they will still show in your library)') editPlaylist(id, type=type) #Load the editplaylist view
def update_playlist(id, type=''): settings = m_xml.xml_get_elem( 'playlists/playlist', 'playlist', {'id': id}, type=type) #Grab the xml settings for this playlist if settings is None: dev.log( 'Could not find playlist ' + id + ' in the ' + dev.typeXml(type) + ' file', True) return False else: dev.log('Updating playlist %s (Id: %s)' % (settings.find('title').text.encode('utf-8'), id)) #Check in which folder the show should be added folder = settings.find('overwritefolder').text if folder is None or folder == '': folder = dev.legal_filename( settings.find('title').text ) #Overwrite folder is not set in settings.xml, so set the folder to the title of the show else: folder = dev.legal_filename(folder) #Create the tvshow.nfo writenfo = settings.find('writenfo').text if writenfo != 'no': if type == '' or type == 'tv': generators.write_tvshow_nfo(folder, settings) elif type == 'musicvideo': generators.write_artist_nfo(folder, settings) if update_playlist_vids(id, folder, settings, type=type) == False: return False #something failed while updating the videos of the playlist #Save the time this playlist got updated in the xml import datetime d = datetime.datetime.now() m_xml.xml_update_playlist_attr(id, 'scansince', d.strftime("%d/%m/%Y %H:%M:%S"), type=type) return True
def write_tvshow_nfo(fold, settings): dev.log('write_tvshow_nfo('+fold+')') name = 'tvshow' movieLibrary = vars.tv_folder #Use the directory from the addon settings #Grab the published date and convert it to a normal date d = ytube.convert_published(settings.find('published').text) normaldate = d['year']+'-'+d['month']+'-'+d['day'] #Grab the tags and convert them to xml tags = settings.find('tags') tags_xml = '' if tags is not None: tags = settings.find('tags').text if '/' in tags: multi_tags = tags.split('/') tags_xml = '' for tag in multi_tags: tags_xml += '<tag>'+tag.strip(' \t\n\r')+'</tag>' elif tags.strip(' \t\n\r') is not '': tags_xml = '<tag>'+tags.strip(' \t\n\r')+'</tag>' #Create the contents of the xml file content = u""" <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <tvshow> <title>%(title)s</title> <showtitle>%(title)s</showtitle> <year>%(year)s</year> <plot>%(plot)s</plot> <genre>%(genre)s</genre> <premiered>%(date)s</premiered> <aired>%(date)s</aired> <studio>%(studio)s</studio> <thumb>%(thumb)s</thumb> <thumb aspect="poster">%(thumb)s</thumb> <thumb aspect="banner">%(banner)s</thumb> <fanart> <thumb>%(fanart)s</thumb> </fanart> %(tags)s </tvshow> """ % { 'title': settings.find('title').text, 'plot': settings.find('description').text, 'year': d['year'], 'genre': settings.find('genre').text, 'studio': settings.find('channel').text, 'thumb': settings.find('thumb').text, 'banner': settings.find('banner').text, 'fanart': settings.find('fanart').text, 'date': normaldate, 'tags': tags_xml, } xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exists yet enc_name = dev.legal_filename(name) #Set the filename to a legal filename folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet stream = os.path.join(folder, enc_name + '.nfo') #Set the file to maindir/name/name.strm import codecs # process Unicode text with codecs.open(stream,'w',encoding='utf8') as f: f.write(content) f.close() #file = xbmcvfs.File(stream, 'w') #Open / create this file for writing #file.write(str(content)) #Write the content in the file #file.close() #Close the file dev.log('write_tvshow_nfo: Written tvshow.nfo file: '+fold+'/'+enc_name+'.nfo') #If the setting download_images is true, we should also download the images as actual files into the directory if vars.__settings__.getSetting("download_images") == "true": dev.log('download_images enabled, so downloading images to '+folder) urllib.urlretrieve(settings.find('thumb').text, folder+"/folder.jpg") urllib.urlretrieve(settings.find('banner').text, folder+"/banner.jpg") urllib.urlretrieve(settings.find('fanart').text, folder+"/fanart.jpg")
def write_nfo(name, fold, vid, settings, season='', episode='', duration='0', overwrite_title=None, overwrite_description=None, musicvideo=None, type=''): #dev.log('write_nfo('+name+', '+fold+')') movieLibrary = vars.tv_folder #Use the directory from the addon settings if type=='musicvideo': movieLibrary = vars.musicvideo_folder snippet = vid['snippet'] #See if we should do something to the title according to the settings title = snippet['title'] if overwrite_title != None: title = overwrite_title removetitle = settings.find('removetitle').text if removetitle == None: removetitle = '' if len(removetitle) > 0: #See if there are multiple lines if '|' in removetitle: strip = removetitle.split('|') for s in strip: #Check if we should do regex r = reg(s, title) if r is not None: s = r if s in title: title = title.replace(s, '') #Remove this line from the title else: #Check if this is a regex var of what should be removed rem = reg(removetitle, title) if rem is not None: removetitle = rem #Regex was succesfull, set removetitle to the found string so it can be removed as normal title = re.sub(removetitle, '', title, flags=re.IGNORECASE) #if removetitle in title: #title = title.replace(removetitle, '') #See if we should do something to the title according to the settings striptitle = settings.find('striptitle').text if striptitle == None: striptitle = '' if len(striptitle) > 0: #See if there are multiple lines if '|' in striptitle: strip = striptitle.split('|') for s in strip: if s in title: title = title[:title.index(s)] #Strip everything to the point where the line was found else: #Check if this is a regex var of what should be removed rem = reg(title, striptitle) if rem is not None: striptitle = rem #Regex was succesfull, set striptitle to the found string so it can be stripped as normal if striptitle in title: title = title[:title.index(striptitle)] #Strip everything to the point where the line was found #See if we should do something to the description according to the settings description = snippet['description'] if overwrite_description != None: description = overwrite_description removedescription = settings.find('removedescription').text if removedescription == None: removedescription = '' if len(removedescription) > 0: #See if there are multiple lines if '|' in removedescription: strip = removedescription.split('|') for s in strip: if s in description: description = description.replace(s, '') #Remove this line from the description else: #Check if this is a regex var of what should be removed rem = reg(description, removedescription) if rem is not None: removedescription = rem #Regex was succesfull, set removedescription to the found string so it can be removed as normal if removedescription in description: description = description.replace(removedescription, '') #See if we should do something to the description according to the settings stripdescription = settings.find('stripdescription').text if stripdescription == None: stripdescription = '' if len(stripdescription) > 0: #See if there are multiple lines if '|' in stripdescription: strip = stripdescription.split('|') for s in strip: if s in description: description = description[:description.index(s)] #Strip everything to the point where the line was found else: #Check if this is a regex var of what should be removed rem = reg(description, stripdescription) if rem is not None: stripdescription = rem #Regex was succesfull, set stripdescription to the found string so it can be stripped as normal if stripdescription in description: description = description[:description.index(stripdescription)] #Strip everything to the point where the line was found #Grab the best possible thumbnail #if 'maxres' in snippet['thumbnails']: # thumbnail = snippet['thumbnails']['maxres'] if 'standard' in snippet['thumbnails']: thumbnail = snippet['thumbnails']['standard']['url'] elif 'high' in snippet['thumbnails']: thumbnail = snippet['thumbnails']['high']['url'] elif 'medium' in snippet['thumbnails']: thumbnail = snippet['thumbnails']['medium']['url'] elif 'default' in snippet['thumbnails']: thumbnail = snippet['thumbnails']['default']['url'] else: thumbnail = settings.find('thumbnail').text #Grab the published date and convert it to a normal date d = ytube.convert_published(snippet['publishedAt']) normaldate = d['year']+'/'+d['month']+'/'+d['day'] #Convert the duration (seconds) in number of minutes durationminutes = int(int(duration) / 60) durationhms = dev.convert_sec_to_hms(duration) if type == 'musicvideo': if musicvideo == None: return False #Grab the featured artists and convert them to xml featured_xml = '' if musicvideo['featured'] != False: for artist in musicvideo['featured']: featured_xml += '<artist>'+artist.strip(' \t\n\r')+'</artist>' #Grab the tags and convert them to xml tags_xml = '' if musicvideo['tags'] != False: for tag in musicvideo['tags']: tags_xml += '<tag>'+tag.strip(' \t\n\r')+'</tag>' tags = settings.find('tags') if tags is not None: tags = settings.find('tags').text if '/' in tags: multi_tags = tags.split('/') for tag in multi_tags: tags_xml += '<tag>'+tag.strip(' \t\n\r')+'</tag>' elif tags.strip(' \t\n\r') is not '': tags_xml += '<tag>'+tags.strip(' \t\n\r')+'</tag>' genre = musicvideo['genre'] if genre is None: genre = '' #Create the contents of the xml file content = """ <musicvideo> <title>%(title)s</title> <artist>%(artist)s</artist> %(featured)s <album>%(album)s</album> <genre>%(genre)s</genre> <runtime>%(durationminutes)s</runtime> <plot>%(plot)s</plot> <year>%(year)s</year> <director></director> <studio>%(studio)s</studio> <track>%(tracknr)s</track> <thumb>%(thumb)s</thumb> <fanart> <thumb>%(fanart)s</thumb> </fanart> <fileinfo> <streamdetails> <durationinseconds>%(duration)s</durationinseconds> </streamdetails> </fileinfo> %(tags)s </musicvideo> """ % { 'title': musicvideo['title'].strip(' \t\n\r'), 'artist': musicvideo['artist'].strip(' \t\n\r'), 'featured': featured_xml, 'album': musicvideo['album'].strip(' \t\n\r'), 'genre': genre.strip(' \t\n\r'), 'plot': musicvideo['plot'].strip(' \t\n\r'), 'year': musicvideo['year'].strip(' \t\n\r'), 'studio': musicvideo['studio'].strip(' \t\n\r'), 'thumb': thumbnail, 'durationhms': durationhms, 'tracknr': musicvideo['tracknr'].strip(' \t\n\r'), 'fanart': settings.find('fanart').text, 'tags': tags_xml, 'durationminutes': durationminutes, 'duration': duration } else: ##TV #Create the contents of the xml file content = """ <episodedetails> <title>%(title)s</title> <season>%(season)s</season> <episode>%(episode)s</episode> <plot>%(plot)s</plot> <thumb>%(thumb)s</thumb> <credits>%(channel)s</credits> <director>%(channel)s</director> <aired>%(date)s</aired> <premiered>%(date)s</premiered> <studio>Youtube</studio> <runtime>%(durationminutes)s</runtime> <fileinfo> <streamdetails> <durationinseconds>%(duration)s</durationinseconds> </streamdetails> </fileinfo> </episodedetails> """ % { 'title': title.strip(' \t\n\r'), 'plot': description.strip(' \t\n\r'), 'channel': settings.find('channel').text, 'thumb': thumbnail, 'date': normaldate, 'season': season, 'episode': episode, 'durationminutes': durationminutes, 'duration': duration } xbmcvfs.mkdir(movieLibrary) #Create the maindirectory if it does not exists yet #enc_name = name.translate('\/:*?"<>|').strip('.') #Escape special characters in the name enc_name = dev.legal_filename(name) folder = os.path.join(movieLibrary, fold) #Set the folder to the maindir/dir xbmcvfs.mkdir(folder) #Create this subfolder if it does not exist yet stream = os.path.join(folder, enc_name + '.nfo') #Set the file to maindir/name/name.strm file = xbmcvfs.File(stream, 'w') #Open / create this file for writing file.write(str(content.encode("utf-8"))) #Write the content in the file file.close() #Close the file dev.log('write_nfo: Written nfo file: '+fold+'/'+enc_name+'.nfo')