Пример #1
0
 def __init__(self, *args, **kwargs):
     import os
     from sqlite3 import dbapi2 as database
     db_path = os.path.join(helper.get_profile(),
                            constants.appdata_cache_path)
     self.dbcon = database.connect(db_path)
     self.dbcon.row_factory = database.Row
     self.dbcur = self.dbcon.cursor()
     self.__createTable()
Пример #2
0
def __init():
    cookies = helper.get_profile() + 'cookies.txt'
    net = NetHelper(cookies, True)

    # Make sure the cookies exist
    if not os.path.exists(cookies):
        cookiesfile = xbmcvfs.File(cookies, 'w')
        cookiesfile.close()

    return cookies, net
    def __init__(self,
                 prepack_images=False,
                 preparezip=False,
                 tmdb_api_key='af95ef8a4fe1e697f86b8c194f2e5e11'):
        '''
        A copy of __init__ from the metahandler plugin, modified to use a 
        different db path, which unfortunately required pasting this function 
        and modifying it :/
        '''
        # TMDB constants
        self.tmdb_image_url = ''
        self.path = helper.get_profile()
        self.cache_path = make_dir(self.path, 'meta_cache')
        user_tmdb_key = helper.get_setting('tmdb-api-key')
        self.tmdb_api_key = user_tmdb_key if user_tmdb_key != '' else tmdb_api_key

        if prepack_images:
            #create container working directory
            #!!!!!Must be matched to workdir in metacontainers.py create_container()
            self.work_path = make_dir(self.path, 'work')

        #set movie/tvshow constants
        self.type_movie = 'movie'
        self.type_tvshow = 'tvshow'
        self.type_season = 'season'
        self.type_episode = 'episode'

        #this init auto-constructs necessary folder hierarchies.

        # control whether class is being used to prepare pre-packaged .zip
        self.prepack_images = bool2string(prepack_images)
        self.videocache = os.path.join(self.cache_path, 'video_cache.db')
        self.tvpath = make_dir(self.cache_path, self.type_tvshow)
        self.tvcovers = make_dir(self.tvpath, 'covers')
        self.tvbackdrops = make_dir(self.tvpath, 'backdrops')
        self.tvbanners = make_dir(self.tvpath, 'banners')
        self.mvpath = make_dir(self.cache_path, self.type_movie)
        self.mvcovers = make_dir(self.mvpath, 'covers')
        self.mvbackdrops = make_dir(self.mvpath, 'backdrops')

        # connect to db at class init and use it globally
        if DB == 'mysql':

            class MySQLCursorDict(database.cursor.MySQLCursor):
                def _row_to_python(self, rowdata, desc=None):
                    row = super(MySQLCursorDict,
                                self)._row_to_python(rowdata, desc)
                    if row:
                        return dict(zip(self.column_names, row))
                    return None

            db_address = common.addon.get_setting('db_address')
            db_port = common.addon.get_setting('db_port')
            if db_port: db_address = '%s:%s' % (db_address, db_port)
            db_user = common.addon.get_setting('db_user')
            db_pass = common.addon.get_setting('db_pass')
            db_name = common.addon.get_setting('db_name')
            self.dbcon = database.connect(database=db_name,
                                          user=db_user,
                                          password=db_pass,
                                          host=db_address,
                                          buffered=True)
            self.dbcur = self.dbcon.cursor(cursor_class=MySQLCursorDict,
                                           buffered=True)
        else:
            self.dbcon = database.connect(self.videocache,
                                          isolation_level=None,
                                          check_same_thread=False)
            self.dbcon.row_factory = database.Row  # return results indexed by field names and not numbers so we can convert to dict
            self.dbcur = self.dbcon.cursor()

        # initialize cache db
        self._cache_create_movie_db()

        # Check TMDB configuration, update if necessary
        self._set_tmdb_config()

        # Add the absolute_number column here, which is helpful for animes
        if not self._does_column_exist('absolute_episode', 'episode_meta'):
            sql_alter = "ALTER TABLE episode_meta ADD absolute_episode INTEGER"
            try:
                self.dbcur.execute(sql_alter)
                helper.log_debug(
                    'Successfully added the absolute_episode column')
            except:
                helper.log_debug('Failed to alter the table')
        else:
            helper.log_debug('The absolute_episode column already exists')

        common.addon.log = helper.log
        self.lock = threading.Lock()
 def __init__(self):
     LastShowVisited.__init__(self, helper.get_profile())