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
예제 #2
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")
예제 #3
0
 def pin_check(self, pin):
     r = self._http("/oauth/pin/" + pin + "?client_id=" + APIKEY, headers=self.headers)
     log("PIN Check = " + str(r))
     if r["result"] == "OK":
         set_setting('token', r["access_token"])
         self.headers["authorization"] = "Bearer " + r["access_token"]
         return self.get_user_settings()
     elif r["result"] == "KO":
         return False
예제 #4
0
    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
예제 #5
0
    def init_settings(self):
        utils.log_normal("Initialising settings from the camera")

        response = self.camera.get_motion_detect_config()
        utils.set_setting('motion_sensitivity', str(response['sensitivity']))
        utils.set_setting('motion_trigger_interval', str(response['triggerInterval']))
        
        response = self.camera.get_sound_detect_config()
        utils.set_setting('sound_sensitivity', str(response['sensitivity']))
        utils.set_setting('sound_trigger_interval', str(response['triggerInterval']))

        response = self.camera.get_snapshot_config()
        utils.set_setting('snapshot_quality', str(response['snapPicQuality']))
예제 #6
0
 def _http(self, url, headers={}, body=None, is_json=True):
     try:
         con = http.client.HTTPSConnection("api.simkl.com")
         con.request("GET", url, headers=headers, body=body)
         r = con.getresponse().read().decode("utf-8")
         if r.find('user_token_failed') != -1:
             self.isLoggedIn = False
             set_setting('token', '')
             notify(get_str(32031))
             return False
         return json.loads(r) if is_json else r
     except Exception:
         return None
예제 #7
0
    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
예제 #8
0
 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
예제 #9
0
    def init_settings(self):
        utils.log_normal("Initialising settings from the camera")

        response = self.camera.get_motion_detect_config()
        utils.set_setting('motion_sensitivity', str(response['sensitivity']))
        utils.set_setting('motion_trigger_interval',
                          str(response['triggerInterval']))

        response = self.camera.get_sound_detect_config()
        utils.set_setting('sound_sensitivity', str(response['sensitivity']))
        utils.set_setting('sound_trigger_interval',
                          str(response['triggerInterval']))
예제 #10
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")
#  "toggle"  - will toggle activity handling state
#  "activity"- will set activity handling state
#            - argv[2] - "true"|"false"
#  "settings"- will open settings dialog
#  None      - will open an options dialog to allow user to choose the above capabilities
if __name__ == "__main__":
    count = len(sys.argv) - 1
    activityState = utils.get_bool_setting("activity_enable")
    currentState = "Enabled" if activityState else "Disabled"
    toggleState = "Disable" if activityState else "Enable"
    if count > 0:
        if sys.argv[1] == "scene":
            Main(sys.argv[2])
        elif sys.argv[1] == "toggle":
            val = "false" if activityState else "true"
            utils.set_setting("activity_enable",val)
            if val == "false":
                disabledDialog()
            else:
                enabledDialog()
        elif sys.argv[1] == "activity":
            val = "true"
            try:
                val = "true" if sys.argv[2] == "true" else "false"
            except:
                pass
            utils.set_setting("activity_enable",val)
            if val == "true":
                enabledDiaglog()
            else:
                disabledDialog()
예제 #12
0
import xbmc
from resources.lib import utils, TimVisionLibrary


class TimVisionService(object):
    def __init__(self):
        self.timvision_server = utils.start_webserver()
        self.library = TimVisionLibrary.TimVisionLibrary()

    def run(self):
        monitor = xbmc.Monitor()
        while not monitor.abortRequested():
            self.library.update()
            if monitor.waitForAbort(5):
                self.shutdown()
                break

    def shutdown(self):
        self.timvision_server.shutdown()
        self.timvision_server.server_close()
        self.timvision_server.socket.close()


if __name__ == "__main__":
    utils.set_setting("kodi_version_alert_shown", "false")
    TimVisionService().run()