def apply_basic_settings(self):
        global SCENES
        scenenames = SCENES.keys()
        labels = map(lambda x:x.lower(),scenenames)
        # Get the bridges
        self.bridge = LimitlessBridge(__addon__.getSetting("b0_host"),__addon__.getSetting("b0_port"))

        # Get the scenes
        #labels     =["normal","dimmed","reading","movie","tv","music"]
        #scenenames = ["Normal","Dimmed","Reading","Movie","TV","Music"]
        for label,scenename in zip (labels,scenenames):
            scene = LimitlessScene(scenename,0,False)
            for i in ("0","1","2","3","4"):
                enabled=utils.get_bool_setting("b0_l"+i+"_"+label+"_enable")
                if enabled:
                    color       = utils.get_setting("b0_l"+i+"_"+label+"_color")
                    brightness  = utils.get_setting("b0_l"+i+"_"+label+"_brightness")
                    light       = LimitlessLight(self.bridge,'rgbw',i,True,color,brightness)
                    utils.log_verbose("Settings: label: " + label + " scenename: " + scenename + " lights: " + str(light))
                    scene.addLight(light)
            SCENES[scenename] = scene
        for activity in ACTIVITIES.keys():
            # map activity to scenes
            activity_scene = utils.get_setting("activity_"+activity)
            ACTIVITIES[activity] = activity_scene
        utils.log_verbose("Enabled: " + utils.get_setting("activity_enable"))
        return True
Beispiel #2
0
    def apply_basic_settings(self):        
        self.check_interval = utils.get_int_setting('check_interval')

        user = utils.get_setting('username')
        password = utils.get_setting('password')
        host = utils.get_setting('host')
        port = utils.get_int_setting('port')

        if not host:
            utils.log_normal("No host specified")
            return False

        invalid = utils.invalid_user_char(user)
        if invalid:
            utils.log_error("Invalid character in user name: " + invalid)
            return False

        invalid = utils.invalid_password_char(password)
        if invalid:
            utils.log_error("Invalid character in password: " + invalid)
            return False

        self.camera = foscam.Camera(host, port, user, password)
        success, msg = self.camera.test()
        if not success:
            utils.log_error(msg)
            return False

        return True
Beispiel #3
0
    def check_db_integrity(self):
        library_enable = utils.get_setting("lib_export_enabled")
        kodi_export = utils.get_setting("lib_export_kodi_library")
        if not library_enable or not kodi_export:
            self.__remove_folder_database(self.movies_folder)
            self.__remove_folder_database(self.tvshows_folder)
            return

        movies_enabled = utils.get_setting("lib_export_movies")
        tvshows_enabled = utils.get_setting("lib_export_tvshows")
        if library_enable and kodi_export:
            # movies
            movies_db, movies_path_id = self.__check_database(
                self.movies_folder)
            if movies_enabled and not movies_db:
                self.__insert_folder_database(self.movies_folder)
            elif not movies_enabled and movies_db:
                self.__remove_folder_database_by_path_id(movies_path_id)

            # tvshows
            tvshows_db, tvshows_path_id = self.__check_database(
                self.tvshows_folder)
            if tvshows_enabled and not tvshows_db:
                self.__insert_folder_database(self.tvshows_folder)
            elif not tvshows_enabled and tvshows_db:
                self.__remove_folder_database_by_path_id(tvshows_path_id)
        self.__run_update_library()
        self.__run_cleanup()
