Exemplo n.º 1
0
def install_local_zip(zip_file):
    mc = metacontainers.MetaContainer()
    work_path = mc.work_path
    cache_path = mc.cache_path

    extract_zip(zip_file, work_path)
    xbmc.sleep(5000)
    copy_meta_contents(work_path, cache_path)
    for table in mc.table_list:
        mc._insert_metadata(table)
Exemplo n.º 2
0
def create_meta_packs():
    import shutil

    global __metaget__
    container = metacontainers.MetaContainer()
    savpath = container.path
    AZ_DIRECTORIES.append('#')
    letters_completed = 0
    letters_per_zip = 27
    start_letter = ''
    end_letter = ''

    for video_type in ('tvshow', 'movie'):
        for letter in AZ_DIRECTORIES:
            if letters_completed == 0:
                start_letter = letter
                __metaget__.__del__()
                shutil.rmtree(container.cache_path)
                __metaget__ = metahandlers.MetaData()

            if letters_completed <= letters_per_zip:
                #scan_by_letter(video_type, letter)
                letters_completed += 1

            if (letters_completed == letters_per_zip or letter == '123'
                    or utils.get_dir_size(container.cache_path) >
                (500 * 1024 * 1024)):
                end_letter = letter
                arcname = 'MetaPack-%s-%s-%s.zip' % (video_type, start_letter,
                                                     end_letter)
                arcname = os.path.join(savpath, arcname)
                __metaget__.__del__()
                zipdir(container.cache_path, arcname)
                __metaget__ = metahandlers.MetaData()
                letters_completed = 0
                xbmc.sleep(5000)
Exemplo n.º 3
0
    def repair_meta_images(self):
        from metahandler import metahandlers
        from metahandler import metacontainers
        import xbmcgui
        __metaget__ = metahandlers.MetaData()

        cont = metacontainers.MetaContainer()
        if self.db_type == DB_TYPES.MYSQL:
            db = db_lib.connect(database=self.dbname, user=self.username, password=self.password, host=self.address, buffered=True)
        else:
            db = db_lib.connect(cont.videocache)
        dbcur = db.cursor()
        dlg = xbmcgui.DialogProgress()
        dlg.create('Repairing Images', '', '', '')
        for video_type in ('tvshow', 'movie'):
            total = 'SELECT count(*) from %s_meta WHERE ' % video_type
            total += 'imgs_prepacked = "true"'
            total = dbcur.execute(total).fetchone()[0]
            statement = 'SELECT title,cover_url,backdrop_url'
            if video_type == 'tvshow': statement += ',banner_url'
            statement += ' FROM %s_meta WHERE imgs_prepacked = "true"' % video_type
            complete = 1.0
            start_time = time.time()
            already_existing = 0

            for row in dbcur.execute(statement):
                title = row[0]
                cover = row[1]
                backdrop = row[2]
                if video_type == 'tvshow':
                    banner = row[3]
                else:
                    banner = False
                percent = int((complete * 100) / total)
                entries_per_sec = (complete - already_existing)
                entries_per_sec /= max(float((time.time() - start_time)), 1)
                total_est_time = total / max(entries_per_sec, 1)
                eta = total_est_time - (time.time() - start_time)

                eta = utils.format_eta(eta)
                dlg.update(percent, eta + title, '')
                if cover:
                    dlg.update(percent, eta + title, cover)
                    img_name = __metaget__._picname(cover)
                    img_path = os.path.join(__metaget__.mvcovers, img_name[0].lower())
                    file_path = os.path.join(img_path, img_name)
                    if not os.path.isfile(file_path):
                        retries = 4
                        while retries:
                            try:
                                __metaget__._downloadimages(cover, img_path, img_name)
                                break
                            except:
                                retries -= 1
                    else:
                        already_existing -= 1
                if backdrop:
                    dlg.update(percent, eta + title, backdrop)
                    img_name = __metaget__._picname(backdrop)
                    img_path = os.path.join(__metaget__.mvbackdrops, img_name[0].lower())
                    file_path = os.path.join(img_path, img_name)
                    if not os.path.isfile(file_path):
                        retries = 4
                        while retries:
                            try:
                                __metaget__._downloadimages(backdrop, img_path, img_name)
                                break
                            except:
                                retries -= 1
                    else:
                        already_existing -= 1
                if banner:
                    dlg.update(percent, eta + title, banner)
                    img_name = __metaget__._picname(banner)
                    img_path = os.path.join(__metaget__.tvbanners, img_name[0].lower())
                    file_path = os.path.join(img_path, img_name)
                    if not os.path.isfile(file_path):
                        retries = 4
                        while retries:
                            try:
                                __metaget__._downloadimages(banner, img_path, img_name)
                                break
                            except:
                                retries -= 1
                    else:
                        already_existing -= 1
                if dlg.iscanceled(): return False
                complete += 1