Beispiel #1
0
def IgnoreListMenu():
    oc = SubFolderObjectContainer(title2="Ignore list", replace_parent=True)
    for key in ignore_list.key_order:
        values = ignore_list[key]
        for value in values:
            add_ignore_options(oc, key, title=ignore_list.get_title(key, value), rating_key=value, callback_menu=IgnoreMenu)
    return oc
Beispiel #2
0
def ItemDetailsMenu(rating_key, title=None, base_title=None, item_title=None, randomize=None):
    """
    displays the item details menu of an item that doesn't contain any deeper tree, such as a movie or an episode
    :param rating_key:
    :param title:
    :param base_title:
    :param item_title:
    :param randomize:
    :return:
    """
    title = unicode(base_title) + " > " + unicode(title) if base_title else unicode(title)
    item = get_item(rating_key)

    oc = ObjectContainer(title2=title, replace_parent=True)
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, randomize=timestamp()),
        title=u"Refresh: %s" % item_title,
        summary="Refreshes the item, possibly picking up new subtitles on disk",
        thumb=item.thumb or default_thumb
    ))
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, force=True, randomize=timestamp()),
        title=u"Force-Refresh: %s" % item_title,
        summary="Issues a forced refresh, ignoring known subtitles and searching for new ones",
        thumb=item.thumb or default_thumb
    ))
    add_ignore_options(oc, "videos", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    return oc
Beispiel #3
0
def IgnoreListMenu():
    oc = ObjectContainer(title2="Ignore list", replace_parent=True)
    for key in ignore_list.key_order:
        values = ignore_list[key]
        for value in values:
            add_ignore_options(oc, key, title=ignore_list.get_title(key, value), rating_key=value, callback_menu=IgnoreMenu)
    return oc
Beispiel #4
0
def MetadataMenu(
    rating_key, title=None, base_title=None, display_items=False, previous_item_type=None, previous_rating_key=None
):
    title = unicode(title)
    item_title = title
    title = base_title + " > " + title
    oc = ObjectContainer(title2=title, no_cache=True, no_history=True)

    if display_items:
        items = getAllItems(key="children", value=rating_key, base="library/metadata")
        kind, deeper = get_items_info(items)
        # we don't know exactly where we are here, only add ignore option to series
        if should_display_ignore(items, previous=previous_item_type):
            add_ignore_options(oc, "series", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)
        dig_tree(
            oc,
            items,
            MetadataMenu,
            pass_kwargs={
                "base_title": title,
                "display_items": deeper,
                "previous_item_type": kind,
                "previous_rating_key": rating_key,
            },
        )
    else:
        return RefreshItemMenu(rating_key=rating_key, title=title, item_title=item_title)

    return oc
Beispiel #5
0
def SectionFirstLetterMenu(rating_key, title=None, base_title=None, section_title=None):
    """
    displays the contents of a section indexed by its first char (A-Z, 0-9...)
    :param rating_key:
    :param title:
    :param base_title:
    :param section_title:
    :return:
    """
    items = get_all_items(key="first_character", value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)

    title = unicode(title)
    oc = ObjectContainer(title2=section_title, no_cache=True, no_history=True)
    title = base_title + " > " + title
    add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    oc.add(DirectoryObject(
        key=Callback(SectionMenu, title="All", base_title=title, rating_key=rating_key, ignore_options=False),
        title="All"
    )
    )
    return dig_tree(oc, items, FirstLetterMetadataMenu, force_rating_key=rating_key, fill_args={"key": "key"},
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_rating_key": rating_key})
Beispiel #6
0
def SectionMenu(rating_key, title=None, base_title=None, section_title=None, ignore_options=True,
                section_items_key="all"):
    """
    displays the contents of a section
    :param section_items_key:
    :param rating_key:
    :param title:
    :param base_title:
    :param section_title:
    :param ignore_options:
    :return:
    """
    from menu import MetadataMenu
    items = get_all_items(key=section_items_key, value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)
    title = unicode(title)

    section_title = title
    title = base_title + " > " + title
    oc = SubFolderObjectContainer(title2=title, no_cache=True, no_history=True)
    if ignore_options:
        add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    return dig_tree(oc, items, MetadataMenu,
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": "section",
                                 "previous_rating_key": rating_key})
Beispiel #7
0
def SectionFirstLetterMenu(rating_key, title=None, base_title=None, section_title=None, ignore_options=True,
                           section_items_key="all"):
    """
    displays the contents of a section indexed by its first char (A-Z, 0-9...)
    :param ignore_options: ignored
    :param section_items_key: ignored
    :param rating_key:
    :param title:
    :param base_title:
    :param section_title:
    :return:
    """
    from menu import FirstLetterMetadataMenu
    items = get_all_items(key="first_character", value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)

    title = unicode(title)
    oc = SubFolderObjectContainer(title2=section_title, no_cache=True, no_history=True)
    title = base_title + " > " + title
    add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    oc.add(DirectoryObject(
        key=Callback(SectionMenu, title="All", base_title=title, rating_key=rating_key, ignore_options=False),
        title="All"
    )
    )
    return dig_tree(oc, items, FirstLetterMetadataMenu, force_rating_key=rating_key, fill_args={"key": "key"},
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_rating_key": rating_key})
Beispiel #8
0
def MetadataMenu(rating_key, title=None, base_title=None, display_items=False, previous_item_type=None,
                 previous_rating_key=None):
    """
    displays the contents of a section based on whether it has a deeper tree or not (movies->movie (item) list; series->series list)
    :param rating_key:
    :param title:
    :param base_title:
    :param display_items:
    :param previous_item_type:
    :param previous_rating_key:
    :return:
    """
    title = unicode(title)
    item_title = title
    title = base_title + " > " + title
    oc = SubFolderObjectContainer(title2=title, no_cache=True, no_history=True)

    current_kind = get_item_kind_from_rating_key(rating_key)

    if display_items:
        items = get_all_items(key="children", value=rating_key, base="library/metadata")
        kind, deeper = get_items_info(items)
        dig_tree(oc, items, MetadataMenu,
                 pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": kind, "previous_rating_key": rating_key})
        # we don't know exactly where we are here, only add ignore option to series
        if should_display_ignore(items, previous=previous_item_type):
            add_ignore_options(oc, "series", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)

        timeout = 30
        if current_kind == "season":
            timeout = 360
        elif current_kind == "series":
            timeout = 1800

        # add refresh
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=title, refresh_kind=current_kind,
                         previous_rating_key=previous_rating_key, timeout=timeout*1000, randomize=timestamp()),
            title=u"Refresh: %s" % item_title,
            summary="Refreshes the %s, possibly searching for missing and picking up new subtitles on disk" % current_kind
        ))
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=title, force=True,
                         refresh_kind=current_kind, previous_rating_key=previous_rating_key, timeout=timeout*1000,
                         randomize=timestamp()),
            title=u"Auto-Find subtitles: %s" % item_title,
            summary="Issues a forced refresh, ignoring known subtitles and searching for new ones"
        ))
    else:
        return ItemDetailsMenu(rating_key=rating_key, title=title, item_title=item_title)

    return oc
