예제 #1
0
def batch_add_tvshows_to_library(library_folder, show):
    id = show['id']
    showname = to_utf8(show['seriesname'])
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if not xbmcvfs.exists(playlist_folder):
        try: xbmcvfs.mkdir(playlist_folder)
        except: dialogs.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists"))
    playlist_file = os.path.join(playlist_folder, id+".xsp")
    if not xbmcvfs.exists(playlist_file):
        playlist_file = xbmcvfs.File(playlist_file, 'w')
        content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, unicode).replace('special://profile',''), str(id))
        playlist_file.write(str(content))
        playlist_file.close()
    show_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(show_folder):
        try: xbmcvfs.mkdir(show_folder)
        except: pass
    player_filepath = os.path.join(show_folder, 'player.info')
    player_file = xbmcvfs.File(player_filepath, 'w')
    content = "default"
    player_file.write(content)
    player_file.close()
    nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
    if not xbmcvfs.exists(nfo_filepath):
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    clean_needed = True
    return clean_needed
예제 #2
0
def add_channel_to_library(library_folder, channel, play_plugin=None):
    changed = False
    # create channel folder
    channel_folder = os.path.join(library_folder, str(channel) + "/")
    if not xbmcvfs.exists(channel_folder):
        try:
            xbmcvfs.mkdir(channel_folder)
        except:
            pass
    # create nfo file
    nfo_filepath = os.path.join(channel_folder, str(channel) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, "w")
        content = "%s" % str(channel)
        nfo_file.write(content)
        nfo_file.close()
    # Create play with file
    if play_plugin is not None:
        player_filepath = os.path.join(channel_folder, "player.info")
        player_file = xbmcvfs.File(player_filepath, "w")
        content = "{0}".format(play_plugin)
        player_file.write(content)
        player_file.close()
    # create strm file
    strm_filepath = os.path.join(channel_folder, str(channel) + ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, "w")
        content = plugin.url_for("live_play", channel=channel, program="None", language="en", mode="library")
        strm_file.write(content)
        strm_file.close()
    return changed
예제 #3
0
 def update_folder(self, details, folder):
     """
     :type details: Details
     :type folder: Folder
     """
     media_path = self.get_media_path(details.section, details.title)
     if not direxists(media_path):
         self.log.info("Creating library folder: %s", media_path)
         xbmcvfs.mkdir(media_path)
     else:
         self.log.info("Updating library folder: %s", media_path)
     self.storage[folder.id] = (details.media_id, media_path, details.section)
     files = folder.files
     """ :type : list of File """
     for f in files:
         file_path = os.path.join(media_path, self.get_file_name(folder.id, f.title))
         if not xbmcvfs.exists(file_path):
             self.log.info("Adding file: %s", file_path)
             fp = xbmcvfs.File(file_path, 'w')
             can_mark_watched = len(files) == 1 and not details.section.is_series()
             url = plugin.url_for('play_file', section=details.section.filter_val,
                                  media_id=details.media_id, url=f.link,
                                  title=f.title, can_mark_watched=int(can_mark_watched))
             fp.write(ensure_str(url))
             fp.close()
     return media_path
예제 #4
0
def library_tv_strm(show, folder, id, season, episode):        
    # Create season folder
    enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
    folder = os.path.join(folder, enc_season)
    try: 
        xbmcvfs.mkdir(folder)
    except: 
        pass
        
    # Create episode strm
    enc_name = 'S%02dE%02d' % (season, episode)
    stream = os.path.join(folder, enc_name + '.strm')
    if not xbmcvfs.exists(stream):
        file = xbmcvfs.File(stream, 'w')
        content = plugin.url_for("tv_play", id=id, season=season, episode=episode, mode='library')
        file.write(str(content))
        file.close()
        
        if plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
            try:
                firstaired = show[season][episode]['firstaired']
                t = date_to_timestamp(firstaired)
                os.utime(stream, (t,t))
            except:
                pass
