예제 #1
0
    def build_title(current, account):
        # <mode>
        title = normalize(SyncMode.title(current.mode))

        # Task Progress
        percent = current.progress.percent

        if percent is not None:
            title += ' (%2d%%)' % percent

        # Account Name (only display outside of account-specific menus)
        if account is None:
            title += ' (%s)' % current.account.name

        return title
예제 #2
0
    def build_title(current, account):
        # <mode>
        title = normalize(SyncMode.title(current.mode))

        # Task Progress
        percent = current.progress.percent

        if percent is not None:
            title += ' (%2d%%)' % percent

        # Account Name (only display outside of account-specific menus)
        if account is None:
            title += ' (%s)' % current.account.name

        return title
예제 #3
0
def ControlsMenu(account_id=1,
                 title=None,
                 message=None,
                 refresh=None,
                 message_only=False,
                 *args,
                 **kwargs):
    account = AccountManager.get(Account.id == account_id)

    # Build sync controls menu
    oc = ObjectContainer(title2=_("Sync (%s)") % account.name,
                         no_cache=True,
                         art=function_path('Cover.png',
                                           account_id=account.id,
                                           refresh=account.refreshed_ts))

    # Start result message
    if title and message:
        oc.add(
            DirectoryObject(key=Callback(ControlsMenu,
                                         account_id=account.id,
                                         refresh=timestamp()),
                            title=pad_title(title),
                            summary=message))

        if message_only:
            return oc

    # Active sync status
    Active.create(oc,
                  callback=Callback(ControlsMenu,
                                    account_id=account.id,
                                    refresh=timestamp()),
                  account=account)

    #
    # Full
    #

    oc.add(
        DirectoryObject(key=Trigger.callback(Synchronize, account),
                        title=pad_title(SyncMode.title(SyncMode.Full)),
                        summary=Status.build(account, SyncMode.Full),
                        thumb=R("icon-sync.png"),
                        art=function_path('Cover.png',
                                          account_id=account.id,
                                          refresh=account.refreshed_ts)))

    #
    # Pull
    #

    oc.add(
        DirectoryObject(key=Trigger.callback(Pull, account),
                        title=pad_title(
                            _('%s from Trakt.tv') %
                            SyncMode.title(SyncMode.Pull)),
                        summary=Status.build(account, SyncMode.Pull),
                        thumb=R("icon-sync_down.png"),
                        art=function_path('Cover.png',
                                          account_id=account.id,
                                          refresh=account.refreshed_ts)))

    oc.add(
        DirectoryObject(key=Trigger.callback(FastPull, account),
                        title=pad_title(
                            _('%s from Trakt.tv') %
                            SyncMode.title(SyncMode.FastPull)),
                        summary=Status.build(account, SyncMode.FastPull),
                        thumb=R("icon-sync_down.png"),
                        art=function_path('Cover.png',
                                          account_id=account.id,
                                          refresh=account.refreshed_ts)))

    #
    # Push
    #

    p_account = account.plex

    try:
        # Retrieve account libraries/sections
        with p_account.authorization():
            sections = Plex['library'].sections()
    except Exception as ex:
        # Build message
        if p_account is None:
            message = _("Plex account hasn't been authenticated")
        else:
            message = str(ex.message or ex)

        # Redirect to error message
        log.warn('Unable to retrieve account libraries/sections: %s',
                 message,
                 exc_info=True)

        return redirect('/sync',
                        account_id=account_id,
                        title=_('Error'),
                        message=message,
                        message_only=True)

    section_keys = []

    f_allow, f_deny = Filters.get('filter_sections')

    for section in sections.filter(['show', 'movie'], titles=f_allow):
        oc.add(
            DirectoryObject(
                key=Trigger.callback(Push, account, section),
                title=pad_title(
                    _('%s "%s" to Trakt.tv') %
                    (SyncMode.title(SyncMode.Push), section.title)),
                summary=Status.build(account, SyncMode.Push, section.key),
                thumb=R("icon-sync_up.png"),
                art=function_path('Cover.png',
                                  account_id=account.id,
                                  refresh=account.refreshed_ts)))
        section_keys.append(section.key)

    if len(section_keys) > 1:
        oc.add(
            DirectoryObject(key=Trigger.callback(Push, account),
                            title=pad_title(
                                _('%s all to Trakt.tv') %
                                SyncMode.title(SyncMode.Push)),
                            summary=Status.build(account, SyncMode.Push),
                            thumb=R("icon-sync_up.png"),
                            art=function_path('Cover.png',
                                              account_id=account.id,
                                              refresh=account.refreshed_ts)))

    return oc