Beispiel #9
0
def SectionMenu(rating_key, title=None, base_title=None, section_title=None, ignore_options=True):
    items = getAllItems(key="all", value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)

    section_title = title
    title = base_title + " > " + title
    oc = ObjectContainer(title2=title, no_cache=True, no_history=True)
    if ignore_options:
        add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    return dig_tree(oc, items, MetadataMenu,
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": "section",
                                 "previous_rating_key": rating_key})
Beispiel #10
0
def SectionMenu(rating_key, title=None, base_title=None, section_title=None, ignore_options=True):
    items = getAllItems(key="all", value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)
    title = unicode(title)

    section_title = title
    title = base_title + " > " + title
    oc = ObjectContainer(title2=title, no_cache=True, no_history=True)
    if ignore_options:
        add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    return dig_tree(oc, items, MetadataMenu,
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": "section",
                                 "previous_rating_key": rating_key})
Beispiel #11
0
def RefreshItemMenu(rating_key, title=None, base_title=None, item_title=None, came_from="/recent"):
    title = unicode(base_title) + " > " + unicode(title) if base_title else unicode(title)
    oc = ObjectContainer(title2=title, replace_parent=True)
    add_ignore_options(oc, "videos", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title),
        title="Refresh: %s" % item_title,
        summary="Refreshes the item, possibly picking up new subtitles on disk"
    ))
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, force=True),
        title="Force-Refresh: %s" % item_title,
        summary="Issues a forced refresh, ignoring known subtitles and searching for new ones"
    ))

    return oc
