本文整理汇总了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
示例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)
示例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)
示例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
示例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
示例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)
示例7: get_account
# 需要导入模块: from plexapi import myplex [as 别名]
# 或者: from plexapi.myplex import MyPlexAccount [as 别名]
def get_account():
return MyPlexAccount()
示例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")
示例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
示例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