Beispiel #4
0
    def apply_basic_settings(self):
        self.check_interval = utils.get_int_setting('check_interval')

        user = utils.get_setting('username')
        password = utils.get_setting('password')
        host = utils.get_setting('host')
        port = utils.get_int_setting('port')

        if not host:
            utils.log_normal("No host specified")
            return False

        invalid = utils.invalid_user_char(user)
        if invalid:
            utils.log_error("Invalid character in user name: " + invalid)
            return False

        invalid = utils.invalid_password_char(password)
        if invalid:
            utils.log_error("Invalid character in password: " + invalid)
            return False

        self.camera = foscam.Camera(host, port, user, password)
        success, msg = self.camera.test()
        if not success:
            utils.log_error(msg)
            return False

        return True
 def set_custom_view(self, content):
     if utils.get_setting("custom_view_enabled"):
         if utils.get_setting("custom_skin_enabled"):
             view_id = utils.get_setting("view_skin_" + content)
         else:
             view = utils.get_setting('view_' + content)
             view_id = self.get_view_id(view, content)
         xbmc.executebuiltin('Container.SetViewMode(%s)' % str(view_id))
 def __init__(self,scenename):
     utils.log_normal("Applying Scene: " + scenename)
     self.bridge = LimitlessBridge(addon.getSetting("b0_host"),addon.getSetting("b0_port"))
     scene = LimitlessScene(scenename,0,False)
     for i in ("0","1","2","3","4"):
         lowerscenename = scenename.lower()
         enabled=utils.get_bool_setting("b0_l"+i+"_"+lowerscenename+"_enable")
         if enabled:
             color       = utils.get_setting("b0_l"+i+"_"+lowerscenename+"_color")
             brightness  = utils.get_setting("b0_l"+i+"_"+lowerscenename+"_brightness")
             light       = LimitlessLight(self.bridge,'rgbw',i,True,color,brightness)
             utils.log_verbose("Settings: label: " + lowerscenename + " scenename: " + scenename + " lights: " + str(light))
             scene.addLight(light)
     self.bridge.applyScene(scene)
    def increase_play_video_count(self):
        show_donation_enabled = utils.get_setting("timvision_show_donation",
                                                  "true")
        play_video_count = int(utils.get_setting("timvision_start_count", "0"))
        pause_video = False
        if show_donation_enabled:
            if play_video_count > 0 and play_video_count % 100 == 0:
                dialog_title = utils.get_local_string(30064)
                dialog_message = utils.get_local_string(30065)
                if Dialogs.ask(dialog_message, dialog_title):
                    pause_video = self.open_donation_page()

        play_video_count = play_video_count + 1
        utils.set_setting("timvision_start_count", str(play_video_count))
        return pause_video