Beispiel #12
0
def RefreshItemMenu(rating_key, title=None, base_title=None, item_title=None, came_from="/recent"):
    title = unicode(base_title) + " > " + unicode(title) if base_title else unicode(title)
    oc = ObjectContainer(title2=title, replace_parent=True)
    add_ignore_options(oc, "videos", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title),
        title="Refresh: %s" % item_title,
        summary="Refreshes the item, possibly picking up new subtitles on disk"
    ))
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, force=True),
        title="Force-Refresh: %s" % item_title,
        summary="Issues a forced refresh, ignoring known subtitles and searching for new ones"
    ))

    return oc
Beispiel #13
0
def SectionFirstLetterMenu(rating_key, title=None, base_title=None, section_title=None):
    items = getAllItems(key="first_character", value=rating_key, base="library/sections")

    kind, deeper = get_items_info(items)

    title = unicode(title)
    oc = ObjectContainer(title2=section_title, no_cache=True, no_history=True)
    title = base_title + " > " + title
    add_ignore_options(oc, "sections", title=section_title, rating_key=rating_key, callback_menu=IgnoreMenu)

    oc.add(DirectoryObject(
        key=Callback(SectionMenu, title="All", base_title=title, rating_key=rating_key, ignore_options=False),
        title="All"
    )
    )
    return dig_tree(oc, items, FirstLetterMetadataMenu, force_rating_key=rating_key, fill_args={"key": "key"},
                    pass_kwargs={"base_title": title, "display_items": deeper, "previous_rating_key": rating_key})
Beispiel #14
0
def MetadataMenu(rating_key, title=None, base_title=None, display_items=False, previous_item_type=None, previous_rating_key=None):
    title = unicode(title)
    item_title = title
    title = base_title + " > " + title
    oc = ObjectContainer(title2=title, no_cache=True, no_history=True)

    if display_items:
        items = getAllItems(key="children", value=rating_key, base="library/metadata")
        kind, deeper = get_items_info(items)
        # we don't know exactly where we are here, only add ignore option to series
        if should_display_ignore(items, previous=previous_item_type):
            add_ignore_options(oc, "series", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)
        dig_tree(oc, items, MetadataMenu,
                 pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": kind, "previous_rating_key": rating_key})
    else:
        return RefreshItemMenu(rating_key=rating_key, title=title, item_title=item_title)

    return oc
Beispiel #15
0
def MetadataMenu(rating_key, title=None, base_title=None, display_items=False, previous_item_type=None, previous_rating_key=None):
    """
    displays the contents of a section based on whether it has a deeper tree or not (movies->movie (item) list; series->series list)
    :param rating_key:
    :param title:
    :param base_title:
    :param display_items:
    :param previous_item_type:
    :param previous_rating_key:
    :return:
    """
    title = unicode(title)
    item_title = title
    title = base_title + " > " + title
    oc = ObjectContainer(title2=title, no_cache=True, no_history=True)

    if display_items:
        items = get_all_items(key="children", value=rating_key, base="library/metadata")
        kind, deeper = get_items_info(items)
        dig_tree(oc, items, MetadataMenu,
                 pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": kind, "previous_rating_key": rating_key})
        # we don't know exactly where we are here, only add ignore option to series
        if should_display_ignore(items, previous=previous_item_type):
            add_ignore_options(oc, "series", title=item_title, rating_key=rating_key, callback_menu=IgnoreMenu)

        # add refresh
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, refresh_kind=kind, previous_rating_key=previous_rating_key,
                         timeout=16000, randomize=timestamp()),
            title=u"Refresh: %s" % item_title,
            summary="Refreshes the item, possibly picking up new subtitles on disk"
        ))
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, force=True, refresh_kind=kind,
                         previous_rating_key=previous_rating_key, timeout=16000),
            title=u"Force-Refresh: %s" % item_title,
            summary="Issues a forced refresh, ignoring known subtitles and searching for new ones"
        ))
    else:
        return ItemDetailsMenu(rating_key=rating_key, title=title, item_title=item_title)

    return oc
