Prefix all tools with plex- allows us to add this directory to bin and still find them with tab complete

This commit is contained in:
Michael Shepanski 2017-08-12 21:35:13 -04:00
parent 24f3e640e6
commit fe68c8f590
7 changed files with 89 additions and 72 deletions

View file

@ -1,8 +1,5 @@
General Settings General Settings
~~~~~~~~~~~~~~~~ ----------------
**butlerTaskCheckForUpdates (bool)**
Automatically check for updates. (default: True)
**butlerUpdateChannel (text)** **butlerUpdateChannel (text)**
Update Channel. (default: 16; choices: 16:Public|8:Plex Pass) Update Channel. (default: 16; choices: 16:Public|8:Plex Pass)
@ -23,7 +20,7 @@ General Settings
Scheduled Task Settings Scheduled Task Settings
~~~~~~~~~~~~~~~~~~~~~~~ -----------------------
**butlerDatabaseBackupPath (text)** **butlerDatabaseBackupPath (text)**
Backup directory. The directory in which database backups are stored. (default: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases) Backup directory. The directory in which database backups are stored. (default: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases)
@ -68,7 +65,7 @@ Scheduled Task Settings
Channels Settings Channels Settings
~~~~~~~~~~~~~~~~~ -----------------
**disableCapabilityChecking (bool)** **disableCapabilityChecking (bool)**
Disable capability checking. Capability checking ensures that plug-ins that are incompatible with this version of the server or the current client application you are using are hidden. Disabling capability checking is useful during development, but will enable access to plug-ins that may perform unreliably with certain client applications. Disable capability checking. Capability checking ensures that plug-ins that are incompatible with this version of the server or the current client application you are using are hidden. Disabling capability checking is useful during development, but will enable access to plug-ins that may perform unreliably with certain client applications.
@ -83,7 +80,7 @@ Channels Settings
DLNA Settings DLNA Settings
~~~~~~~~~~~~~ -------------
**dlnaAnnouncementLeaseTime (int)** **dlnaAnnouncementLeaseTime (int)**
DLNA server announcement lease time. Duration in seconds of DLNA Server SSDP announcement lease time. (default: 1800) DLNA server announcement lease time. Duration in seconds of DLNA Server SSDP announcement lease time. (default: 1800)
@ -110,7 +107,7 @@ DLNA Settings
Extras Settings Extras Settings
~~~~~~~~~~~~~~~ ---------------
**cinemaTrailersFromBluRay (bool)** **cinemaTrailersFromBluRay (bool)**
Include Cinema Trailers from new and upcoming movies on Blu-ray. This feature is Plex Pass only. Include Cinema Trailers from new and upcoming movies on Blu-ray. This feature is Plex Pass only.
@ -128,9 +125,9 @@ Extras Settings
Library Settings Library Settings
~~~~~~~~~~~~~~~~ ----------------
**allowMediaDeletion (bool)** **allowMediaDeletion (bool)**
Allow media deletion. The owner of the server will be allowed to delete media files from disk. Allow media deletion. The owner of the server will be allowed to delete media files from disk. (default: True)
**autoEmptyTrash (bool)** **autoEmptyTrash (bool)**
Empty trash automatically after every scan. (default: True) Empty trash automatically after every scan. (default: True)
@ -164,7 +161,7 @@ Library Settings
Network Settings Network Settings
~~~~~~~~~~~~~~~~ ----------------
**allowedNetworks (text)** **allowedNetworks (text)**
List of IP addresses and networks that are allowed without auth. Comma separated list of IP addresses or IP/netmask entries for networks that are allowed to access Plex Media Server without logging in. When the server is signed out and this value is set, only localhost and addresses on this list will be allowed. List of IP addresses and networks that are allowed without auth. Comma separated list of IP addresses or IP/netmask entries for networks that are allowed to access Plex Media Server without logging in. When the server is signed out and this value is set, only localhost and addresses on this list will be allowed.
@ -206,7 +203,7 @@ Network Settings
Transcoder Settings Transcoder Settings
~~~~~~~~~~~~~~~~~~~ -------------------
**hardwareAcceleratedCodecs (bool)** **hardwareAcceleratedCodecs (bool)**
Use hardware acceleration when available (Experimental). Plex Media Server will attempt to use hardware-accelerated video codecs when encoding and decoding video. Hardware acceleration can make transcoding faster and allow more simultaneous video transcodes, but it can also reduce video quality and compatibility. Use hardware acceleration when available (Experimental). Plex Media Server will attempt to use hardware-accelerated video codecs when encoding and decoding video. Hardware acceleration can make transcoding faster and allow more simultaneous video transcodes, but it can also reduce video quality and compatibility.
@ -236,7 +233,7 @@ Transcoder Settings
Misc Settings Misc Settings
~~~~~~~~~~~~~ -------------
**acceptedEULA (bool)** **acceptedEULA (bool)**
Has the user accepted the EULA. Has the user accepted the EULA.
@ -266,14 +263,17 @@ Misc Settings
Undocumented Settings Undocumented Settings
~~~~~~~~~~~~~~~~~~~~~ ---------------------
* **aBRKeepOldTranscodes (bool)**
* **allowHighOutputBitrates (bool)** * **allowHighOutputBitrates (bool)**
* **backgroundQueueIdlePaused (bool)** * **backgroundQueueIdlePaused (bool)**
* **butlerTaskGenerateMediaIndexFiles (bool)** * **butlerTaskGenerateMediaIndexFiles (bool)**
* **certificateVersion (int)**: default: 2 * **certificateVersion (int)**: default: 2
* **disableHlsAuthorization (bool)** * **dvrShowUnsupportedDevices (bool)**
* **enableABRDebugOverlay (bool)**
* **enableAirplay (bool)** * **enableAirplay (bool)**
* **eyeQUser (text)** * **eyeQUser (text)**
* **forceAutoAdjustQuality (bool)**
* **generateIndexFilesDuringAnalysis (bool)** * **generateIndexFilesDuringAnalysis (bool)**
* **gracenoteUser (text)** * **gracenoteUser (text)**
* **hardwareDevicePath (text)**: default: /dev/dri/renderD128 * **hardwareDevicePath (text)**: default: /dev/dri/renderD128
@ -291,5 +291,6 @@ Undocumented Settings
* **transcoderH264Options (text)** * **transcoderH264Options (text)**
* **transcoderH264OptionsOverride (text)** * **transcoderH264OptionsOverride (text)**
* **transcoderH264Preset (text)**: default: veryfast * **transcoderH264Preset (text)**: default: veryfast
* **transcoderLivePruneBuffer (int)**: default: 5400
* **transcoderLogLevel (text)**: default: error * **transcoderLogLevel (text)**: default: error

