Ejemplo n.º 1
0
def showParentContent(params):
    log.debug("showParentContent Called: {0}", params)

    parentId = params.get("ParentId")

    contentUrl = ("{server}/emby/Users/{userid}/items?ParentId=" + parentId +
                  "&IsVirtualUnaired=false" + "&IsMissing=False" +
                  "&ImageTypeLimit=1" + "&Fields={field_filters}" +
                  "&format=json")

    log.debug("showParentContent Content Url: {0}", contentUrl)
    getContent(contentUrl, params)
Ejemplo n.º 2
0
def showContent(pluginName, handle, params):
    log.debug("showContent Called: {0}", params)

    item_type = params.get("item_type")
    settings = xbmcaddon.Addon()
    group_movies = settings.getSetting('group_movies') == "true"

    if item_type.lower().find("movie") == -1:
        group_movies = False

    contentUrl = ("{server}/emby/Users/{userid}/Items"
                  "?format=json" + "&ImageTypeLimit=1" + "&IsMissing=False" +
                  "&Fields={field_filters}" + '&CollapseBoxSetItems=' +
                  str(group_movies) + '&GroupItemsIntoCollections=' +
                  str(group_movies) + "&Recursive=true" +
                  "&IsVirtualUnaired=false" + "&IncludeItemTypes=" + item_type)

    log.debug("showContent Content Url: {0}", contentUrl)
    getContent(contentUrl, params)
Ejemplo n.º 3
0
def mainEntryPoint():
    log.debug("===== JellyfinCon START =====")

    settings = xbmcaddon.Addon()
    profile_code = settings.getSetting('profile') == "true"
    pr = None
    if profile_code:
        return_value = xbmcgui.Dialog().yesno("Profiling Enabled",
                                              "Do you want to run profiling?")
        if return_value:
            pr = cProfile.Profile()
            pr.enable()

    log.debug("Running Python: {0}", sys.version_info)
    log.debug("Running JellyfinCon: {0}", ClientInformation().getVersion())
    log.debug("Kodi BuildVersion: {0}",
              xbmc.getInfoLabel("System.BuildVersion"))
    log.debug("Kodi Version: {0}", kodi_version)
    log.debug("Script argument data: {0}", sys.argv)

    try:
        params = get_params(sys.argv[2])
    except:
        params = {}

    home_window = HomeWindow()

    if len(params) == 0:
        window_params = home_window.getProperty("Params")
        log.debug("windowParams: {0}", window_params)
        # home_window.clearProperty("Params")
        if window_params:
            try:
                params = get_params(window_params)
            except:
                params = {}

    log.debug("Script params: {0}", params)

    param_url = params.get('url', None)

    if param_url:
        param_url = urllib.unquote(param_url)

    mode = params.get("mode", None)

    if mode == "CHANGE_USER":
        checkServer(change_user=True, notify=False)
    elif mode == "CACHE_ARTWORK":
        CacheArtwork().cache_artwork_interactive()
    elif mode == "DETECT_SERVER":
        checkServer(force=True, notify=True)
    elif mode == "DETECT_SERVER_USER":
        checkServer(force=True, change_user=True, notify=False)
    elif mode == "playTrailer":
        item_id = params["id"]
        playTrailer(item_id)
    elif mode == "MOVIE_ALPHA":
        showMovieAlphaList()
    elif mode == "GENRES":
        showGenreList(params)
    elif mode == "MOVIE_PAGES":
        showMoviePages(params)
    elif mode == "WIDGETS":
        showWidgets()
    elif mode == "TOGGLE_WATCHED":
        toggle_watched(params)
    elif mode == "SHOW_MENU":
        show_menu(params)
    elif mode == "SHOW_SETTINGS":
        __addon__.openSettings()
        WINDOW = xbmcgui.getCurrentWindowId()
        if WINDOW == 10000:
            log.debug(
                "Currently in home - refreshing to allow new settings to be taken"
            )
            xbmc.executebuiltin("ActivateWindow(Home)")
    elif mode == "WIDGET_CONTENT":
        getWidgetContent(int(sys.argv[1]), params)
    elif mode == "WIDGET_CONTENT_CAST":
        get_widget_content_cast(int(sys.argv[1]), params)
    #elif mode == "WIDGET_CONTENT_URL":
    #    getWidgetUrlContent(int(sys.argv[1]), params)
    elif mode == "PARENT_CONTENT":
        checkServer(notify=False)
        showParentContent(params)
    elif mode == "SHOW_CONTENT":
        # plugin://plugin.video.jellyfincon?mode=SHOW_CONTENT&item_type=Movie|Series
        checkServer(notify=False)
        showContent(sys.argv[0], int(sys.argv[1]), params)
    elif mode == "SEARCH":
        # plugin://plugin.video.jellyfincon?mode=SEARCH
        checkServer(notify=False)
        xbmcplugin.setContent(int(sys.argv[1]), 'files')
        show_search()
    elif mode == "NEW_SEARCH":
        checkServer(notify=False)
        search_results(params)
    elif mode == "NEW_SEARCH_PERSON":
        checkServer(notify=False)
        search_results_person(params)
    elif mode == "SHOW_SERVER_SESSIONS":
        checkServer(notify=False)
        showServerSessions()
    elif mode == "TRAKTTOKODI":
        checkServer(notify=False)
        trakttokodi.entry_point(params)
    else:
        checkServer(notify=False)
        log.debug("JellyfinCon -> Mode: {0}", mode)
        log.debug("JellyfinCon -> URL: {0}", param_url)

        if mode == "GET_CONTENT":
            getContent(param_url, params)
        elif mode == "PLAY":
            PLAY(params)
        else:
            displaySections()

    if (pr):
        pr.disable()

        fileTimeStamp = time.strftime("%Y%m%d-%H%M%S")
        tabFileName = __addondir__ + "profile(" + fileTimeStamp + ").txt"
        s = StringIO.StringIO()
        ps = pstats.Stats(pr, stream=s)
        ps = ps.sort_stats('cumulative')
        ps.print_stats()
        ps.strip_dirs()
        ps = ps.sort_stats('tottime')
        ps.print_stats()
        with open(tabFileName, 'wb') as f:
            f.write(s.getvalue())

    log.debug("===== JellyfinCon FINISHED =====")