Ejemplo n.º 1
0
def export_videolibrary(item):
    logger.info()

    zip_file_folder = platformtools.dialog_browse(3, config.get_localized_string(80002))
    if zip_file_folder == "":
        return
    zip_file = xbmc.translatePath(zip_file_folder + "KoD_video_library-" + str(datetime.date.today()) + ".zip")

    p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80003))
    p_dialog.update(0)

    if filetools.exists(temp_path):
        filetools.rmdirtree(temp_path)
    filetools.mkdir(temp_path)
    p_dialog.update(25)
    filetools.mkdir(movies_path)
    copy_tree(videolibrarytools.MOVIES_PATH, movies_path)
    p_dialog.update(50)
    filetools.mkdir(tvshows_path)
    copy_tree(videolibrarytools.TVSHOWS_PATH, tvshows_path)
    p_dialog.update(75)

    zipper = ziptools.ziptools()
    zipper.zip(temp_path, zip_file)

    filetools.rmdirtree(temp_path)

    p_dialog.update(100)
    xbmc.sleep(1000)
    p_dialog.close()
    platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80004), time=5000, sound=False)
Ejemplo n.º 2
0
def import_videolibrary(item):
    logger.info()

    zip_file = platformtools.dialog_browse(1,
                                           config.get_localized_string(80005))
    if zip_file == "":
        return
    if not platformtools.dialog_yesno(config.get_localized_string(20000),
                                      config.get_localized_string(80006)):
        return

    p_dialog = platformtools.dialog_progress_bg(
        config.get_localized_string(20000), config.get_localized_string(80007))
    p_dialog.update(0)

    if filetools.exists(temp_path):
        filetools.rmdirtree(temp_path)
    filetools.mkdir(temp_path)

    unzipper = ziptools.ziptools()
    unzipper.extract(zip_file, temp_path)
    p_dialog.update(25)

    filetools.rmdirtree(videolibrarytools.VIDEOLIBRARY_PATH)
    p_dialog.update(50)
    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc.sleep(5000)
        xbmc_videolibrary.clean()

    config.verify_directories_created()
    if filetools.exists(movies_path):
        copy_tree(movies_path, videolibrarytools.MOVIES_PATH)
    p_dialog.update(70)
    if filetools.exists(tvshows_path):
        copy_tree(tvshows_path, videolibrarytools.TVSHOWS_PATH)
    p_dialog.update(90)
    filetools.rmdirtree(temp_path)

    p_dialog.update(100)
    xbmc.sleep(2000)
    p_dialog.close()
    platformtools.dialog_ok(config.get_localized_string(20000),
                            config.get_localized_string(80008))

    if platformtools.dialog_yesno(config.get_localized_string(20000),
                                  config.get_localized_string(80009)):
        import service
        service.check_for_update(overwrite=True)

    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc_videolibrary.update()
Ejemplo n.º 3
0
def import_videolibrary(item):
    logger.info()

    zip_file = unicode(
        platformtools.dialog_browse(1,
                                    config.get_localized_string(80005),
                                    mask=".zip"))
    if zip_file == "":
        return
    if not platformtools.dialog_yesno(config.get_localized_string(20000),
                                      config.get_localized_string(80006)):
        return

    p_dialog = platformtools.dialog_progress_bg(
        config.get_localized_string(20000), config.get_localized_string(80007))
    # p_dialog.update(0)

    if filetools.exists(temp_path):
        shutil.rmtree(temp_path)
    filetools.mkdir(videolibrary_temp_path)

    unzip(videolibrary_temp_path, zip_file)
    p_dialog.update(20)

    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc_videolibrary.clean()
    p_dialog.update(30)
    shutil.rmtree(videolibrary_movies_path)
    shutil.rmtree(videolibrary_tvshows_path)
    p_dialog.update(50)

    config.verify_directories_created()
    if filetools.exists(movies_path):
        copy_tree(movies_path, videolibrary_movies_path)
    p_dialog.update(70)
    if filetools.exists(tvshows_path):
        copy_tree(tvshows_path, videolibrary_tvshows_path)
    p_dialog.update(90)
    shutil.rmtree(temp_path)

    p_dialog.update(100)
    xbmc.sleep(1000)
    p_dialog.close()
    platformtools.dialog_notification(config.get_localized_string(20000),
                                      config.get_localized_string(80008),
                                      time=5000,
                                      sound=False)

    videolibrary.update_videolibrary()
    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc_videolibrary.update()
Ejemplo n.º 4
0
def import_videolibrary(item):
    logger.info()

    zip_file = platformtools.dialog_browse(1, config.get_localized_string(80005))
    if zip_file == "":
        return
    if not platformtools.dialog_yesno(config.get_localized_string(20000), config.get_localized_string(80006)):
        return

    p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(80007))
    p_dialog.update(0)

    if filetools.exists(temp_path):
        filetools.rmdirtree(temp_path)
    filetools.mkdir(temp_path)

    unzipper = ziptools.ziptools()
    unzipper.extract(zip_file, temp_path)
    p_dialog.update(20)

    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc_videolibrary.clean()
    p_dialog.update(30)
    filetools.rmdirtree(videolibrarytools.MOVIES_PATH)
    filetools.rmdirtree(videolibrarytools.TVSHOWS_PATH)
    p_dialog.update(50)

    config.verify_directories_created()
    if filetools.exists(movies_path):
        copy_tree(movies_path, videolibrarytools.MOVIES_PATH)
    p_dialog.update(70)
    if filetools.exists(tvshows_path):
        copy_tree(tvshows_path, videolibrarytools.TVSHOWS_PATH)
    p_dialog.update(90)
    filetools.rmdirtree(temp_path)

    p_dialog.update(100)
    xbmc.sleep(1000)
    p_dialog.close()
    platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80008), time=5000, sound=False)

    videolibrary.update_videolibrary()
    if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
        xbmc_videolibrary.update()