예제 #5
0
def setup_library(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed as a tv shows source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            try:
                source_thumbnail = get_icon_path("tv")
                source_name = "[COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed " + _(
                    "TV shows")
                source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(
                    library_folder, LANG)
                add_source(source_name, library_folder, source_content,
                           source_thumbnail)
            except:
                pass
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #6
0
파일: live.py 프로젝트: vog31/noobsandnerds
def add_channel_to_library(library_folder, channel, play_plugin = None):
    changed = False
    # create channel folder
    channel_folder = os.path.join(library_folder, str(channel)+'/')
    if not xbmcvfs.exists(channel_folder):
        try: 
            xbmcvfs.mkdir(channel_folder)
        except:
            pass
    # create nfo file
    nfo_filepath = os.path.join(channel_folder, str(channel)+".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        content = "%s" % str(channel)
        nfo_file.write(content)
        nfo_file.close()
    # Create play with file
    if play_plugin is not None:
        player_filepath = os.path.join(channel_folder, 'player.info')
        player_file = xbmcvfs.File(player_filepath, 'w')
        content = "{0}".format(play_plugin)
        player_file.write(content)
        player_file.close()
    # create strm file
    strm_filepath = os.path.join(channel_folder, str(channel)+".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("live_play", channel=channel, program="None", language="en", mode="library")
        strm_file.write(content)
        strm_file.close()
    return changed
예제 #7
0
def library_tv_strm(show, folder, id, season, episode):
    # Create season folder
    enc_season = ('Season %s' % season).translate(None, '\/:*?"<>|').strip('.')
    folder = os.path.join(folder, enc_season)
    try:
        xbmcvfs.mkdir(folder)
    except:
        pass
    # Create episode strm
    enc_name = 'S%02dE%02d' % (season, episode)
    stream = os.path.join(
        folder, enc_name +
        "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + ".strm")
    if not xbmcvfs.exists(stream):
        file = xbmcvfs.File(stream, 'w')
        content = plugin.url_for("tv_play",
                                 id=id,
                                 season=season,
                                 episode=episode,
                                 mode='library')
        file.write(str(content))
        file.close()
        if plugin.get_setting(SETTING_LIBRARY_SET_DATE, bool):
            try:
                firstaired = show[season][episode]['firstaired']
                t = date_to_timestamp(firstaired)
                os.utime(stream, (t, t))
            except:
                pass
예제 #8
0
def batch_add_movies_to_library(library_folder, id):
    if id == None:
        return
    changed = False
    movie_folder = os.path.join(library_folder, str(id) + "/")
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
    nfo_filepath = os.path.join(movie_folder, str(id) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, "w")
        content = "http://www.imdb.com/title/%s/" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    strm_filepath = os.path.join(movie_folder, str(id) + ".strm")
    src = "imdb"
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, "w")
        try:
            content = plugin.url_for("movies_play", src=src, id=id, mode="library")
            strm_file.write(content)
            strm_file.close()
        except:
            pass
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
        xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
예제 #9
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _(
            "Would you like to automatically set [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed as a music source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "[COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed " + _(
                "Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #10
0
파일: movies.py 프로젝트: helloman37/repo
def batch_add_movies_to_library(library_folder, id):
    if id == None:
        return
    changed = False
    movie_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(movie_folder):
        try: xbmcvfs.mkdir(movie_folder)
        except: pass
        player_filepath = os.path.join(movie_folder, 'player.info')
        player_file = xbmcvfs.File(player_filepath, 'w')
        content = "{0}".format(plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode))
        player_file.write(content)
        player_file.close()
    # create nfo file
    nfo_filepath = os.path.join(movie_folder, str(id)+ "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        content = "http://www.imdb.com/title/%s/" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    strm_filepath = os.path.join(movie_folder, str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) + ".strm")
    src = "imdb"
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        try:
            content = plugin.url_for("movies_play", src=src, id=id, mode='library')
            strm_file.write(content)
            strm_file.close()
        except:
            pass
#    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
#    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
예제 #11
0
def auto_tv_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        source_thumbnail = xbmc.translatePath('special://home/addons/plugin.video.meta/resources/img/tv.png')
        source_name = "Meta TVShows"
        source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
        add_source(source_name, library_folder, source_content, source_thumbnail)
예제 #12
0
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        source_thumbnail = 'special://home/addons/plugin.video.meta/resources/img/movies.png'
        source_name = "Meta Movies"
        source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
        add_source(source_name, library_folder, source_content, source_thumbnail)
예제 #13
0
def auto_live_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #14
0
파일: live.py 프로젝트: vog31/noobsandnerds
def auto_live_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #15
0
def playlist_folders_setup():
    movies_playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(movies_playlist_folder):
        xbmcvfs.mkdir(movies_playlist_folder)
    elif xbmcvfs.exists(movies_playlist_folder):
        plugin.notify(msg="Movie playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Movie playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    tv_playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(tv_playlist_folder):
        xbmcvfs.mkdir(tv_playlist_folder)
    elif xbmcvfs.exists(tv_playlist_folder):
        plugin.notify(msg="TVShow playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="TVShow playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    music_playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(music_playlist_folder):
        xbmcvfs.mkdir(music_playlist_folder)
    elif xbmcvfs.exists(music_playlist_folder):
        plugin.notify(msg="Music playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Music playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    live_playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(live_playlist_folder):
        xbmcvfs.mkdir(live_playlist_folder)
    elif xbmcvfs.exists(live_playlist_folder):
        plugin.notify(msg="Live playlist folder", title="Already exists", delay=1000, image=get_icon_path("lists"))
    else:
        plugin.notify(msg="Live playlist folder creation", title="Failed", delay=1000, image=get_icon_path("lists"))
    plugin.notify(msg="Playlists folder creation", title="Completed", delay=1000, image=get_icon_path("lists"))
    return True
예제 #16
0
def auto_tvshows_setup(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except: False
예제 #17
0
def playlist_folders_setup():
    movies_playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(movies_playlist_folder):
        xbmcvfs.mkdir(movies_playlist_folder)
    elif xbmcvfs.exists(movies_playlist_folder):
        plugin.notify(msg='Movie playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Movie playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    tv_playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(tv_playlist_folder):
        xbmcvfs.mkdir(tv_playlist_folder)
    elif xbmcvfs.exists(tv_playlist_folder):
        plugin.notify(msg='TVShow playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='TVShow playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    music_playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(music_playlist_folder):
        xbmcvfs.mkdir(music_playlist_folder)
    elif xbmcvfs.exists(music_playlist_folder):
        plugin.notify(msg='Music playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Music playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    live_playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER)
    if not xbmcvfs.exists(live_playlist_folder):
        xbmcvfs.mkdir(live_playlist_folder)
    elif xbmcvfs.exists(live_playlist_folder):
        plugin.notify(msg='Live playlist folder',
                      title='Already exists',
                      delay=1000,
                      image=get_icon_path("lists"))
    else:
        plugin.notify(msg='Live playlist folder creation',
                      title='Failed',
                      delay=1000,
                      image=get_icon_path("lists"))
    plugin.notify(msg='Playlists folder creation',
                  title='Completed',
                  delay=1000,
                  image=get_icon_path("lists"))
    return True
예제 #18
0
파일: music.py 프로젝트: uguer30/Project
def auto_music_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("musicvideos")
            source_name = "Chappaai "  + _("Music videos")
            source_content = "('{0}','musicvideos','metadata.musicvideos.theaudiodb.com','',2147483647,0,'<settings><setting id=\"fanarttvalbumthumbs\" value=\"true\" /><setting id=\"tadbalbumthumbs\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #19
0
def temp_path():
    path = ensure_path_local(plugin.get_setting('temp-path', unicode))
    if not xbmcvfs.mkdir(path):
        raise LocalizedError(33030,
                             "Invalid temporary path",
                             check_settings=True)
    return path
예제 #20
0
def add_movie_to_library(library_folder, src, id, play_plugin=None):
    changed = False
    # create movie folder
    movie_folder = os.path.join(library_folder, str(id) + '/')
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(movie_folder, 'player.info')
            player_file = xbmcvfs.File(player_filepath, 'w')
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
    # create nfo file
    nfo_filepath = os.path.join(
        movie_folder,
        str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) +
        ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        if src == "imdb":
            content = "http://www.imdb.com/title/%s/" % str(id)
        else:
            content = "http://www.themoviedb.org/movie/%s" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    # create strm file
    strm_filepath = os.path.join(
        movie_folder,
        str(id) + "%s" % plugin.get_setting(SETTING_LIBRARY_TAGS, unicode) +
        ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("movies_play", src=src, id=id, mode='library')
        strm_file.write(content)
        strm_file.close()


#    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
#    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
#    xbmc.executebuiltin("RunScript(script.artworkdownloader,mediatype=movie,dbid=%s)" % xbmc.getInfoLabel('ListItem.DBID'))
    return changed
예제 #21
0
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #22
0
파일: movies.py 프로젝트: helloman37/repo
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(library_folder):
        try:
            if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("movies")
            source_name = "MetalliQ " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #23
0
def setup_library(library_folder):
    if library_folder[-1] != "/": library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a tv shows source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            try:
                source_thumbnail = get_icon_path("tv")
                source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("TV shows")
                source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)
                add_source(source_name, library_folder, source_content, source_thumbnail)
            except: pass
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #24
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        
        # auto configure folder
        msg = _("Would you like to automatically set Meta as a movies video source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta Movies"
            
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,0,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
예제 #25
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        
        # auto configure folder
        msg = _("Would you like to automatically set Meta as a tv shows source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta TVShows"
            
            source_content = "('{0}','tvshows','metadata.tvdb.com','',0,0,'<settings><setting id=\"RatingS\" value=\"TheTVDB\" /><setting id=\"absolutenumber\" value=\"false\" /><setting id=\"dvdorder\" value=\"false\" /><setting id=\"fallback\" value=\"true\" /><setting id=\"fanart\" value=\"true\" /><setting id=\"language\" value=\"{1}\" /></settings>',0,0,NULL,NULL)".format(library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
예제 #26
0
def add_movie_to_library(library_folder, src, id, play_plugin=None):
    changed = False
    # create movie folder
    movie_folder = os.path.join(library_folder, str(id) + "/")
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(movie_folder, "player.info")
            player_file = xbmcvfs.File(player_filepath, "w")
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
    # create nfo file
    nfo_filepath = os.path.join(movie_folder, str(id) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, "w")
        if src == "imdb":
            content = "http://www.imdb.com/title/%s/" % str(id)
        else:
            content = "http://www.themoviedb.org/movie/%s" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    # create strm file
    strm_filepath = os.path.join(movie_folder, str(id) + ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, "w")
        content = plugin.url_for("movies_play", src=src, id=id, mode="library")
        strm_file.write(content)
        strm_file.close()
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
        xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    #    xbmc.executebuiltin("RunScript(script.artworkdownloader,mediatype=movie,dbid=%s)" % xbmc.getInfoLabel('ListItem.DBID'))
    return changed
예제 #27
0
def auto_movie_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
                library_folder, LANG
            )
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #28
0
def auto_music_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         converter=str)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                          converter=str)[-1] != "/":
        playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("music")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _(
                "Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
            return True
        except:
            False
예제 #29
0
파일: live.py 프로젝트: KingPug75/repo
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    chappaai_playlist_folder = "special://home/playlists/mixed/Chappaai/"
    if not xbmcvfs.exists(chappaai_playlist_folder):
        xbmcvfs.mkdir(chappaai_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, unicode)
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set Chappaai as a channel video source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "Chappaai " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #30
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a music source?"
        )
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _(
                "Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(
                library_folder)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #31
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, converter=str)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Movies")
            source_content = '(\'{0}\',\'movies\',\'metadata.themoviedb.org\',\'\',2147483647,1,\'<settings><setting id="RatingS" value="TMDb" /><setting id="certprefix" value="Rated " /><setting id="fanart" value="true" /><setting id="keeporiginaltitle" value="false" /><setting id="language" value="{1}" /><setting id="tmdbcertcountry" value="us" /><setting id="trailer" value="true" /></settings>\',0,0,NULL,NULL)'.format(
                library_folder, LANG
            )
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #32
0
파일: movies.py 프로젝트: uguer30/Project
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    chappaai_playlist_folder = "special://profile/playlists/mixed/Chappaai/"
    if not xbmcvfs.exists(chappaai_playlist_folder):
        xbmcvfs.mkdir(chappaai_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER,
                                         unicode)
    if plugin.get_setting(SETTING_MOVIES_PLAYLIST_FOLDER, unicode)[-1] != "/":
        playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set Chappaai as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("movies")
            source_name = "Chappaai " + _("Movies")
            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,1,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)
            add_source(source_name, library_folder, source_content,
                       source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #33
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"

    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)

        # auto configure folder
        msg = _(
            "Would you like to automatically set Meta as a movies video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_name = "Meta Movies"

            source_content = "('{0}','movies','metadata.themoviedb.org','',2147483647,0,'<settings><setting id=\"RatingS\" value=\"TMDb\" /><setting id=\"certprefix\" value=\"Rated \" /><setting id=\"fanart\" value=\"true\" /><setting id=\"keeporiginaltitle\" value=\"false\" /><setting id=\"language\" value=\"{1}\" /><setting id=\"tmdbcertcountry\" value=\"us\" /><setting id=\"trailer\" value=\"true\" /></settings>',0,0,NULL,NULL)".format(
                library_folder, LANG)

            add_source(source_name, library_folder, source_content)

    # return translated path
    return xbmc.translatePath(library_folder)
예제 #34
0
def add_movie_to_library(library_folder, src, id, date):    
    changed = False
    
    # create movie folder
    movie_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(movie_folder):
        try: 
            xbmcvfs.mkdir(movie_folder)
        except:
            pass

    # create nfo file
    nfo_filepath = os.path.join(movie_folder, str(id)+".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        if src == "imdb":
            content = "http://www.imdb.com/title/%s/" % str(id)
        else:
            content = "http://www.themoviedb.org/movie/%s" % str(id)
        nfo_file.write(content)
        nfo_file.close()
        if date and plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
            os.utime(nfo_filepath, (date,date))
        
    # create strm file
    strm_filepath = os.path.join(movie_folder, str(id)+".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("movies_play", src=src, id=id, mode='library')
        strm_file.write(content)
        strm_file.close()
        if date and plugin.get_setting(SETTING_LIBRARY_SET_DATE, converter=bool):
            os.utime(strm_filepath, (date,date))
    
    return changed    
예제 #35
0
def batch_add_movies_to_library(library_folder, id):
    if id == None:
        return
    changed = False
    movie_folder = os.path.join(library_folder, str(id) + '/')
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
    nfo_filepath = os.path.join(movie_folder, str(id) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, 'w')
        content = "http://www.imdb.com/title/%s/" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    strm_filepath = os.path.join(movie_folder, str(id) + ".strm")
    src = "imdb"
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        try:
            content = plugin.url_for("movies_play",
                                     src=src,
                                     id=id,
                                     mode='library')
            strm_file.write(content)
            strm_file.close()
        except:
            pass
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
        xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
예제 #36
0
def auto_music_setup(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        try:
            xbmcvfs.mkdir(library_folder)
            source_thumbnail = get_icon_path("music")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] "  + _("Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
            return True
        except:
            False
예제 #37
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)
    if plugin.get_setting(SETTING_MUSIC_PLAYLIST_FOLDER, unicode)[-1] != "/": playlist_folder += "/"
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a music source?")
        if dialogs.yesno("{0} {1}".format(_("Library"), "setup"), msg):
            source_thumbnail = get_icon_path("tv")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] "  + _("Music")
            source_content = "('{0}','musicvideos','metadata.musicvideos.imvdb','',2147483647,0,'<settings/>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #38
0
파일: live.py 프로젝트: vog31/noobsandnerds
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder): xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, converter=str)
    # create folders
    if not xbmcvfs.exists(playlist_folder): xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _("Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a channel video source?")
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #39
0
def setup_library(library_folder):
    if library_folder[-1] != "/":
        library_folder += "/"
    metalliq_playlist_folder = "special://profile/playlists/mixed/MetalliQ/"
    if not xbmcvfs.exists(metalliq_playlist_folder):
        xbmcvfs.mkdir(metalliq_playlist_folder)
    playlist_folder = plugin.get_setting(SETTING_LIVE_PLAYLIST_FOLDER, converter=str)
    # create folders
    if not xbmcvfs.exists(playlist_folder):
        xbmcvfs.mkdir(playlist_folder)
    if not xbmcvfs.exists(library_folder):
        # create folder
        xbmcvfs.mkdir(library_folder)
        # auto configure folder
        msg = _(
            "Would you like to automatically set [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] as a channel video source?"
        )
        if dialogs.yesno(_("Library setup"), msg):
            source_thumbnail = get_icon_path("live")
            source_name = "[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] " + _("Channels")
            source_content = "('{0}','','','',0,0,'<settings></settings>',0,0,NULL,NULL)".format(library_folder)
            add_source(source_name, library_folder, source_content, source_thumbnail)
    # return translated path
    return xbmc.translatePath(library_folder)
예제 #40
0
def add_music_to_library(library_folder, artist_name, album_name, track_name):
    # replace non valid path characters with _
    safe_artist_name = to_utf8(re.sub('[^\w\-_\. ]', '_', artist_name))
    safe_album_name = to_utf8(re.sub('[^\w\-_\. ]', '_', album_name))
    safe_track_name = to_utf8(re.sub('[^\w\-_\. ]', '_', track_name))

    changed = False
    artist_info = lastfm.get_artist_info(artist_name)
    album_info = lastfm.get_album_info(artist_name, album_name)
    # create nfo file
    artist_folder = os.path.join(library_folder, safe_artist_name)
    album_folder = os.path.join(artist_folder, safe_album_name)
    if not xbmcvfs.exists(artist_folder):
        xbmcvfs.mkdir(artist_folder)
    if not xbmcvfs.exists(album_folder):
        xbmcvfs.mkdir(album_folder)
    nfo_artist_path = os.path.join(artist_folder, "artist.nfo")
    nfo_album_path = os.path.join(album_folder, "album.nfo")
    track_info = lastfm.get_track_info(artist_name, track_name)
    track_number = ""
    if "album" in track_info:
        track_number = track_info["album"]["@attr"]["position"]
        if track_number != "" and track_number != None:
            full_track_name = track_number + ". " + safe_track_name
        else:
            full_track_name = safe_track_name
    else:
        full_track_name = safe_track_name
    nfo_track_path = os.path.join(album_folder, full_track_name + ".nfo")
    if not xbmcvfs.exists(nfo_artist_path):
        changed = True
        image = artist_info["image"][-1]["#text"]
        nfo_file = xbmcvfs.File(nfo_artist_path, 'w')
        content = "<artist>\n" \
                  "  <name>{0}</name>\n" \
                  "  <thumb>{1}</thumb>\n" \
                  "</artist>".format(artist_name, image)
        nfo_file.write(content)
        nfo_file.close()

    if not xbmcvfs.exists(nfo_album_path):
        changed = True
        image = album_info["image"][-1]["#text"]
        nfo_file = xbmcvfs.File(nfo_album_path, 'w')
        content = "<album>\n" \
                  "  <title>{0}</title>\n" \
                  "  <artist>{1}</artist>\n" \
                  "  <thumb>{2}</thumb>\n" \
                  "</album>".format(album_name, artist_name, image)
        nfo_file.write(content)
        nfo_file.close()

    if not xbmcvfs.exists(nfo_track_path):
        changed = True
        track_info = lastfm.get_track_info(artist_name, track_name)
        track_number = ""
        if "album" in track_info:
            track_number = track_info["album"]["@attr"]["position"]
        nfo_file = xbmcvfs.File(nfo_track_path, 'w')
        content = "<musicvideo>\n" \
                  "  <title>{0}</title>\n" \
                  "  <artist>{1}</artist>\n" \
                  "  <album>{2}</album>\n" \
                  "  <track>{3}</track>\n" \
                  "</musicvideo>".format(to_utf8(track_name),
                                         artist_name,
                                         album_name,
                                         track_number)
        nfo_file.write(content)
        nfo_file.close()

    # create strm file
    strm_filepath = os.path.join(album_folder, full_track_name + ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        track_info = lastfm.get_track_info(artist_name, track_name)
        track_number = ""
        if "album" in track_info:
            track_number = track_info["album"]["@attr"]["position"]
            strm_filepath = os.path.join(
                album_folder, track_number + ". " + safe_track_name + ".strm")
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("music_play",
                                 artist_name=artist_name,
                                 track_name=track_name,
                                 album_name=album_name,
                                 mode='library')
        strm_file.write(content)
        strm_file.close()
    # create thumbnails
    thumb_album_path = os.path.join(artist_folder, "folder.jpg")
    if not xbmcvfs.exists(thumb_album_path):
        changed = True
        r = requests.get(artist_info["image"][-1]["#text"], stream=True)
        if r.status_code == 200:
            try:
                with open(thumb_album_path, 'wb') as f:
                    r.raw.decode_content = True
                    shutil.copyfileobj(r.raw, f)
            except:
                pass
    thumb_album_path = os.path.join(album_folder, "folder.jpg")
    if not xbmcvfs.exists(thumb_album_path):
        changed = True
        try:
            r = requests.get(album_info["image"][-1]["#text"], stream=True)
            if r.status_code == 200:
                with open(thumb_album_path, 'wb') as f:
                    r.raw.decode_content = True
                    shutil.copyfileobj(r.raw, f)
        except:
            pass
    return changed
예제 #41
0
def add_music_to_library(library_folder, artist_name, album_name, track_name):
    # replace non valid path characters with _
    safe_artist_name = to_utf8(re.sub('[^\w\-_\. ]', '_', artist_name))
    safe_album_name = to_utf8(re.sub('[^\w\-_\. ]', '_', album_name))
    safe_track_name = to_utf8(re.sub('[^\w\-_\. ]', '_', track_name))

    changed = False
    artist_info = lastfm.get_artist_info(artist_name)
    album_info = lastfm.get_album_info(artist_name, album_name)
    # create nfo file
    artist_folder = os.path.join(library_folder, safe_artist_name)
    album_folder = os.path.join(artist_folder, safe_album_name)
    if not xbmcvfs.exists(artist_folder):
        xbmcvfs.mkdir(artist_folder)
    if not xbmcvfs.exists(album_folder):
        xbmcvfs.mkdir(album_folder)
    nfo_artist_path = os.path.join(artist_folder, "artist.nfo")
    nfo_album_path = os.path.join(album_folder, "album.nfo")
    track_info = lastfm.get_track_info(artist_name, track_name)
    track_number = ""
    if "album" in track_info:
        track_number = track_info["album"]["@attr"]["position"]
        if track_number != "" and track_number != None: full_track_name = track_number + ". " + safe_track_name
        else: full_track_name = safe_track_name
    else: full_track_name = safe_track_name
    nfo_track_path = os.path.join(album_folder, full_track_name + ".nfo")
    if not xbmcvfs.exists(nfo_artist_path):
        changed = True
        image = artist_info["image"][-1]["#text"]
        nfo_file = xbmcvfs.File(nfo_artist_path, 'w')
        content = "<artist>\n" \
                  "  <name>{0}</name>\n" \
                  "  <thumb>{1}</thumb>\n" \
                  "</artist>".format(artist_name, image)
        nfo_file.write(content)
        nfo_file.close()

    if not xbmcvfs.exists(nfo_album_path):
        changed = True
        image = album_info["image"][-1]["#text"]
        nfo_file = xbmcvfs.File(nfo_album_path, 'w')
        content = "<album>\n" \
                  "  <title>{0}</title>\n" \
                  "  <artist>{1}</artist>\n" \
                  "  <thumb>{2}</thumb>\n" \
                  "</album>".format(album_name, artist_name, image)
        nfo_file.write(content)
        nfo_file.close()

    if not xbmcvfs.exists(nfo_track_path):
        changed = True
        track_info = lastfm.get_track_info(artist_name, track_name)
        track_number = ""
        if "album" in track_info:
            track_number = track_info["album"]["@attr"]["position"]
        nfo_file = xbmcvfs.File(nfo_track_path, 'w')
        content = "<musicvideo>\n" \
                  "  <title>{0}</title>\n" \
                  "  <artist>{1}</artist>\n" \
                  "  <album>{2}</album>\n" \
                  "  <track>{3}</track>\n" \
                  "</musicvideo>".format(to_utf8(track_name),
                                         artist_name,
                                         album_name,
                                         track_number)
        nfo_file.write(content)
        nfo_file.close()

    # create strm file
    strm_filepath = os.path.join(album_folder, full_track_name + ".strm")
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        track_info = lastfm.get_track_info(artist_name, track_name)
        track_number = ""
        if "album" in track_info:
            track_number = track_info["album"]["@attr"]["position"]
            strm_filepath = os.path.join(album_folder, track_number + ". " + safe_track_name + ".strm")
        strm_file = xbmcvfs.File(strm_filepath, 'w')
        content = plugin.url_for("music_play", artist_name=artist_name, track_name=track_name,
                                 album_name=album_name, mode='library')
        strm_file.write(content)
        strm_file.close()
    # create thumbnails
    thumb_album_path = os.path.join(artist_folder, "folder.jpg")
    if not xbmcvfs.exists(thumb_album_path):
            changed = True
            r = requests.get(artist_info["image"][-1]["#text"], stream=True)
            if r.status_code == 200:
                try:
                    with open(thumb_album_path, 'wb') as f:
                        r.raw.decode_content = True
                        shutil.copyfileobj(r.raw, f)
                except:
                    pass
    thumb_album_path = os.path.join(album_folder, "folder.jpg")
    if not xbmcvfs.exists(thumb_album_path):
            changed = True
            try:
                r = requests.get(album_info["image"][-1]["#text"], stream=True)
                if r.status_code == 200:
                    with open(thumb_album_path, 'wb') as f:
                        r.raw.decode_content = True
                        shutil.copyfileobj(r.raw, f)
            except:
                pass
    return changed
예제 #42
0
def temp_path():
    path = ensure_path_local(plugin.get_setting('temp-path', unicode))
    if not xbmcvfs.mkdir(path):
        raise LocalizedError(33030, "Invalid temporary path", check_settings=True)
    return path
예제 #43
0
def add_tvshow_to_library(library_folder, show, play_plugin = None):
    clean_needed = False
    id = show['id']
    showname = to_utf8(show['seriesname'])
    if showname == "None" or showname == None:
        show_folder = os.path.join(library_folder, str(id)+'/')
        if os.path.isdir(show_folder): return shutil.rmtree(show_folder)
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if not xbmcvfs.exists(playlist_folder):
        try: xbmcvfs.mkdir(playlist_folder)
        except: dialogs.notify(msg=_('Creation of [COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR] Playlist Folder'), title=_('Failed'), delay=5000, image=get_icon_path("lists"))
    playlist_file = os.path.join(playlist_folder, id+".xsp")
    if not xbmcvfs.exists(playlist_file):
        playlist_file = xbmcvfs.File(playlist_file, 'w')
        content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (showname, plugin.get_setting(SETTING_TV_LIBRARY_FOLDER, str).replace('special://profile',''), str(id))
        playlist_file.write(str(content))
        playlist_file.close()
    ## Create show folder
    enc_show = showname.translate(None, '\/:*?"<>|').strip('.')
    show_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(show_folder):
        try:
            xbmcvfs.mkdir(show_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(show_folder, 'player.info')
            player_file = xbmcvfs.File(player_filepath, 'w')
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
        # Create nfo file
        nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
        if not xbmcvfs.exists(nfo_filepath):
            nfo_file = xbmcvfs.File(nfo_filepath, 'w')
            content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
            nfo_file.write(content)
            nfo_file.close()
    ## Get existing items in library
    # get all ids of the show
    ids = [id, show.get('imdb_id', None)]   # TODO: add tmdb!
    ids = [x for x in ids if x]
    # get show episodes in library
    try:
        # get tvshow from library
        libshows = RPC.VideoLibrary.GetTVShows(properties=["imdbnumber", "title", "year"])['tvshows']
        libshows = [i for i in libshows if str(i['imdbnumber']) in ids or (str(i['year']) == str(show.get('year', 0)) and equals(show['seriesname'], i['title']))]
        libshow = libshows[0]
        # get existing (non strm) episodes in library
        libepisodes = RPC.VideoLibrary.GetEpisodes(filter={"and": [ {"field": "tvshow", "operator": "is", "value": to_utf8(libshow['title'])}]}, properties=["season", "episode", "file"])['episodes']
        libepisodes = [(int(i['season']), int(i['episode'])) for i in libepisodes if not i['file'].endswith(".strm")]
    except: libepisodes = []
    ## Create content strm files
    for (season_num,season) in show.items():
        if season_num == 0 and not plugin.get_setting(SETTING_INCLUDE_SPECIALS, bool): continue
        if not season.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): continue
        for (episode_num, episode) in season.items():
            if not season_num == 0 and not episode.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): continue
            delete = False
            if not episode.has_aired(flexible=plugin.get_setting(SETTING_AIRED_UNKNOWN, bool)): delete = True
            if delete or (season_num, episode_num) in libepisodes:
                if library_tv_remove_strm(show, show_folder, id, season_num, episode_num): clean_needed = True
            else: library_tv_strm(show, show_folder, id, season_num, episode_num)
    files, dirs = xbmcvfs.listdir(show_folder)
    if not dirs:
        shutil.rmtree(show_folder)
        clean_needed = True
#    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
#    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return clean_needed
예제 #44
0
def add_tvshow_to_library(library_folder, show, play_plugin=None):
    clean_needed = False
    id = show['id']
    showname = to_utf8(show['seriesname'])
    if showname == "None" or showname == None:
        show_folder = os.path.join(library_folder, str(id) + '/')
        if os.path.isdir(show_folder): return shutil.rmtree(show_folder)
    playlist_folder = plugin.get_setting(SETTING_TV_PLAYLIST_FOLDER, unicode)
    if not xbmcvfs.exists(playlist_folder):
        try:
            xbmcvfs.mkdir(playlist_folder)
        except:
            dialogs.notify(msg=_(
                'Creation of [COLOR limegreen]M[/COLOR]etalli[COLOR limegreen]Q[/COLOR] 4[COLOR limegreen]Q[/COLOR]ed Playlist Folder'
            ),
                           title=_('Failed'),
                           delay=5000,
                           image=get_icon_path("lists"))
    playlist_file = os.path.join(playlist_folder, id + ".xsp")
    if not xbmcvfs.exists(playlist_file):
        playlist_file = xbmcvfs.File(playlist_file, 'w')
        content = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><smartplaylist type="tvshows"><name>%s</name><match>all</match><rule field="path" operator="contains"><value>%s%s</value></rule><rule field="playcount" operator="is"><value>0</value></rule><order direction="ascending">numepisodes</order></smartplaylist>' % (
            showname, plugin.get_setting(
                SETTING_TV_LIBRARY_FOLDER, str).replace(
                    'special://profile', ''), str(id))
        playlist_file.write(str(content))
        playlist_file.close()
    ## Create show folder
    enc_show = showname.translate(None, '\/:*?"<>|').strip('.')
    show_folder = os.path.join(library_folder, str(id) + '/')
    if not xbmcvfs.exists(show_folder):
        try:
            xbmcvfs.mkdir(show_folder)
        except:
            pass
        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(show_folder, 'player.info')
            player_file = xbmcvfs.File(player_filepath, 'w')
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
        # Create nfo file
        nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
        if not xbmcvfs.exists(nfo_filepath):
            nfo_file = xbmcvfs.File(nfo_filepath, 'w')
            content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
            nfo_file.write(content)
            nfo_file.close()
    ## Get existing items in library
    # get all ids of the show
    ids = [id, show.get('imdb_id', None)]  # TODO: add tmdb!
    ids = [x for x in ids if x]
    # get show episodes in library
    try:
        # get tvshow from library
        libshows = RPC.VideoLibrary.GetTVShows(
            properties=["imdbnumber", "title", "year"])['tvshows']
        libshows = [
            i for i in libshows if str(i['imdbnumber']) in ids or (
                str(i['year']) == str(show.get('year', 0))
                and equals(show['seriesname'], i['title']))
        ]
        libshow = libshows[0]
        # get existing (non strm) episodes in library
        libepisodes = RPC.VideoLibrary.GetEpisodes(
            filter={
                "and": [{
                    "field": "tvshow",
                    "operator": "is",
                    "value": to_utf8(libshow['title'])
                }]
            },
            properties=["season", "episode", "file"])['episodes']
        libepisodes = [(int(i['season']), int(i['episode']))
                       for i in libepisodes if not i['file'].endswith(".strm")]
    except:
        libepisodes = []
    ## Create content strm files
    for (season_num, season) in show.items():
        if season_num == 0:  # or not season.has_aired():
            continue
        for (episode_num, episode) in season.items():
            if episode_num == 0:
                continue
            delete = False
            if plugin.get_setting(SETTING_AIRED_UNKNOWN, bool) == True:
                aired_unknown = True
            else:
                aired_unknown = False
            if not episode.has_aired(flexible=aired_unknown):
                delete = True
                #break
            if delete or (season_num, episode_num) in libepisodes:
                if library_tv_remove_strm(show, show_folder, id, season_num,
                                          episode_num):
                    clean_needed = True
            else:
                library_tv_strm(show, show_folder, id, season_num, episode_num)
    files, dirs = xbmcvfs.listdir(show_folder)
    if not dirs:
        shutil.rmtree(show_folder)
        clean_needed = True


#    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"): xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
#    elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"): xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return clean_needed
예제 #45
0
def add_tvshow_to_library(library_folder, show, play_plugin = None):
    clean_needed = False
    
    id = show['id']
    showname = to_utf8(show['seriesname'])

    ## Create show folder
    enc_show = showname.translate(None, '\/:*?"<>|').strip('.')
    show_folder = os.path.join(library_folder, str(id)+'/')
    if not xbmcvfs.exists(show_folder):
        try: 
            xbmcvfs.mkdir(show_folder)
        except:
            pass

        # Create play with file
        if play_plugin is not None:
            player_filepath = os.path.join(show_folder, 'player.info')
            player_file = xbmcvfs.File(player_filepath, 'w')
            content = "{0}".format(play_plugin)
            player_file.write(content)
            player_file.close()
            
        # Create nfo file
        nfo_filepath = os.path.join(show_folder, 'tvshow.nfo')
        if not xbmcvfs.exists(nfo_filepath):
            nfo_file = xbmcvfs.File(nfo_filepath, 'w')
            content = "http://thetvdb.com/index.php?tab=series&id=%s" % str(id)
            nfo_file.write(content)
            nfo_file.close()

    ## Get existing items in library
    
    # get all ids of the show
    ids = [id, show.get('imdb_id', None)]   # TODO: add tmdb!
    ids = [x for x in ids if x]

    # get show episodes in library
    try:
#        if not plugin.get_setting(SETTING_CHECK_LIBRARY_DUPS, converter=bool):
#            raise Exception()

        # get tvshow from library
        libshows = RPC.VideoLibrary.GetTVShows(properties=["imdbnumber", "title", "year"])['tvshows']
        libshows = [i for i in libshows if str(i['imdbnumber']) in ids or (str(i['year']) == str(show.get('year', 0)) and equals(show['seriesname'], i['title']))]
        libshow = libshows[0]
        
        # get existing (non strm) episodes in library
        libepisodes = RPC.VideoLibrary.GetEpisodes(filter={"and": [ {"field": "tvshow", "operator": "is", "value": to_utf8(libshow['title'])}]}, properties=["season", "episode", "file"])['episodes']
        libepisodes = [(int(i['season']), int(i['episode'])) for i in libepisodes if not i['file'].endswith(".strm")]
    except:
        libepisodes = []
    
    ## Create content strm files
    for (season_num,season) in show.items():
        if season_num == 0: # or not season.has_aired():
            continue
            
        for (episode_num, episode) in season.items():
            if episode_num == 0:
                continue
            
            delete = False
            if not episode.has_aired(flexible=True):
                delete = True
                #break
            
            if delete or (season_num, episode_num) in libepisodes:
                if library_tv_remove_strm(show, show_folder, id, season_num, episode_num):
                    clean_needed = True
            else:
                library_tv_strm(show, show_folder, id, season_num, episode_num)

    files, dirs = xbmcvfs.listdir(show_folder)
    if not dirs:
        shutil.rmtree(show_folder)
        clean_needed = True
                
    return clean_needed