Beispiel #16
0
def MetadataMenu(rating_key, title=None, base_title=None, display_items=False, previous_item_type=None,
                 previous_rating_key=None, message=None, header=None, randomize=None):
    """
    displays the contents of a section based on whether it has a deeper tree or not (movies->movie (item) list; series->series list)
    :param rating_key:
    :param title:
    :param base_title:
    :param display_items:
    :param previous_item_type:
    :param previous_rating_key:
    :return:
    """
    title = unicode(title)
    item_title = title
    title = base_title + " > " + title
    oc = SubFolderObjectContainer(title2=title, no_cache=True, no_history=True, header=header, message=message,
                                  view_group="full_details")

    current_kind = get_item_kind_from_rating_key(rating_key)

    if display_items:
        timeout = 30
        show = None

        # add back to series for season
        if current_kind == "season":
            timeout = 720

            show = get_item(previous_rating_key)
            oc.add(DirectoryObject(
                key=Callback(MetadataMenu, rating_key=show.rating_key, title=show.title, base_title=show.section.title,
                             previous_item_type="section", display_items=True, randomize=timestamp()),
                title=_(u"< Back to %s", show.title),
                thumb=show.thumb or default_thumb
            ))
        elif current_kind == "series":
            # it shouldn't take more than 6 minutes to scan all of a series' files and determine the force refresh
            timeout = 3600

        items = get_all_items(key="children", value=rating_key, base="library/metadata")
        kind, deeper = get_items_info(items)
        dig_tree(oc, items, MetadataMenu,
                 pass_kwargs={"base_title": title, "display_items": deeper, "previous_item_type": kind,
                              "previous_rating_key": rating_key})

        # we don't know exactly where we are here, only add ignore option to series
        if current_kind in ("series", "season"):
            item = get_item(rating_key)
            sub_title = get_item_title(item)
            add_ignore_options(oc, current_kind, title=sub_title, rating_key=rating_key, callback_menu=IgnoreMenu)

        # mass-extract embedded
        if current_kind == "season" and config.plex_transcoder:
            for lang in config.lang_list:
                oc.add(DirectoryObject(
                    key=Callback(SeasonExtractEmbedded, rating_key=rating_key, language=lang,
                                 base_title=show.section.title, display_items=display_items, item_title=item_title,
                                 title=title,
                                 previous_item_type=previous_item_type, with_mods=True,
                                 previous_rating_key=previous_rating_key, randomize=timestamp()),
                    title=_(u"Extract missing %(language)s embedded subtitles", language=display_language(lang)),
                    summary=_("Extracts the not yet extracted embedded subtitles of all episodes for the current "
                              "season with all configured default modifications")
                ))
                oc.add(DirectoryObject(
                    key=Callback(SeasonExtractEmbedded, rating_key=rating_key, language=lang,
                                 base_title=show.section.title, display_items=display_items, item_title=item_title,
                                 title=title, force=True,
                                 previous_item_type=previous_item_type, with_mods=True,
                                 previous_rating_key=previous_rating_key, randomize=timestamp()),
                    title=_(u"Extract and activate %(language)s embedded subtitles", language=display_language(lang)),
                    summary=_("Extracts embedded subtitles of all episodes for the current season "
                              "with all configured default modifications")
                ))

        # add refresh
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=title, refresh_kind=current_kind,
                         previous_rating_key=previous_rating_key, timeout=timeout * 1000, randomize=timestamp()),
            title=_(u"Refresh: %s", item_title),
            summary=_("Refreshes %(the_movie_series_season_episode)s, possibly searching for missing and picking up "
                      "new subtitles on disk", the_movie_series_season_episode=_(u"the %s" % current_kind))
        ))
        oc.add(DirectoryObject(
            key=Callback(RefreshItem, rating_key=rating_key, item_title=title, force=True,
                         refresh_kind=current_kind, previous_rating_key=previous_rating_key, timeout=timeout * 1000,
                         randomize=timestamp()),
            title=_(u"Auto-Find subtitles: %s", item_title),
            summary=_("Issues a forced refresh, ignoring known subtitles and searching for new ones")
        ))
    else:
        return ItemDetailsMenu(rating_key=rating_key, title=title, item_title=item_title)

    return oc
