Beispiel #1
0
 def __remove_folder_database_by_path_id(self, path_id):
     Logger.kodi_log("Removing path id: %d" % (path_id))
     db_path = self.__get_database_path()
     conn = sqlite3.connect(db_path)
     cursor = conn.cursor()
     cursor.execute("DELETE FROM path WHERE idPath = ?", [path_id])
     conn.commit()
     cursor.close()
     conn.close()
Beispiel #2
0
def load_pickle(pickle_file, default=None):
    folder = get_data_folder()
    path = url_join(folder, pickle_file)
    try:
        content = default
        with open(path, "r") as file_stream:
            content = pickle.load(file_stream)
        file_stream.close()
        return content
    except:
        Logger.kodi_log("Error while loading %s" % (pickle_file))
        return default
Beispiel #3
0
 def __update_tvshows_library(self):
     tvshows = utils.call_service("load_all_contents", {
         "begin": 0,
         "category": "Serie"
     })
     if tvshows == None or len(tvshows) == 0:
         return
     self.empty_tvshows_library()
     base_series_folder = os.path.join(self.library_folder,
                                       self.tvshows_folder)
     items = TimVisionObjects.parse_collection(tvshows)
     for tvshow in items:
         title_normalized = self.__normalize_path(tvshow.title)
         if len(title_normalized) == 0:
             # TODO: FIX ME
             continue  #skip shows with unicode characters/empty title
         Logger.kodi_log("Library (TV): %s" % (title_normalized))
         normalized_show_name = "%s (%d)" % (title_normalized, tvshow.year)
         show_folder = os.path.join(base_series_folder,
                                    normalized_show_name)
         xbmcvfs.mkdir(show_folder)
         seasons_json = utils.call_service(
             "get_show_content", {
                 "contentId": tvshow.content_id,
                 "contentType": TimVisionAPI.TVSHOW_CONTENT_TYPE_SEASONS
             })
         seasons = TimVisionObjects.parse_collection(seasons_json)
         for season in seasons:
             episodes_json = utils.call_service(
                 "get_show_content", {
                     "contentId": season.content_id,
                     "contentType":
                     TimVisionAPI.TVSHOW_CONTENT_TYPE_EPISODES
                 })
             episodes = TimVisionObjects.parse_collection(episodes_json)
             for episode in episodes:
                 filename = "%s S%02dE%02d" % (
                     normalized_show_name, episode.season, episode.episode)
                 url = "plugin://plugin.video.timvision/?action=play_item&contentId=%s&videoType=%s&has_hd=%s&startPoint=%s&duration=%s" % (
                     str(episode.content_id), episode.mediatype,
                     str(episode.is_hd_available), str(
                         episode.bookmark), str(episode.duration))
                 self.write_strm(
                     os.path.join(show_folder, filename + ".strm"),
                     filename, url)
Beispiel #4
0
def start_webserver():
    Logger.kodi_log("Starting TIMVISION addon")

    # pick & store a port for the internal TimVision HTTP proxy service
    tv_port = select_unused_port()
    set_setting('timvision_service_port', str(tv_port))

    # server defaults
    SocketServer.TCPServer.allow_reuse_address = True

    # configure the TimVision Data Server
    from resources.lib.TimVisionHttpRequestHandler import TimVisionHttpRequestHandler
    tv_server = SocketServer.TCPServer(('127.0.0.1', tv_port),
                                       TimVisionHttpRequestHandler)
    tv_server.server_activate()
    tv_server.timeout = 1

    tv_thread = threading.Thread(target=tv_server.serve_forever)
    tv_thread.daemon = True
    tv_thread.start()

    return tv_server
Beispiel #5
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")