Beispiel #8
0
    def apply_other_settings(self):            
        self.motion_enable = utils.get_bool_setting('motion_enable')
        self.sound_enable = utils.get_bool_setting('sound_enable')

        self.duration = utils.get_int_setting('preview_duration')
        self.scaling = utils.get_float_setting('preview_scaling')
        self.position = utils.get_setting('preview_position').lower()

        motion_trigger_interval = utils.get_int_setting('motion_trigger_interval')
        sound_trigger_interval = utils.get_int_setting('sound_trigger_interval')
        
        if self.motion_enable and self.sound_enable:
            self.trigger_interval = min(motion_trigger_interval, sound_trigger_interval)
        elif self.motion_enable:
            self.trigger_interval = motion_trigger_interval
        elif self.sound_enable:
            self.trigger_interval = sound_trigger_interval
        
        if self.motion_enable:
            command = self.camera.set_motion_detect_config()
            command['isEnable'] = 1
            command['sensitivity'] = utils.get_int_setting('motion_sensitivity')
            command['triggerInterval'] = motion_trigger_interval
            self.send_command(command)
            
        if self.sound_enable:
            command = self.camera.set_sound_detect_config()
            command['isEnable'] = 1
            command['sensitivity'] = utils.get_int_setting('sound_sensitivity')
            command['triggerInterval'] = sound_trigger_interval
            
            for iday in range(7):
                command['schedule{0:d}'.format(iday)] = 2**48 - 1
            self.send_command(command)
 def get_license_info(self, content_id, video_type, has_hd=False):
     cp_id, mpd = self.get_mpd_file(content_id, video_type)
     if cp_id != None:
         asset_id_wd = TimVisionSession.get_asset_id_wd(mpd)
         if has_hd and utils.get_setting("prefer_hd"):
             mpd = mpd.replace("_SD", "_HD")
         wv_url = self.widevine_proxy_url.replace(
             "{ContentIdAVS}",
             content_id).replace("{AssetIdWD}", asset_id_wd).replace(
                 "{CpId}", cp_id).replace("{Type}", "VOD").replace(
                     "{ClientTime}", str(long(time.time() * 1000))).replace(
                         "{Channel}", SERVICE_CHANNEL).replace(
                             "{DeviceType}",
                             "CHROME").replace('http://', 'https://')
         '''
         major_version, _ = utils.get_kodi_version()
         if major_version < 18:
             wv_url = utils.url_join(utils.get_service_url(), "?action=get_license&license_url=%s" % (urllib.quote(wv_url)))
         '''
         return {
             "mpd_file": mpd,
             "avs_cookie": self.avs_cookie,
             "widevine_url": wv_url
         }
     return None
 def login(self, username, password):
     deviceId = utils.get_setting("timvision_device_id")
     if deviceId == None or len(deviceId) < 38:
         deviceId = self.__random_device_id()
         utils.set_setting("timvision_device_id", deviceId)
     data = {
         'username':
         username,
         'password':
         password,
         'customData':
         '{"customData":[{"name":"deviceType","value":' + DEVICE_TYPE +
         '},{"name":"deviceVendor","value":""},{"name":"accountDeviceModel","value":""},{"name":"FirmwareVersion","value":""},{"name":"Loader","value":""},{"name":"ResidentApp","value":""},{"name":"DeviceLanguage","value":"it"},{"name":"NetworkType","value":""},{"name":"DisplayDimension","value":""},{"name":"OSversion","value":"Windows 10"},{"name":"AppVersion","value":""},{"name":"DeviceRooted","value":""},{"name":"NetworkOperatoreName","value":""},{"name":"ServiceOperatorName","value":""},{"name":"Custom1","value":"Firefox"},{"name":"Custom2","value":54},{"name":"Custom3","value":"1920x1080"},{"name":"Custom4","value":"PC"},{"name":"Custom5","value":""},{"name":"Custom6","value":""},{"name":"Custom7","value":""},{"name":"Custom8","value":""},{"name":"Custom9","value":""}]}'
     }
     url = "/besc?action=Login&channel={channel}&providerName={providerName}&serviceName={serviceName}&deviceType={deviceType}&accountDeviceId=%s" % (
         deviceId)
     response = self.send_request(url=url,
                                  base_url=self.BASE_URL_AVS,
                                  method="POST",
                                  data=data)
     if response != None:
         self.api_endpoint.headers.__setitem__(self.user_http_header,
                                               response["resultObj"])
         self.session_login_hash = response["extObject"]["hash"]
         self.avs_cookie = self.api_endpoint.cookies.get("avs_cookie")
         self.license_endpoint.headers.__setitem__('AVS_COOKIE',
                                                   self.avs_cookie)
         self.stop_check_session = threading.Event()
         check_thread = threading.Thread(target=self.check_session)
         check_thread.start()
         return True
     return False