def ItemDetailsMenu(rating_key, title=None, base_title=None, item_title=None, randomize=None, header=None):
    """
    displays the item details menu of an item that doesn't contain any deeper tree, such as a movie or an episode
    :param rating_key:
    :param title:
    :param base_title:
    :param item_title:
    :param randomize:
    :return:
    """
    from interface.main import IgnoreMenu

    title = unicode(base_title) + " > " + unicode(title) if base_title else unicode(title)
    item = plex_item = get_item(rating_key)
    current_kind = get_item_kind_from_rating_key(rating_key)

    timeout = 30

    oc = SubFolderObjectContainer(title2=title, replace_parent=True, header=header)

    if not item:
        oc.add(DirectoryObject(
            key=Callback(ItemDetailsMenu, rating_key=rating_key, title=title, base_title=base_title,
                         item_title=item_title, randomize=timestamp()),
            title=u"Item not found: %s!" % item_title,
            summary="Plex didn't return any information about the item, please refresh it and come back later",
            thumb=default_thumb
        ))
        return oc

    # add back to season for episode
    if current_kind == "episode":
        from interface.menu import MetadataMenu
        show = get_item(item.show.rating_key)
        season = get_item(item.season.rating_key)

        oc.add(DirectoryObject(
            key=Callback(MetadataMenu, rating_key=season.rating_key, title=season.title, base_title=show.title,
                         previous_item_type="show", previous_rating_key=show.rating_key,
                         display_items=True, randomize=timestamp()),
            title=u"< Back to %s" % season.title,
            summary="Back to %s > %s" % (show.title, season.title),
            thumb=season.thumb or default_thumb
        ))

    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, randomize=timestamp(),
                     timeout=timeout * 1000),
        title=u"Refresh: %s" % item_title,
        summary="Refreshes the %s, possibly searching for missing and picking up new subtitles on disk" % current_kind,
        thumb=item.thumb or default_thumb
    ))
    oc.add(DirectoryObject(
        key=Callback(RefreshItem, rating_key=rating_key, item_title=item_title, force=True, randomize=timestamp(),
                     timeout=timeout * 1000),
        title=u"Force-find subtitles: %s" % item_title,
        summary="Issues a forced refresh, ignoring known subtitles and searching for new ones",
        thumb=item.thumb or default_thumb
    ))

    # get stored subtitle info for item id
    subtitle_storage = get_subtitle_storage()
    stored_subs = subtitle_storage.load_or_new(item)

    # look for subtitles for all available media parts and all of their languages
    has_multiple_parts = len(plex_item.media) > 1
    part_index = 0
    for media in plex_item.media:
        for part in media.parts:
            filename = os.path.basename(part.file)
            if not os.path.exists(part.file):
                continue

            part_id = str(part.id)
            part_index += 1

            part_index_addon = ""
            part_summary_addon = ""
            if has_multiple_parts:
                part_index_addon = u"File %s: " % part_index
                part_summary_addon = "%s " % filename

            # iterate through all configured languages
            for lang in config.lang_list:
                # get corresponding stored subtitle data for that media part (physical media item), for language
                current_sub = stored_subs.get_any(part_id, lang)
                current_sub_id = None
                current_sub_provider_name = None

                summary = u"%sNo current subtitle in storage" % part_summary_addon
                current_score = None
                if current_sub:
                    current_sub_id = current_sub.id
                    current_sub_provider_name = current_sub.provider_name
                    current_score = current_sub.score

                    summary = u"%sCurrent subtitle: %s (added: %s, %s), Language: %s, Score: %i, Storage: %s" % \
                              (part_summary_addon, current_sub.provider_name, df(current_sub.date_added),
                               current_sub.mode_verbose, display_language(lang), current_sub.score,
                               current_sub.storage_type)

                    oc.add(DirectoryObject(
                        key=Callback(SubtitleOptionsMenu, rating_key=rating_key, part_id=part_id, title=title,
                                     item_title=item_title, language=lang, language_name=display_language(lang),
                                     current_id=current_sub_id,
                                     item_type=plex_item.type, filename=filename, current_data=summary,
                                     randomize=timestamp(), current_provider=current_sub_provider_name,
                                     current_score=current_score),
                        title=u"%sManage %s subtitle" % (part_index_addon, display_language(lang)),
                        summary=summary
                    ))
                else:
                    oc.add(DirectoryObject(
                        key=Callback(ListAvailableSubsForItemMenu, rating_key=rating_key, part_id=part_id, title=title,
                                     item_title=item_title, language=lang, language_name=display_language(lang),
                                     current_id=current_sub_id,
                                     item_type=plex_item.type, filename=filename, current_data=summary,
                                     randomize=timestamp(), current_provider=current_sub_provider_name,
                                     current_score=current_score),
                        title=u"%sList %s subtitles" % (part_index_addon, display_language(lang)),
                        summary=summary
                    ))

            if config.plex_transcoder:
                # embedded subtitles
                embedded_count = 0
                embedded_langs = []
                for stream in part.streams:
                    # subtitle stream
                    if stream.stream_type == 3 and not stream.stream_key and stream.codec in TEXT_SUBTITLE_EXTS:
                        lang = get_language_from_stream(stream.language_code)

                        if not lang and config.treat_und_as_first:
                            lang = list(config.lang_list)[0]

                        if lang:
                            embedded_langs.append(lang)
                            embedded_count += 1

                if embedded_count:
                    oc.add(DirectoryObject(
                        key=Callback(ListEmbeddedSubsForItemMenu, rating_key=rating_key, part_id=part_id, title=title,
                                     item_type=plex_item.type, item_title=item_title, base_title=base_title,
                                     randomize=timestamp()),
                        title=u"%sEmbedded subtitles (%s)" % (part_index_addon, ", ".join(display_language(l) for l in
                                                                                          set(embedded_langs))),
                        summary=u"Extract and activate embedded subtitle streams"
                    ))

    ignore_title = item_title
    if current_kind == "episode":
        ignore_title = get_item_title(item)
    add_ignore_options(oc, "videos", title=ignore_title, rating_key=rating_key, callback_menu=IgnoreMenu)
    subtitle_storage.destroy()

    return oc
