當前位置: 首頁>>代碼示例>>Python>>正文


Python myplex.MyPlexAccount方法代碼示例

本文整理匯總了Python中plexapi.myplex.MyPlexAccount方法的典型用法代碼示例。如果您正苦於以下問題:Python myplex.MyPlexAccount方法的具體用法?Python myplex.MyPlexAccount怎麽用?Python myplex.MyPlexAccount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plexapi.myplex的用法示例。


在下文中一共展示了myplex.MyPlexAccount方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def __init__(self, server, username, password, *args, **kwargs):
        """
        :param server: Plex server name
        :type server: str

        :param username: Plex username
        :type username: str

        :param password: Plex password
        :type username: str
        """

        from plexapi.myplex import MyPlexAccount
        super().__init__(*args, **kwargs)

        self.resource = MyPlexAccount(username, password).resource(server)
        self._plex = None 
開發者ID:BlackLight,項目名稱:platypush,代碼行數:19,代碼來源:plex.py

示例2: getMyPlexAccount

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def getMyPlexAccount(opts=None):  # pragma: no cover
    """ Helper function tries to get a MyPlex Account instance by checking
        the the following locations for a username and password. This is
        useful to create user-friendly command line tools.
        1. command-line options (opts).
        2. environment variables and config.ini
        3. Prompt on the command line.
    """
    from plexapi import CONFIG
    from plexapi.myplex import MyPlexAccount
    # 1. Check command-line options
    if opts and opts.username and opts.password:
        print('Authenticating with Plex.tv as %s..' % opts.username)
        return MyPlexAccount(opts.username, opts.password)
    # 2. Check Plexconfig (environment variables and config.ini)
    config_username = CONFIG.get('auth.myplex_username')
    config_password = CONFIG.get('auth.myplex_password')
    if config_username and config_password:
        print('Authenticating with Plex.tv as %s..' % config_username)
        return MyPlexAccount(config_username, config_password)
    # 3. Prompt for username and password on the command line
    username = input('What is your plex.tv username: ')
    password = getpass('What is your plex.tv password: ')
    print('Authenticating with Plex.tv as %s..' % username)
    return MyPlexAccount(username, password) 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:27,代碼來源:utils.py

示例3: get_account

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def get_account(self):
        username = input("Plex Username: ")
        password = getpass.getpass()

        return MyPlexAccount(username, password) 
開發者ID:alex-phillips,項目名稱:plex-autocollections,代碼行數:7,代碼來源:main.py

示例4: build_config

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def build_config():
    if not os.path.exists(config_path):
        print("Dumping default config to: %s" % config_path)

        configs = dict(url='', token='', auto_delete=False)

        # Get URL
        configs['url'] = input("Plex Server URL: ")

        # Get Credentials for plex.tv
        user = input("Plex Username: ")
        password = getpass('Plex Password: ')

        # Get choice for Auto Deletion
        auto_del = input("Auto Delete duplicates? [y/n]: ")
        while auto_del.strip().lower() not in ['y', 'n']:
            auto_del = input("Auto Delete duplicates? [y/n]: ")
            if auto_del.strip().lower() == 'y':
                configs['auto_delete'] = True
            elif auto_del.strip().lower() == 'n':
                configs['auto_delete'] = False

        account = MyPlexAccount(user, password)
        configs['token'] = account.authenticationToken

        with open(config_path, 'w') as fp:
            json.dump(prefilled_default_config(configs), fp, sort_keys=True, indent=2)

        return True

    else:
        return False 
開發者ID:l3uddz,項目名稱:plex_dupefinder,代碼行數:34,代碼來源:config.py

示例5: myPlexAccount

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def myPlexAccount(self):
        """ Returns a :class:`~plexapi.myplex.MyPlexAccount` object using the same
            token to access this server. If you are not the owner of this PlexServer
            you're likley to recieve an authentication error calling this.
        """
        if self._myPlexAccount is None:
            from plexapi.myplex import MyPlexAccount
            self._myPlexAccount = MyPlexAccount(token=self._token)
        return self._myPlexAccount 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:11,代碼來源:server.py

示例6: sync

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def sync(self, videoQuality, limit=None, unwatched=False, **kwargs):
        """ Add current Movie library section as sync item for specified device.
            See description of :func:`plexapi.library.LibrarySection.search()` for details about filtering / sorting and
            :func:`plexapi.library.LibrarySection.sync()` for details on syncing libraries and possible exceptions.

            Parameters:
                videoQuality (int): idx of quality of the video, one of VIDEO_QUALITY_* values defined in
                                    :mod:`plexapi.sync` module.
                limit (int): maximum count of movies to sync, unlimited if `None`.
                unwatched (bool): if `True` watched videos wouldn't be synced.

            Returns:
                :class:`plexapi.sync.SyncItem`: an instance of created syncItem.

            Example:

                .. code-block:: python

                    from plexapi import myplex
                    from plexapi.sync import VIDEO_QUALITY_3_MBPS_720p

                    c = myplex.MyPlexAccount()
                    target = c.device('Plex Client')
                    sync_items_wd = c.syncItems(target.clientIdentifier)
                    srv = c.resource('Server Name').connect()
                    section = srv.library.section('Movies')
                    section.sync(VIDEO_QUALITY_3_MBPS_720p, client=target, limit=1, unwatched=True,
                                 title='Next best movie', sort='rating:desc')

        """
        from plexapi.sync import Policy, MediaSettings
        kwargs['mediaSettings'] = MediaSettings.createVideo(videoQuality)
        kwargs['policy'] = Policy.create(limit, unwatched)
        return super(MovieSection, self).sync(**kwargs) 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:36,代碼來源:library.py

示例7: get_account

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def get_account():
    return MyPlexAccount() 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:4,代碼來源:conftest.py

示例8: mocked_account

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def mocked_account(requests_mock):
    requests_mock.get("https://plex.tv/users/account", text=ACCOUNT_XML)
    return MyPlexAccount(token="faketoken") 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:5,代碼來源:conftest.py

示例9: __init__

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def __init__(self, opts):
        self.opts = opts                                            # command line options
        self.clsnames = [c for c in opts.clsnames.split(',') if c]  # list of clsnames to report (blank=all)
        self.account = MyPlexAccount()                              # MyPlexAccount instance
        self.plex = PlexServer()                                    # PlexServer instance
        self.total = 0                                              # Total objects parsed
        self.attrs = defaultdict(dict)                              # Attrs result set 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:9,代碼來源:plex-listattrs.py

示例10: get_plex_account

# 需要導入模塊: from plexapi import myplex [as 別名]
# 或者: from plexapi.myplex import MyPlexAccount [as 別名]
def get_plex_account(opts):
    """ Authenitcate with Plex using the command line options. """
    if not opts.unclaimed:
        if opts.token:
            return MyPlexAccount(token=opts.token)
        return plexapi.utils.getMyPlexAccount(opts)
    return None 
開發者ID:pkkid,項目名稱:python-plexapi,代碼行數:9,代碼來源:plex-bootstraptest.py


注:本文中的plexapi.myplex.MyPlexAccount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。