예제 #4
0
def ControlsMenu(account_id=1, title=None, message=None, refresh=None, message_only=False, *args, **kwargs):
    account = AccountManager.get(Account.id == account_id)

    # Build sync controls menu
    oc = ObjectContainer(
        title2=_("Sync (%s)") % account.name,
        no_cache=True,

        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    )

    # Start result message
    if title and message:
        oc.add(DirectoryObject(
            key=Callback(ControlsMenu, account_id=account.id, refresh=timestamp()),
            title=pad_title(title),
            summary=message
        ))

        if message_only:
            return oc

    # Active sync status
    Active.create(
        oc,
        callback=Callback(ControlsMenu, account_id=account.id, refresh=timestamp()),
        account=account
    )

    #
    # Full
    #

    oc.add(DirectoryObject(
        key=Trigger.callback(Synchronize, account),
        title=pad_title(SyncMode.title(SyncMode.Full)),
        summary=Status.build(account, SyncMode.Full),

        thumb=R("icon-sync.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    #
    # Pull
    #

    oc.add(DirectoryObject(
        key=Trigger.callback(Pull, account),
        title=pad_title(_('%s from Trakt.tv') % SyncMode.title(SyncMode.Pull)),
        summary=Status.build(account, SyncMode.Pull),

        thumb=R("icon-sync_down.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    oc.add(DirectoryObject(
        key=Trigger.callback(FastPull, account),
        title=pad_title(_('%s from Trakt.tv') % SyncMode.title(SyncMode.FastPull)),
        summary=Status.build(account, SyncMode.FastPull),

        thumb=R("icon-sync_down.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    #
    # Push
    #

    p_account = account.plex

    try:
        # Retrieve account libraries/sections
        with p_account.authorization():
            sections = Plex['library'].sections()
    except Exception as ex:
        # Build message
        if p_account is None:
            message = _("Plex account hasn't been authenticated")
        else:
            message = str(ex.message or ex)

        # Redirect to error message
        log.warn('Unable to retrieve account libraries/sections: %s', message, exc_info=True)

        return redirect('/sync',
            account_id=account_id,
            title=_('Error'),
            message=message,
            message_only=True
        )

    section_keys = []

    f_allow, f_deny = Filters.get('filter_sections')

    for section in sections.filter(['show', 'movie'], titles=f_allow):
        oc.add(DirectoryObject(
            key=Trigger.callback(Push, account, section),
            title=pad_title(_('%s "%s" to Trakt.tv') % (SyncMode.title(SyncMode.Push), section.title)),
            summary=Status.build(account, SyncMode.Push, section.key),

            thumb=R("icon-sync_up.png"),
            art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
        ))
        section_keys.append(section.key)

    if len(section_keys) > 1:
        oc.add(DirectoryObject(
            key=Trigger.callback(Push, account),
            title=pad_title(_('%s all to Trakt.tv') % SyncMode.title(SyncMode.Push)),
            summary=Status.build(account, SyncMode.Push),

            thumb=R("icon-sync_up.png"),
            art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
        ))

    return oc
예제 #5
0
                        account_id=account_id,
                        title=_('Error'),
                        message=message,
                        message_only=True)

    section_keys = []

    f_allow, f_deny = Filters.get('filter_sections')

    for section in sections.filter(['show', 'movie'], titles=f_allow):
        oc.add(
            DirectoryObject(
                key=Trigger.callback(Push, account, section),
                title=pad_title(
                    _('%s "%s" to Trakt.tv') %
                    (SyncMode.title(SyncMode.Push), section.title)),
                summary=Status.build(account, SyncMode.Push, section.key),
                thumb=R("icon-sync_up.png"),
                art=function_path('Cover.png',
                                  account_id=account.id,
                                  refresh=account.refreshed_ts)))
        section_keys.append(section.key)

    if len(section_keys) > 1:
        oc.add(
            DirectoryObject(key=Trigger.callback(Push, account),
                            title=pad_title(
                                _('%s all to Trakt.tv') %
                                SyncMode.title(SyncMode.Push)),
                            summary=Status.build(account, SyncMode.Push),
                            thumb=R("icon-sync_up.png"),
예제 #6
0
def ControlsMenu(account_id=1, title=None, message=None, refresh=None, message_only=False):
    account = AccountManager.get(Account.id == account_id)

    # Build sync controls menu
    oc = ObjectContainer(
        title2=LF('controls:title', account.name),
        no_cache=True,

        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    )

    # Start result message
    if title and message:
        oc.add(DirectoryObject(
            key=Callback(ControlsMenu, account_id=account.id, refresh=timestamp()),
            title=pad_title(title),
            summary=message
        ))

        if message_only:
            return oc

    # Active sync status
    Active.create(
        oc,
        callback=Callback(ControlsMenu, account_id=account.id, refresh=timestamp()),
        account=account
    )

    #
    # Full
    #

    oc.add(DirectoryObject(
        key=Callback(Synchronize, account_id=account.id, refresh=timestamp()),
        title=pad_title(SyncMode.title(SyncMode.Full)),
        summary=Status.build(account, SyncMode.Full),

        thumb=R("icon-sync.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    #
    # Pull
    #

    oc.add(DirectoryObject(
        key=Callback(Pull, account_id=account.id, refresh=timestamp()),
        title=pad_title('%s from trakt' % SyncMode.title(SyncMode.Pull)),
        summary=Status.build(account, SyncMode.Pull),

        thumb=R("icon-sync_down.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    oc.add(DirectoryObject(
        key=Callback(FastPull, account_id=account.id, refresh=timestamp()),
        title=pad_title('%s from trakt' % SyncMode.title(SyncMode.FastPull)),
        summary=Status.build(account, SyncMode.FastPull),

        thumb=R("icon-sync_down.png"),
        art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
    ))

    #
    # Push
    #

    p_account = account.plex

    try:
        # Retrieve account libraries/sections
        with p_account.authorization():
            sections = Plex['library'].sections()
    except Exception, ex:
        # Build message
        if p_account is None:
            message = "Plex account hasn't been authenticated"
        else:
            message = str(ex.message or ex)

        # Redirect to error message
        log.warn('Unable to retrieve account libraries/sections: %s', message, exc_info=True)

        return redirect('/sync',
            account_id=account_id,
            title='Error',
            message=message,
            message_only=True
        )
예제 #7
0
        return redirect('/sync',
            account_id=account_id,
            title='Error',
            message=message,
            message_only=True
        )

    section_keys = []

    f_allow, f_deny = Filters.get('filter_sections')

    for section in sections.filter(['show', 'movie'], titles=f_allow):
        oc.add(DirectoryObject(
            key=Callback(Push, account_id=account.id, section=section.key, refresh=timestamp()),
            title=pad_title('%s "%s" to trakt' % (SyncMode.title(SyncMode.Push), section.title)),
            summary=Status.build(account, SyncMode.Push, section.key),

            thumb=R("icon-sync_up.png"),
            art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)
        ))
        section_keys.append(section.key)

    if len(section_keys) > 1:
        oc.add(DirectoryObject(
            key=Callback(Push, account_id=account.id, refresh=timestamp()),
            title=pad_title('%s all to trakt' % SyncMode.title(SyncMode.Push)),
            summary=Status.build(account, SyncMode.Push),

            thumb=R("icon-sync_up.png"),
            art=function_path('Cover.png', account_id=account.id, refresh=account.refreshed_ts)