Пример #1
0
def browse_trailers():
    per_page = plugin.get_setting('per-page', int)
    skip = plugin.request.arg('skip')
    scraper = get_scraper()
    trailers = scraper.browse_trailers(skip)
    items = []
    if len(trailers) < per_page:
        skip = (skip or 1) + 1
        trailers.extend(scraper.browse_trailers(skip))
    total = len(trailers)
    if skip > 2:
        skip_prev = max(skip - 1, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(trailers, BATCH_EPISODES_COUNT):
        if abort_requested():
            break
        items = itemify_trailers(batch_res)
        plugin.add_items(with_fanart(items), total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 1) + 1
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
        plugin.add_items(with_fanart(items), len(items))
    plugin.finish(update_listing=skip > 2)
Пример #2
0
def browse_library():
    plugin.set_content('tvshows')
    scraper = get_scraper()
    library = library_items()
    total = len(library)
    for batch_ids in batch(library, BATCH_SERIES_COUNT):
        if abort_requested():
            break
        series = scraper.get_series_bulk(batch_ids)
        items = [itemify_series(series[i], highlight_library_items=False) for i in batch_ids]
        plugin.add_items(with_fanart(items), total)
    plugin.finish(sort_methods=['unsorted', 'label'])
Пример #3
0
def browse_all_series():
    plugin.set_content('tvshows')
    scraper = get_scraper()
    all_series_ids = scraper.get_all_series_ids()
    total = len(all_series_ids)
    for batch_ids in batch(all_series_ids, BATCH_SERIES_COUNT):
        if abort_requested():
            break
        series = scraper.get_series_bulk(batch_ids)
        items = [itemify_series(series[i]) for i in batch_ids]
        plugin.add_items(with_fanart(items), total)
    plugin.finish()
Пример #4
0
def browse_all_series():
    plugin.set_content('tvshows')
    scraper = get_scraper()
    all_series_ids = scraper.get_all_series_ids()
    total = len(all_series_ids)
    for batch_ids in batch(all_series_ids, BATCH_SERIES_COUNT):
        if abort_requested():
            break
        series = scraper.get_series_bulk(batch_ids)
        items = [itemify_series(series[i]) for i in batch_ids]
        plugin.add_items(with_fanart(items), total)
    plugin.finish()
Пример #5
0
def browse_favorites():
    plugin.set_content('tvshows')
    scraper = get_scraper()
    library = scraper.get_favorite_series()
    total = len(library)
    for batch_ids in batch(library, BATCH_SERIES_COUNT):
        if abort_requested():
            break
        series = scraper.get_series_bulk(batch_ids)
        items = [itemify_series(series[i]) for i in batch_ids]
        plugin.add_items(with_fanart(items), total)
    plugin.finish(sort_methods=['unsorted', 'label'])
Пример #6
0
def index():
    plugin.set_content('episodes')
    skip = plugin.request.arg('skip')
    per_page = plugin.get_setting('per-page', int)
    scraper = get_scraper()
    episodes = scraper.browse_episodes(skip)
    if episodes and not skip:
        check_last_episode(episodes[0])
    check_first_start()
    new_episodes = library_new_episodes()
    new_str = "(%s) " % tf.color(str(
        len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else ""
    total = len(episodes)
    header = [
        {
            'label': lang(40401),
            'path': plugin.url_for('browse_all_series')
        },
        {
            'label': lang(40407) % new_str,
            'path': plugin.url_for('browse_library'),
            'context_menu': update_library_menu()
        },
    ]
    items = []
    if skip:
        skip_prev = max(skip - per_page, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    elif header:
        items.extend(header)
        total += len(header)
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(episodes, BATCH_EPISODES_COUNT):
        if abort_requested():
            break
        items = itemify_episodes(batch_res)
        plugin.add_items(with_fanart(items), total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 0) + per_page
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
    plugin.finish(items=with_fanart(items),
                  cache_to_disc=False,
                  update_listing=skip is not None)
Пример #7
0
def update_library():
    plugin.log.info("Starting LostFilm.TV library update...")
    progress = xbmcgui.DialogProgressBG()
    scraper = get_scraper()
    series_ids = library_items()
    if plugin.get_setting('sync_favorites', bool) and plugin.get_setting(
            'enable_sync', bool):
        fav_ids = scraper.get_favorite_series()
        series_ids = list(set(series_ids + fav_ids))
    total = len(series_ids)
    lib = get_library()
    processed = 0
    with closing(progress):
        progress.create(lang(30000), lang(40409))
        series_episodes = {}
        for ids in batch(series_ids, BATCH_SERIES_COUNT):
            series_episodes.update(scraper.get_series_episodes_bulk(ids))
            processed += len(ids)
            progress.update(processed * 100 / total)
            if abort_requested():
                return
        medias = []
        for series_id, episodes in series_episodes.iteritems():
            medias.extend(
                library.Episode(folder=e.series_title,
                                title=e.episode_title.replace(u'й', u'й'),
                                season_number=e.season_number,
                                episode_number=e.episode_numbers,
                                url=episode_url(e),
                                time_added=e.release_date,
                                episode=e) for e in episodes
                if not e.is_complete_season)
        lib.sync(medias)
        new_episodes = library_new_episodes()
        new_episodes |= NewEpisodes(lib.added_medias)
    if plugin.get_setting('update-xbmc-library', bool):
        if lib.added_medias or lib.created_medias or lib.updated_medias:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library update...")
            plugin.update_library('video',
                                  plugin.get_setting('library-path', unicode))
        if lib.removed_files:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library clean...")
            plugin.clean_library('video')
    plugin.log.info("LostFilm.TV library update finished.")
    return lib.added_medias or lib.created_medias or lib.updated_medias or lib.removed_files
Пример #8
0
def index():
    plugin.set_content('episodes')
    skip = plugin.request.arg('skip')
    per_page = plugin.get_setting('per-page', int)
    scraper = get_scraper()
    episodes = scraper.browse_episodes(skip)
    if episodes and not skip:
        check_last_episode(episodes[0])
    check_first_start()
    new_episodes = library_new_episodes()
    new_str = "(%s) " % tf.color(str(len(new_episodes)), NEW_LIBRARY_ITEM_COLOR) if new_episodes else ""
    total = len(episodes)
    header = [
        {'label': lang(40401), 'path': plugin.url_for('browse_all_series')},
        {'label': lang(40407) % new_str, 'path': plugin.url_for('browse_library'),
         'context_menu': update_library_menu()},
    ]
    items = []
    if skip:
        skip_prev = max(skip - per_page, 0)
        total += 1
        items.append({
            'label': lang(34003),
            'path': plugin.request.url_with_params(skip=skip_prev)
        })
    elif header:
        items.extend(header)
        total += len(header)
    plugin.add_items(with_fanart(items), total)
    for batch_res in batch(episodes, BATCH_EPISODES_COUNT):
        if abort_requested():
            break
        items = itemify_episodes(batch_res)
        plugin.add_items(with_fanart(items), total)
    items = []
    if scraper.has_more:
        skip_next = (skip or 0) + per_page
        items.append({
            'label': lang(34004),
            'path': plugin.request.url_with_params(skip=skip_next)
        })
    plugin.finish(items=with_fanart(items),
                  cache_to_disc=False,
                  update_listing=skip is not None)
Пример #9
0
def search():
    skbd = xbmc.Keyboard()
    skbd.setHeading(lang(40423))
    skbd.doModal()
    if skbd.isConfirmed():
        query = skbd.getText()
    else:
        return None
    plugin.set_content('tvshows')
    scraper = get_scraper()
    library = scraper.search_serial(query)
    total = len(library)
    for batch_ids in batch(library, BATCH_SERIES_COUNT):
        if abort_requested():
            break
        series = scraper.get_series_bulk(batch_ids)
        items = [itemify_series(series[i]) for i in batch_ids]
        plugin.add_items(with_fanart(items), total)
    plugin.finish(sort_methods=['unsorted', 'label'])
Пример #10
0
def update_library():
    plugin.log.info("Starting LostFilm.TV library update...")
    progress = xbmcgui.DialogProgressBG()
    scraper = get_scraper()
    series_ids = library_items()
    total = len(series_ids)
    lib = get_library()
    processed = 0
    with closing(progress):
        progress.create(lang(30000), lang(40409))
        series_episodes = {}
        for ids in batch(series_ids, BATCH_SERIES_COUNT):
            series_episodes.update(scraper.get_series_episodes_bulk(ids))
            sleep(2000)
            processed += len(ids)
            progress.update(processed * 100 / total)
            if abort_requested():
                return
        medias = []
        for series_id, episodes in series_episodes.iteritems():
            medias.extend(library.Episode(folder=e.series_title, title=e.episode_title,
                                          season_number=e.season_number, episode_number=e.episode_numbers,
                                          url=episode_url(e), time_added=e.release_date,
                                          episode=e)
                          for e in episodes if not e.is_complete_season)
        lib.sync(medias)
        new_episodes = library_new_episodes()
        new_episodes |= NewEpisodes(lib.added_medias)
    if plugin.get_setting('update-xbmc-library', bool):
        if lib.added_medias or lib.created_medias or lib.updated_medias:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library update...")
            plugin.update_library('video', plugin.get_setting('library-path', unicode))
        if lib.removed_files:
            plugin.wait_library_scan()
            plugin.log.info("Starting XBMC library clean...")
            plugin.clean_library('video')
    plugin.log.info("LostFilm.TV library update finished.")
    return lib.added_medias or lib.created_medias or lib.updated_medias or lib.removed_files