Beispiel #18
0
def ItemDetailsMenu(rating_key,
                    title=None,
                    base_title=None,
                    item_title=None,
                    randomize=None):
    """
    displays the item details menu of an item that doesn't contain any deeper tree, such as a movie or an episode
    :param rating_key:
    :param title:
    :param base_title:
    :param item_title:
    :param randomize:
    :return:
    """
    title = unicode(base_title) + " > " + unicode(
        title) if base_title else unicode(title)
    item = get_item(rating_key)
    current_kind = get_item_kind_from_rating_key(rating_key)

    timeout = 30

    oc = SubFolderObjectContainer(title2=title, replace_parent=True)
    oc.add(
        DirectoryObject(
            key=Callback(RefreshItem,
                         rating_key=rating_key,
                         item_title=item_title,
                         randomize=timestamp(),
                         timeout=timeout * 1000),
            title=u"Refresh: %s" % item_title,
            summary=
            "Refreshes the %s, possibly searching for missing and picking up new subtitles on disk"
            % current_kind,
            thumb=item.thumb or default_thumb))
    oc.add(
        DirectoryObject(
            key=Callback(RefreshItem,
                         rating_key=rating_key,
                         item_title=item_title,
                         force=True,
                         randomize=timestamp(),
                         timeout=timeout * 1000),
            title=u"Auto-search: %s" % item_title,
            summary=
            "Issues a forced refresh, ignoring known subtitles and searching for new ones",
            thumb=item.thumb or default_thumb))

    # get stored subtitle info for item id
    subtitle_storage = get_subtitle_storage()
    stored_subs = subtitle_storage.load_or_new(item)

    # get the plex item
    plex_item = list(Plex["library"].metadata(rating_key))[0]

    # get current media info for that item
    media = plex_item.media

    # look for subtitles for all available media parts and all of their languages
    for part in media.parts:
        filename = os.path.basename(part.file)
        part_id = str(part.id)

        # iterate through all configured languages
        for lang in config.lang_list:
            lang_a2 = lang.alpha2
            # ietf lang?
            if cast_bool(Prefs["subtitles.language.ietf"]) and "-" in lang_a2:
                lang_a2 = lang_a2.split("-")[0]

            # get corresponding stored subtitle data for that media part (physical media item), for language
            current_sub = stored_subs.get_any(part_id, lang_a2)
            current_sub_id = None
            current_sub_provider_name = None

            summary = u"No current subtitle in storage"
            current_score = None
            if current_sub:
                current_sub_id = current_sub.id
                current_sub_provider_name = current_sub.provider_name
                current_score = current_sub.score

                summary = u"Current subtitle: %s (added: %s, %s), Language: %s, Score: %i, Storage: %s" % \
                          (current_sub.provider_name, df(current_sub.date_added), current_sub.mode_verbose, lang,
                           current_sub.score, current_sub.storage_type)

            oc.add(
                DirectoryObject(key=Callback(
                    ListAvailableSubsForItemMenu,
                    rating_key=rating_key,
                    part_id=part_id,
                    title=title,
                    item_title=item_title,
                    language=lang,
                    current_id=current_sub_id,
                    item_type=plex_item.type,
                    filename=filename,
                    current_data=summary,
                    randomize=timestamp(),
                    current_provider=current_sub_provider_name,
                    current_score=current_score),
                                title=u"List %s subtitles" % lang.name,
                                summary=summary))

    add_ignore_options(oc,
                       "videos",
                       title=item_title,
                       rating_key=rating_key,
                       callback_menu=IgnoreMenu)

    return oc