Beispiel #11
0
 def __init__(self):
     custom_path = utils.get_setting("lib_export_folder")
     if custom_path == None or len(custom_path) == 0:
         custom_path = utils.get_data_folder()
         utils.set_setting("lib_export_folder", custom_path)
     self.library_folder = os.path.join(custom_path, "timvision_library")
     self.init_library_folders()
     utils.set_setting("lib_export_updating", "false")
    def play(self,
             content_id=None,
             url=None,
             license_key=None,
             license_headers="",
             start_offset=0.0,
             content_type='',
             duration=0,
             start_paused=False):
        PROTOCOL = 'mpd'
        DRM = 'com.widevine.alpha'
        user_agent = utils.get_user_agent()

        play_item = xbmcgui.ListItem(path=url)
        play_item.setContentLookup(False)
        play_item.setMimeType('application/dash+xml')
        play_item.setProperty('inputstreamaddon', "inputstream.adaptive")
        play_item.setProperty('inputstream.adaptive.stream_headers',
                              "%s&Connection=keep-alive" % (user_agent))
        play_item.setProperty('inputstream.adaptive.manifest_type', PROTOCOL)

        if license_key != None:
            is_helper = inputstreamhelper.Helper(PROTOCOL, drm=DRM)
            if not is_helper.check_inputstream():
                Dialogs.show_dialog(utils.get_local_string(30063))
                return
            play_item.setProperty('inputstream.adaptive.license_type', DRM)
            play_item.setProperty(
                'inputstream.adaptive.license_key',
                license_key + '|' + license_headers + '|R{SSM}|')

            start_offset = int(start_offset)
            duration = int(duration)
            if start_offset >= 10 and duration - start_offset > 30:
                if not utils.get_setting("always_resume"):
                    xbmc.executebuiltin("Dialog.Close(all,true)")
                    dialog_title = utils.get_local_string(30050)
                    message = utils.get_local_string(30051) % (
                        utils.get_timestring_from_seconds(start_offset))
                    start_offset = start_offset if Dialogs.ask(
                        message, dialog_title) else 0
            else:
                start_offset = 0

            utils.call_service(
                "set_playing_item", {
                    "url": url,
                    "contentId": content_id,
                    "time": start_offset,
                    "videoType": content_type,
                    "duration": duration,
                    "paused": start_paused
                })
            xbmcplugin.setResolvedUrl(handle=self.plugin_handle,
                                      succeeded=True,
                                      listitem=play_item)
        else:
            xbmc.Player().play(item=url, listitem=play_item)
 def verifica_login(self, count=0):
     logged = utils.call_service("is_logged")
     if not logged:
         email = utils.get_setting("username")
         password = utils.get_setting("password")
         if email != "" and password != "":
             logged = utils.call_service("login", {
                 "username": email,
                 "password": password
             })
         if not logged:
             if count == 0:
                 utils.set_setting(
                     "username",
                     Dialogs.get_text_input(utils.get_local_string(30001)))
                 utils.set_setting("password", Dialogs.get_password_input())
                 return self.verifica_login(count + 1)
     return logged
Beispiel #14
0
    def apply_basic_settings(self):        
        self.check_interval = utils.get_int_setting('check_interval')

        user = utils.get_setting('username')
        password = utils.get_setting('password')
        host = utils.get_setting('host')
        port = utils.get_int_setting('port')

        if not host:
            utils.log_normal("No host specified")
            return False

        self.camera = foscam.Camera(host, port, user, password)
        success, msg = self.camera.test()
        if not success:
            utils.log_error(msg)
            return False

        return True
    def verify_version(self, force=False):
        major, _ = utils.get_kodi_version()
        if major >= 18:
            return True

        if not utils.get_setting("kodi_version_alert_shown") or force:
            dialog_title = utils.get_local_string(30040)
            dialog_msg = utils.get_local_string(30067)
            Dialogs.show_dialog(dialog_msg, dialog_title)
            utils.set_setting("kodi_version_alert_shown", "true")
        return False
Beispiel #16
0
def log_write(msg, mode):
    from resources.lib import utils

    if not utils.get_setting("debug_enable"):
        return

    if mode == LOG_API and not utils.get_setting("log_all_apicalls"):
        return
    if mode == LOG_TIMVISION and not utils.get_setting("logd_timvision"):
        return
    if mode == LOG_PLAYER and not utils.get_setting("logd_player"):
        return
    if mode == LOG_WIDEVINE and not utils.get_setting("logd_widevine"):
        return

    if msg != None:
        if isinstance(msg, unicode):
            msg = msg.encode('utf-8')
        message = "[%s] - %s" % (mode, msg)
        kodi_log(message)
Beispiel #17
0
    def _thread_tracker(self):
        log("in tracker thread")
        xbmc.sleep(2000)

        total_time = int(self.getTotalTime())
        total_time_min = int(get_setting("min-length"))
        perc_mark = int(get_setting("scr-pct"))
        self._is_detected = True
        timeout = 1000
        # if total_time set and is lower than total_time_min then we do not start the loop at all and stop the thread,
        if total_time <= 0 or total_time > total_time_min:
            while self._playback_lock.isSet() and not xbmc.Monitor().abortRequested():
                try:
                    # The max() assures that the total time is over two minutes
                    # preventing it from scrobbling while buffering and solving #31
                    if min(99, 100 * self.getTime() / max(120, total_time)) >= perc_mark:
                        success = self._api.mark_as_watched(self._item)
                        if not success:
                            if timeout == 1000:
                                log("Failed to scrobble")
                                notify(get_str(32080))
                                timeout = 30000
                            elif (self.getTime() / total_time) > 0.95:
                                log("Stopped scrobbling")
                                notify(get_str(32081))
                                break
                            else:
                                log("Retrying")

                        elif success and bool(get_setting("bubble")):
                            self._show_bubble(self._item)
                            break
                except:
                    pass
                xbmc.sleep(timeout)
        log('track stop')