View file

@ -1,15 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This will find every item marked with the collection 'markwatched' and mark
it watched. Just set run every so often in a scheduled task. This will only
work for the user you connect to the PlexServer as.
"""
from plexapi.server import PlexServer
plex = PlexServer()
for section in plex.library.sections():
if section.type in ('movie', 'artist', 'show'):
for item in section.search(collection='markwatched'):
print('Marking %s watched.' % item.title)
item.watched()

View file

@ -1,9 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
This script loops through all media items to build a collection of attributes on Plex-ListAttrs is used during development of PlexAPI and loops through all media
each media type. The resulting list can be compared with the current object items to build a collection of attributes on each media type. The resulting list
implementation in python-plex api to track new attributes and depricate old ones. can be compared with the current object implementation in python-plexapi to track
new attributes and depricate old ones.
""" """
import argparse, copy, pickle, plexapi, os, re, sys, time import argparse, copy, pickle, plexapi, os, re, sys, time
from os.path import abspath, dirname, join from os.path import abspath, dirname, join
@ -16,7 +17,7 @@ from plexapi.server import PlexServer
from plexapi.playqueue import PlayQueue from plexapi.playqueue import PlayQueue
CACHEPATH = join(dirname(abspath(__file__)), 'findattrs.pickle') CACHEPATH = join(dirname(abspath(__file__)), 'findattrs.pickle')
NAMESPACE = { NAMESPACE = {
'xml': defaultdict(int), 'xml': defaultdict(int),
'obj': defaultdict(int), 'obj': defaultdict(int),
'docs': defaultdict(int), 'docs': defaultdict(int),
@ -55,9 +56,10 @@ TAGATTRS = {
'Country': 'countries', 'Country': 'countries',
} }
STOP_RECURSING_AT = ( STOP_RECURSING_AT = (
#'media.MediaPart', # 'media.MediaPart',
) )
class PlexAttributes(): class PlexAttributes():
def __init__(self, opts): def __init__(self, opts):
@ -70,17 +72,17 @@ class PlexAttributes():
def run(self): def run(self):
starttime = time.time() starttime = time.time()
# self._parse_myplex() self._parse_myplex()
# self._parse_server() self._parse_server()
# self._parse_search() self._parse_search()
# self._parse_library() self._parse_library()
self._parse_audio() self._parse_audio()
# self._parse_photo() self._parse_photo()
# self._parse_movie() self._parse_movie()
# self._parse_show() self._parse_show()
# self._parse_client() self._parse_client()
# self._parse_playlist() self._parse_playlist()
# self._parse_sync() self._parse_sync()
self.runtime = round((time.time() - starttime) / 60.0, 1) self.runtime = round((time.time() - starttime) / 60.0, 1)
return self return self
@ -106,7 +108,7 @@ class PlexAttributes():
def _parse_library(self): def _parse_library(self):
cat = 'lib' cat = 'lib'
self._load_attrs(self.plex.library, cat) self._load_attrs(self.plex.library, cat)
#self._load_attrs(self.plex.library.all()[:50], 'all') # self._load_attrs(self.plex.library.all()[:50], 'all')
self._load_attrs(self.plex.library.onDeck()[:50], 'deck') self._load_attrs(self.plex.library.onDeck()[:50], 'deck')
self._load_attrs(self.plex.library.recentlyAdded()[:50], 'add') self._load_attrs(self.plex.library.recentlyAdded()[:50], 'add')
for search in ('cat', 'dog', 'rat', 'gir', 'mou'): for search in ('cat', 'dog', 'rat', 'gir', 'mou'):
@ -248,7 +250,7 @@ class PlexAttributes():
if self._clsname_match(clsname): if self._clsname_match(clsname):
meta = self.attrs[clsname] meta = self.attrs[clsname]
count = meta['total'] count = meta['total']
print(_('\n%s (%s)\n%s' % (clsname, count, '-'*30), 'yellow')) print(_('\n%s (%s)\n%s' % (clsname, count, '-' * 30), 'yellow'))
attrs = sorted(set(list(meta['xml'].keys()) + list(meta['obj'].keys()))) attrs = sorted(set(list(meta['xml'].keys()) + list(meta['obj'].keys())))
for attr in attrs: for attr in attrs:
state = self._attr_state(clsname, attr, meta) state = self._attr_state(clsname, attr, meta)
@ -257,7 +259,7 @@ class PlexAttributes():
examples = '; '.join(list(meta['examples'].get(attr, ['--']))[:3])[:80] examples = '; '.join(list(meta['examples'].get(attr, ['--']))[:3])[:80]
print('%7s %3s %-30s %-20s %s' % (count, state, attr, categories, examples)) print('%7s %3s %-30s %-20s %s' % (count, state, attr, categories, examples))
total_attrs += count total_attrs += count
print(_('\nSUMMARY\n%s' % ('-'*30), 'yellow')) print(_('\nSUMMARY\n%s' % ('-' * 30), 'yellow'))
print('%7s %3s %3s %3s %-20s %s' % ('total', 'new', 'old', 'doc', 'categories', 'clsname')) print('%7s %3s %3s %3s %-20s %s' % ('total', 'new', 'old', 'doc', 'categories', 'clsname'))
for clsname in sorted(self.attrs.keys()): for clsname in sorted(self.attrs.keys()):
if self._clsname_match(clsname): if self._clsname_match(clsname):
@ -311,6 +313,7 @@ def _(text, color):
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__)
parser = argparse.ArgumentParser(description='resize and copy starred photos') parser = argparse.ArgumentParser(description='resize and copy starred photos')
parser.add_argument('-f', '--force', default=False, action='store_true', help='force a full refresh of attributes.') parser.add_argument('-f', '--force', default=False, action='store_true', help='force a full refresh of attributes.')
parser.add_argument('-m', '--max', default=99999, help='max number of objects to load.') parser.add_argument('-m', '--max', default=99999, help='max number of objects to load.')

View file

@ -1,36 +1,38 @@
from collections import OrderedDict #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Plex-ListDocAttrs is used during development of PlexAPI.
Example usage: AttDS(dict or object).write()
"""
import re import re
from collections import OrderedDict
def type_finder(s): def type_finder(s):
type_string = str(type(s)) type_string = str(type(s))
x = re.search("'(.+)'", type_string) x = re.search("'(.+)'", type_string)
if x: if x:
return x.group(1) return x.group(1)
return '' return ''
class AttDS(object): class AttDS(object):
"""Helper that prints docstring attrs""" """ Helper that prints docstring attrs. """
def __init__(self, o, keys=None, style='google'): def __init__(self, o, keys=None, style='google'):
self.__o = o self.__o = o
if not isinstance(o, dict): if not isinstance(o, dict):
self.o = o.__dict__.items() self.o = o.__dict__.items()
self._as_dict = o.__dict__ self._as_dict = o.__dict__
else: else:
self.o = o.items() self.o = o.items()
self._as_dict = o self._as_dict = o
if keys is None: if keys is None:
self.keys = self._as_dict.keys() self.keys = self._as_dict.keys()
else: else:
self.keys = keys self.keys = keys
if style == 'google': if style == 'google':
self.template = '%s (%s): %s' self.template = '%s (%s): %s'
self.res_dict = OrderedDict() self.res_dict = OrderedDict()
self.parse() self.parse()
@ -42,12 +44,8 @@ class AttDS(object):
ds += '%s=%s ' % (key, self._as_dict.get(key, '')) ds += '%s=%s ' % (key, self._as_dict.get(key, ''))
else: else:
ds = '' ds = ''
self.res_dict[k] = self.template % (k, type_finder(v), ds) self.res_dict[k] = self.template % (k, type_finder(v), ds)
def write(self): def write(self):
for k, v in self.res_dict.items(): for k, v in self.res_dict.items():
print v print(v)
#x = AttDS(dict or object).write()