Beispiel #19
0
def ItemDetailsMenu(rating_key,
                    title=None,
                    base_title=None,
                    item_title=None,
                    randomize=None):
    """
    displays the item details menu of an item that doesn't contain any deeper tree, such as a movie or an episode
    :param rating_key:
    :param title:
    :param base_title:
    :param item_title:
    :param randomize:
    :return:
    """
    from interface.main import IgnoreMenu

    title = unicode(base_title) + " > " + unicode(
        title) if base_title else unicode(title)
    item = get_item(rating_key)
    current_kind = get_item_kind_from_rating_key(rating_key)

    timeout = 30

    oc = SubFolderObjectContainer(title2=title, replace_parent=True)

    # add back to season for episode
    if current_kind == "episode":
        from interface.menu import MetadataMenu
        show = get_item(item.show.rating_key)
        season = get_item(item.season.rating_key)

        oc.add(
            DirectoryObject(key=Callback(MetadataMenu,
                                         rating_key=season.rating_key,
                                         title=season.title,
                                         base_title=show.title,
                                         previous_item_type="show",
                                         previous_rating_key=show.rating_key,
                                         display_items=True,
                                         randomize=timestamp()),
                            title=u"< Back to %s" % season.title,
                            summary="Back to %s > %s" %
                            (show.title, season.title),
                            thumb=season.thumb or default_thumb))

    oc.add(
        DirectoryObject(
            key=Callback(RefreshItem,
                         rating_key=rating_key,
                         item_title=item_title,
                         randomize=timestamp(),
                         timeout=timeout * 1000),
            title=u"Refresh: %s" % item_title,
            summary=
            "Refreshes the %s, possibly searching for missing and picking up new subtitles on disk"
            % current_kind,
            thumb=item.thumb or default_thumb))
    oc.add(
        DirectoryObject(
            key=Callback(RefreshItem,
                         rating_key=rating_key,
                         item_title=item_title,
                         force=True,
                         randomize=timestamp(),
                         timeout=timeout * 1000),
            title=u"Force-find subtitles: %s" % item_title,
            summary=
            "Issues a forced refresh, ignoring known subtitles and searching for new ones",
            thumb=item.thumb or default_thumb))

    # get stored subtitle info for item id
    subtitle_storage = get_subtitle_storage()
    stored_subs = subtitle_storage.load_or_new(item)

    # get the plex item
    plex_item = get_item(rating_key)

    # look for subtitles for all available media parts and all of their languages
    has_multiple_parts = len(plex_item.media) > 1
    part_index = 0
    for media in plex_item.media:
        for part in media.parts:
            filename = os.path.basename(part.file)
            if not os.path.exists(part.file):
                continue

            part_id = str(part.id)
            part_index += 1

            # iterate through all configured languages
            for lang in config.lang_list:
                # get corresponding stored subtitle data for that media part (physical media item), for language
                current_sub = stored_subs.get_any(part_id, lang)
                current_sub_id = None
                current_sub_provider_name = None

                part_index_addon = ""
                part_summary_addon = ""
                if has_multiple_parts:
                    part_index_addon = u"File %s: " % part_index
                    part_summary_addon = "%s " % filename

                summary = u"%sNo current subtitle in storage" % part_summary_addon
                current_score = None
                if current_sub:
                    current_sub_id = current_sub.id
                    current_sub_provider_name = current_sub.provider_name
                    current_score = current_sub.score

                    summary = u"%sCurrent subtitle: %s (added: %s, %s), Language: %s, Score: %i, Storage: %s" % \
                              (part_summary_addon, current_sub.provider_name, df(current_sub.date_added),
                               current_sub.mode_verbose, lang, current_sub.score, current_sub.storage_type)

                    oc.add(
                        DirectoryObject(key=Callback(
                            SubtitleOptionsMenu,
                            rating_key=rating_key,
                            part_id=part_id,
                            title=title,
                            item_title=item_title,
                            language=lang,
                            language_name=lang.name,
                            current_id=current_sub_id,
                            item_type=plex_item.type,
                            filename=filename,
                            current_data=summary,
                            randomize=timestamp(),
                            current_provider=current_sub_provider_name,
                            current_score=current_score),
                                        title=u"%sActions for %s subtitle" %
                                        (part_index_addon, lang.name),
                                        summary=summary))
                else:
                    oc.add(
                        DirectoryObject(key=Callback(
                            ListAvailableSubsForItemMenu,
                            rating_key=rating_key,
                            part_id=part_id,
                            title=title,
                            item_title=item_title,
                            language=lang,
                            language_name=lang.name,
                            current_id=current_sub_id,
                            item_type=plex_item.type,
                            filename=filename,
                            current_data=summary,
                            randomize=timestamp(),
                            current_provider=current_sub_provider_name,
                            current_score=current_score),
                                        title=u"%sList %s subtitles" %
                                        (part_index_addon, lang.name),
                                        summary=summary))

    add_ignore_options(oc,
                       "videos",
                       title=item_title,
                       rating_key=rating_key,
                       callback_menu=IgnoreMenu)
    subtitle_storage.destroy()

    return oc