Beispiel #18
0
    def __init__(self):
        self.userSettings = {}
        self.isLoggedIn = False
        self.loginInProgress = False

        self.headers = {"Content-Type": "application-json", "simkl-api-key": APIKEY}
        # set_setting('token', '')
        token = get_setting('token')
        if token:
            self.headers["authorization"] = "Bearer " + token
            r = self.get_user_settings()
            if r:
                notify(get_str(32025).format(self.userSettings["user"]["name"]))
                return
            elif r is None:
                notify(get_str(32027))
                return
        self.login()
Beispiel #19
0
    def apply_other_settings(self):
        self.motion_enable = utils.get_bool_setting('motion_enable')
        self.sound_enable = utils.get_bool_setting('sound_enable')

        self.duration = utils.get_int_setting('preview_duration')
        self.scaling = utils.get_float_setting('preview_scaling')
        self.position = utils.get_setting('preview_position').lower()

        motion_trigger_interval = utils.get_int_setting(
            'motion_trigger_interval')
        sound_trigger_interval = utils.get_int_setting(
            'sound_trigger_interval')

        if self.motion_enable and self.sound_enable:
            self.trigger_interval = min(motion_trigger_interval,
                                        sound_trigger_interval)
        elif self.motion_enable:
            self.trigger_interval = motion_trigger_interval
        elif self.sound_enable:
            self.trigger_interval = sound_trigger_interval

        if self.motion_enable:
            command = self.camera.set_motion_detect_config()
            command['isEnable'] = 1
            command['sensitivity'] = utils.get_int_setting(
                'motion_sensitivity')
            command['triggerInterval'] = motion_trigger_interval
            self.send_command(command)

        if self.sound_enable:
            command = self.camera.set_sound_detect_config()
            command['isEnable'] = 1
            command['sensitivity'] = utils.get_int_setting('sound_sensitivity')
            command['triggerInterval'] = sound_trigger_interval

            for iday in range(7):
                command['schedule{0:d}'.format(iday)] = 2**48 - 1
            self.send_command(command)
Beispiel #20
0
 def __insert_folder_database(self, label):
     database_insert = utils.get_setting("lib_export_kodi_library")
     if not database_insert:
         return
     folder = os.path.join(self.library_folder, label) + os.sep
     entry_found, _ = self.__check_database(folder)
     if entry_found:
         return False
     if label == self.movies_folder:
         strScraper = "metadata.themoviedb.org"
         strSettings = '<settings version="2"><setting id="certprefix" default="true">Rated </setting><setting id="fanart">true</setting><setting id="imdbanyway" default="true">false</setting><setting id="keeporiginaltitle" default="true">false</setting><setting id="language">it</setting><setting id="RatingS">IMDb</setting><setting id="tmdbcertcountry">it</setting><setting id="trailer">true</setting></settings>'
     else:
         strScraper = "metadata.tvdb.com"
         strSettings = '<settings version="2"><setting id="absolutenumber" default="true">false</setting><setting id="alsoimdb" default="true">false</setting><setting id="dvdorder" default="true">false</setting><setting id="fallback" default="true">true</setting><setting id="fallbacklanguage" default="true">en</setting><setting id="fanart">true</setting><setting id="language">it</setting><setting id="RatingS">IMDb</setting><setting id="usefallbacklanguage1">true</setting></settings>'
     db_path = self.__get_database_path()
     conn = sqlite3.connect(db_path)
     cursor = conn.cursor()
     cursor.execute(
         "INSERT INTO path (strPath, strContent, strScraper, scanRecursive, useFolderNames, strSettings, noUpdate, exclude) VALUES (?,?,?,0,0,?,0,0)",
         [folder, label, strScraper, strSettings])
     conn.commit()
     cursor.close()
     conn.close()