View file

@ -1,12 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""
Plex-ListSettings is used during development of PlexAPI and loops through available
setting items and separates them by group as well as display the variable type. The
resulting list is used for the creation of docs/settingslist.rst.
"""
from collections import defaultdict from collections import defaultdict
from os.path import abspath, dirname, join from os.path import abspath, dirname, join
from plexapi import utils from plexapi import utils
from plexapi.server import PlexServer from plexapi.server import PlexServer
GROUPNAMES = {'butler':'Scheduled Task', 'dlna':'DLNA'} GROUPNAMES = {'butler':'Scheduled Task', 'dlna':'DLNA'}
OUTPUT = join(dirname(dirname(abspath(__file__))), 'docs/settingslist.rst') OUTPUT = join(dirname(dirname(abspath(__file__))), 'docs/settingslist.rst')
def _setting_group(setting): def _setting_group(setting):
@ -17,8 +22,8 @@ def _setting_group(setting):
def _write_settings(handle, groups, group): def _write_settings(handle, groups, group):
title = GROUPNAMES.get(group, group.title()) title = GROUPNAMES.get(group, group.title())
print('\n%s Settings\n%s' % (title, '~' * (len(title) + 9))) print('\n%s Settings\n%s' % (title, '-' * (len(title) + 9)))
handle.write('%s Settings\n%s\n' % (title, '~' * (len(title) + 9))) handle.write('%s Settings\n%s\n' % (title, '-' * (len(title) + 9)))
for setting in groups[group]: for setting in groups[group]:
print(' %s (%s)' % (utils.lowerFirst(setting.id), setting.type)) print(' %s (%s)' % (utils.lowerFirst(setting.id), setting.type))
# Special case undocumented settings # Special case undocumented settings
@ -66,4 +71,5 @@ def list_settings():
if __name__ == '__main__': if __name__ == '__main__':
print(__doc__)
list_settings() list_settings()

View file

@ -1,9 +1,17 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
"""
Plex-ListTokens is a simple utility to fetch and list all known Plex
Server tokens your plex.tv account has access to. Because this information
comes from the plex.tv website, we need to ask for your username
and password. Alternatively, if you do not wish to enter your login
information below, you can retrieve the same information from plex.tv
at the URL: https://plex.tv/api/resources?includeHttps=1
"""
from getpass import getpass from getpass import getpass
from plexapi import utils from plexapi import utils
from plexapi.exceptions import BadRequest from plexapi.exceptions import BadRequest
from plexapi.myplex import MyPlexAccount, MyPlexResource, _connect from plexapi.myplex import MyPlexAccount, _connect
from plexapi.server import PlexServer from plexapi.server import PlexServer
FORMAT = ' %-17s %-25s %-20s %s' FORMAT = ' %-17s %-25s %-20s %s'
@ -51,14 +59,7 @@ def _test_servers(servers):
if __name__ == '__main__': if __name__ == '__main__':
print('List Plex Tokens') print(__doc__)
print('----------------')
print('This is a simple utility to fetch and list all known Plex Server')
print('tokens your plex.tv account has access to. Because this information')
print('comes from the plex.tv website, we need to ask for your username')
print('and password. Alternatively, if you do not wish to enter your login')
print('information below, you can retrieve the same information from plex.tv')
print('directly at the URL: %s\n' % MyPlexResource.key)
username = input('What is your plex.tv username: ') username = input('What is your plex.tv username: ')
password = getpass('What is your plex.tv password: ') password = getpass('What is your plex.tv password: ')
try: try:

23
tools/plex-markwatched.py Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Plex-MarkWatched is a useful to always mark a show as watched. This comes in
handy when you have a show you keep downloaded, but do not religiously watch
every single episode that is downloaded. By marking everything watched, it
will keep the show out of your OnDeck list inside Plex.
Usage:
Intended usage is to add the tak 'markwatched' to any show you want to have
this behaviour. Then simply add this script to run on a schedule and you
should be all set.
"""
from plexapi.server import PlexServer
if __name__ == '__main__':
plex = PlexServer()
for section in plex.library.sections():
if section.type in ('movie', 'artist', 'show'):
for item in section.search(collection='markwatched'):
print('Marking %s watched.' % item.title)
item.watched()