Пример #1
0
def AccountsMenu(refresh=None, *args, **kwargs):
    oc = ObjectContainer(title2=_("Accounts"), no_cache=True)

    # Active sync status
    Active.create(
        oc,
        callback=Callback(AccountsMenu, refresh=timestamp()),
    )

    # Accounts
    for account in Accounts.list():
        oc.add(
            DirectoryObject(key=Callback(ControlsMenu, account_id=account.id),
                            title=account.name,
                            art=function_path('Cover.png',
                                              account_id=account.id,
                                              refresh=account.refreshed_ts),
                            thumb=function_path('Thumb.png',
                                                account_id=account.id,
                                                refresh=account.refreshed_ts)))

    return oc
Пример #2
0
def AccountsMenu(refresh=None, *args, **kwargs):
    oc = ObjectContainer(
        title2=_("Accounts"),
        no_cache=True
    )

    # Active sync status
    Active.create(
        oc,
        callback=Callback(AccountsMenu, refresh=timestamp()),
    )

    # Accounts
    for account in Accounts.list():
        oc.add(DirectoryObject(
            key=Callback(ControlsMenu, account_id=account.id),
            title=account.name,

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

    return oc
Пример #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
    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)))
Пример #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
            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)
        ))

    return oc