Beispiel #21
0
    def update(self, force=False):
        is_updating = utils.get_setting("lib_export_updating")
        if not utils.get_setting("lib_export_enabled") or is_updating:
            return
        utils.set_setting("lib_export_updating", "true")
        update_kodi_library = False
        time_now = int(time.time())
        last_update_movies = int(
            utils.get_setting("lib_export_last_update_movies"))
        if utils.get_setting("lib_export_movies") and (
                force
                or time_now - self.TIME_BETWEEN_UPDATE > last_update_movies):
            Logger.kodi_log("Updating movies library")
            utils.set_setting("lib_export_last_update_movies", str(time_now))
            self.__update_movies_library()
            self.__add_folder_to_sources(self.movies_folder)
            self.__insert_folder_database(self.movies_folder)
            update_kodi_library = True

        last_update_tvshows = int(
            utils.get_setting("lib_export_last_update_tvshows"))
        if utils.get_setting("lib_export_tvshows") and (
                force
                or time_now - self.TIME_BETWEEN_UPDATE > last_update_tvshows):
            Logger.kodi_log("Updating tvshows library")
            utils.set_setting("lib_export_last_update_tvshows", str(time_now))
            self.__update_tvshows_library()
            self.__add_folder_to_sources(self.tvshows_folder)
            self.__insert_folder_database(self.tvshows_folder)
            update_kodi_library = True

        if update_kodi_library:
            #xbmc.executebuiltin('Action(reloadsources)')
            self.__run_update_library()
            Logger.kodi_log("Libreria in aggiornamento")

        utils.set_setting("lib_export_updating", "false")
Beispiel #22
0
import os
from functools import partial

import xbmc
import xbmcaddon
import xbmcgui

from resources.lib import foscam
from resources.lib import utils
from resources.lib import gui

user = utils.get_setting('username')
password = utils.get_setting('password')
host = utils.get_setting('host')
port = utils.get_int_setting('port')

if not host:
    utils.error_dialog(utils.get_string(32101))
    sys.exit(1)

if utils.invalid_user_char(user, show_dialog=True):
    sys.exit(1)

if utils.invalid_password_char(password, show_dialog=True):
    sys.exit(1)

camera = foscam.Camera(host, port, user, password)
success, msg = camera.test()
if not success:
    utils.error_dialog(msg)
    sys.exit(1)
Beispiel #23
0
import os
from functools import partial

import xbmc
import xbmcaddon
import xbmcgui

from resources.lib import foscam
from resources.lib import utils
from resources.lib import gui


user = utils.get_setting('username')
password = utils.get_setting('password')
host = utils.get_setting('host')
port = utils.get_int_setting('port')

if not host:
    utils.error_dialog(utils.get_string(32101))
    sys.exit(1)

if utils.invalid_user_char(user, show_dialog=True):
    sys.exit(1)

if utils.invalid_password_char(password, show_dialog=True):
    sys.exit(1)

camera = foscam.Camera(host, port, user, password)
success, msg = camera.test()
if not success:
    utils.error_dialog(msg)