Ejemplo n.º 5
0
def list_storage(item):
    logger.info()
    from core import filetools
    from lib import generictools

    itemlist = []

    torrent_params = {
        'url': item.url,
        'torrents_path': '',
        'local_torr': item.torrents_path,
        'lookup': False,
        'force': True,
        'data_torrent': True,
        'subtitles': True,
        'file_list': True
    }

    #logger.debug(item)

    browse_type = 0
    path_out = item.url
    if not filetools.exists(path_out):
        path_out = ''

    if not path_out:
        msg = 'Seleccione carpeta de destino:'
        path_out = platformtools.dialog_browse(browse_type, msg, shares='')

    path_list = filetools.listdir(path_out)
    VIDEOLIBRARY_PATH = config.get_videolibrary_path()
    FOLDER_MOVIES = config.get_setting("folder_movies")
    FOLDER_TVSHOWS = config.get_setting("folder_tvshows")
    FOLDER = ''
    if VIDEOLIBRARY_PATH in path_out:
        if FOLDER_MOVIES in path_out:
            FOLDER = FOLDER_MOVIES
        elif FOLDER_TVSHOWS in path_out:
            FOLDER = FOLDER_TVSHOWS
    MOVIES_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_MOVIES)
    TVSHOWS_PATH = filetools.join(VIDEOLIBRARY_PATH, FOLDER_TVSHOWS)
    VIDEO_FOLDER = filetools.join(VIDEOLIBRARY_PATH, FOLDER)
    TEMP_TORRENT_FOLDER = filetools.join(
        config.get_setting('downloadpath', default=''), 'cached_torrents_Alfa')
    MIS_TORRENT_FOLDER = filetools.join(
        config.get_setting('downloadpath', default=''), 'Mis_Torrents')

    for file in path_list:
        if FOLDER and file.endswith('.json') and file.split(
                '.')[0] + '_01.torrent' in str(path_list):
            json_video = Item().fromjson(
                filetools.read(filetools.join(path_out, file)))
            json_video.channel = 'url'
            json_video.action = 'findvideos'
            json_video.torrents_path = json_video.url
            itemlist.append(json_video)

        elif FOLDER and filetools.isdir(filetools.join(path_out, file)):
            if '.torrent' in str(filetools.listdir(filetools.join(path_out, file))) \
                                 or '.magnet' in str(filetools.listdir(filetools.join(path_out, file))):
                itemlist.append(
                    Item(channel=item.channel,
                         action="list_storage",
                         url=filetools.join(path_out, file),
                         title=file.title(),
                         contentTitle=file.title(),
                         contentType="list",
                         unify=False,
                         context=context))
                if len(itemlist) > 1:
                    itemlist = sorted(itemlist,
                                      key=lambda it: it.title)  #clasificamos

        elif not FOLDER and filetools.isdir(filetools.join(path_out, file)):
            if MIS_TORRENT_FOLDER in path_out:
                title = file.title()
                if 'BTDigg' in file:
                    title = title.replace(
                        'Btdigg',
                        '[B][COLOR limegreen]BT[/COLOR][COLOR red]Digg[/COLOR][/B]'
                    )
                itemlist.append(
                    Item(channel=item.channel,
                         action="list_storage",
                         url=filetools.join(path_out, file),
                         title=title,
                         contentTitle=title,
                         contentType="list",
                         unify=False,
                         btdigg=True if 'BTDigg' in file else False,
                         url_org=filetools.join(path_out, file),
                         context=context))
                if len(itemlist) > 1:
                    itemlist = sorted(itemlist,
                                      key=lambda it: it.title)  #clasificamos

        elif not FOLDER and ('.torrent' in file or '.magnet' in file):
            btdigg = False
            if '.torrent' in file:
                url = filetools.join(TEMP_TORRENT_FOLDER, file)
                filetools.copy(filetools.join(path_out, file),
                               url,
                               silent=True)
                if not filetools.exists(url): continue
            else:
                url = filetools.read(filetools.join(path_out, file),
                                     silent=True)
                if btdigg_magnet in url: btdigg = True
                size = 'MAGNET'
                if not url: continue

            torrent_params['url'] = url
            torrent_params['torrents_path'] = ''
            torrent_params['local_torr'] = filetools.join(
                TEMP_TORRENT_FOLDER, file)
            torrent_params = generictools.get_torrent_size(
                url, torrent_params=torrent_params)
            if '.magnet' in file and 'ERROR' in torrent_params['size']:
                torrent_params['size'] = 'MAGNET'
            size = torrent_params['size']

            itemlist.append(
                Item(channel=item.channel,
                     action="play",
                     url=url,
                     url_org=filetools.join(path_out, file),
                     server='torrent',
                     title=filetools.join(
                         filetools.basename(path_out.rstrip('/').rstrip('\\')),
                         file).title() + " [%s]" % size,
                     contentTitle=filetools.join(
                         filetools.basename(path_out.rstrip('/').rstrip('\\')),
                         file).title(),
                     contentType="movie",
                     unify=False,
                     torrents_path=torrent_params['torrents_path'],
                     infoLabels={"tmdb_id": "111"},
                     context=context,
                     btdigg=btdigg))
            if len(itemlist) > 1:
                itemlist = sorted(itemlist,
                                  key=lambda it: it.title)  #clasificamos

    return itemlist