Beispiel #24
0
 def prefetch_login(self):
     user = utils.get_setting('username')
     passw = utils.get_setting('password')
     if user != '' and passw != '':
         self.timvision_session.login(user, passw)
    def router(self, parameters):
        if not self.verifica_login():
            utils.open_settings()
            return

        params = utils.get_parameters_dict_from_url(parameters)
        params_count = len(params)
        if params_count == 0:
            self.verify_version()
            self.create_main_page()
        else:
            if params.has_key("page"):
                page = params.get("page")
                category_id = params.get("category_id")
                if page in ["HOME", "INTRATTENIMENTO"]:
                    self.create_category_page(page_id=category_id)
                elif page == "CINEMA":
                    self.create_category_page(page_id=category_id,
                                              ha_elenco=True,
                                              category_name='Cinema')
                elif page == "SERIE TV":
                    self.create_category_page(page_id=category_id,
                                              ha_elenco=True,
                                              category_name='Serie')
                elif page == "BAMBINI":
                    self.create_category_page(page_id=category_id,
                                              ha_elenco=True,
                                              category_name='Kids')

            if params.has_key("action"):
                action = params.get("action")
                if action == "full_list":
                    category = params.get("category")
                    items = utils.call_service("load_all_contents", {
                        "begin": 0,
                        "category": category
                    })
                    self.add_items_to_folder(items)
                elif action == "apri_serie":
                    id_serie = params.get("id_serie")
                    nome_serie = urllib.unquote(params.get("serieNome", ""))
                    items = utils.call_service(
                        "get_show_content", {
                            "contentId": id_serie,
                            "contentType":
                            TimVisionAPI.TVSHOW_CONTENT_TYPE_SEASONS
                        })
                    if len(items) == 1 and utils.get_setting("unique_season"):
                        items = TimVisionObjects.parse_collection(items)
                        items = utils.call_service(
                            "get_show_content", {
                                "contentId":
                                items[0].content_id,
                                "contentType":
                                TimVisionAPI.TVSHOW_CONTENT_TYPE_EPISODES
                            })
                    self.add_items_to_folder(items=items, title=nome_serie)
                elif action == "apri_stagione":
                    id_stagione = params.get("id_stagione")
                    items = utils.call_service(
                        "get_show_content", {
                            "contentId":
                            id_stagione,
                            "contentType":
                            TimVisionAPI.TVSHOW_CONTENT_TYPE_EPISODES
                        })
                    season_no = params.get("seasonNo")
                    self.add_items_to_folder(items=items,
                                             title="Stagione %s" % (season_no))
                elif action == "play_item":
                    content_id = params.get("contentId")
                    video_type = params.get("videoType")
                    has_hd = params.get("has_hd", "false")
                    start_offset = params.get("startPoint")
                    duration = params.get("duration")
                    paused = self.increase_play_video_count()
                    self.play_video(content_id, video_type, has_hd,
                                    start_offset, duration, paused)
                elif action == "open_page":
                    uri = urllib.unquote_plus(params.get("uri")).replace(
                        "maxResults=30",
                        "maxResults=50").replace("&addSeeMore=50", "")
                    items = utils.call_service("get_contents", {"url": uri})
                    items = [x for x in items if x["layout"] != "SEE_MORE"]
                    self.add_items_to_folder(items)
                elif action == "logout":
                    utils.call_service("logout")
                elif action == "play_trailer":
                    content_id = params.get("contentId")
                    content_type = params.get("type")
                    self.play_trailer(content_id, content_type)
                elif action == "set_seen":
                    content_id = params.get("contentId")
                    duration = params.get("duration")
                    utils.call_service("set_content_seen", {
                        "contentId": content_id,
                        "duration": duration
                    })
                    xbmc.executebuiltin("Container.Refresh()")
                elif action == "toogle_favourite":
                    content_id = params.get("contentId")
                    value = utils.get_bool(params.get("value"))
                    mediatype = params.get("mediatype")
                    response = utils.call_service(
                        "set_favourite", {
                            "contentId": content_id,
                            "value": value,
                            "mediatype": mediatype
                        })
                    if response:
                        dialog_title = utils.get_local_string(30033)
                        dialog_msg = utils.get_local_string(
                            30034) if value else utils.get_local_string(30035)
                        Dialogs.show_message(dialog_msg, dialog_title,
                                             xbmcgui.NOTIFICATION_INFO)
                        xbmc.executebuiltin("Container.Refresh()")
                    else:
                        dialog_title = utils.get_local_string(30038)
                        dialog_msg = utils.get_local_string(30039)
                        Dialogs.show_dialog(dialog_msg, dialog_title)
                elif action == "search":
                    keyword = Dialogs.get_text_input(
                        utils.get_local_string(30032))
                    if keyword != None and len(keyword) > 0:
                        items = utils.call_service("search",
                                                   {"keyword": keyword})
                        return self.add_items_to_folder(items)
                elif action == "favourites":
                    items = utils.call_service("get_favourite")
                    return self.add_items_to_folder(items)
                elif action == "donation":
                    self.open_donation_page()
                elif action == "library":
                    library = TimVisionLibrary.TimVisionLibrary()
                    library.update(force=True)
                elif action == "library_kodi":
                    library = TimVisionLibrary.TimVisionLibrary()
                    library.check_db_integrity()
                    pass