andy-maier / plexmediafixup Goto Github PK
View Code? Open in Web Editor NEWRun configurable fixups against the media database of a Plex Media Server
License: Apache License 2.0
Run configurable fixups against the media database of a Plex Media Server
License: Apache License 2.0
The video_genre_cleanup fixup currently uses the low level edit()
method to get the list of genres updated. There are higher level methods addGenre()
/ deleteGenre()
to do that.
This could be done like PlexAPI does it, by using a docker container with a PMS that is preloaded with some test data.
Even though the timeout is supposedly increased to 300 sec, both connections and operations time out at the requests level.
Example for connection timeout (can be triggered with direct connection in an environment that does not have a network connection to the PMS server):
Using plexmediafixup config file: try/ds12_config_file.yml
Using PlexAPI config file: /Users/maiera/.config/plexapi/config.ini
Loading fixup: sync_title
Loading fixup: sync_sort_title
Traceback (most recent call last):
File "/Users/maiera/virtualenvs/plex27/bin/plexmediafixup", line 11, in <module>
load_entry_point('plexmediafixup', 'console_scripts', 'plexmediafixup')()
File "/Users/maiera/PycharmProjects/plex/repos/plexmediafixup/plexmediafixup/cli.py", line 281, in main
plex = plexapi.server.PlexServer()
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/plexapi/server.py", line 103, in __init__
data = self.query(self.key, timeout=timeout)
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/plexapi/server.py", line 376, in query
response = method(url, headers=headers, timeout=timeout, **kwargs)
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/Users/maiera/virtualenvs/plex27/lib/python2.7/site-packages/requests/adapters.py", line 504, in send
raise ConnectTimeout(e, request=request)
requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.0.12', port=32400): Max retries exceeded with url: / (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x1101bb190>, 'Connection to 192.168.0.12 timed out. (connect timeout=30)'))
timeout of 300 sec is honored for operations, but 30 sec stays for connections.
When PMS updates the movie metadata, it sometimes resets the collections to empty. This causes collections to "loose" members over time.
Note: It is not fully understood under which circumstances the collections resetting happens.
A fixup could be written that preserves the collections.
One idea is that the fixup would sync the collections in both directions between PMS and the file. The sync from PMS to the file would be needed to save collections that were newly added to a Movie/Show item. The sync from the file to PMS would be needed to restore any reset collections. One handling difficulty with this approach would be that intentional removal of a collection would require both editing the file and removing it from PMS.
PMS supports that streams within a media file have titles. This seems to be a calculated setting that is not part of the actual stream in the media file. For video streams, that calculated stream title is set to show the video stream resolution etc. This is not useful for selecting the item with the desired audio language, for example.
A fixup could be written that sets the calculated video stream title such that the audio language(s) is included. Probably the value needs to be configurable, so that the video stream resolution is not lost.
Currently, the package is classified as development and as python library.
Find classifier values that better describe the nature of the package being scripts for the PMS admin.
Add a fixup that sets the title field in the media item to the value of the title as determined from the media file, as follows:
Use title in media file, if set. Use this title unchanged.
If a media file does not have a title set, it is particularly important to do this right, because PMS uses the file base name and folds in things it should not (for example, words after the last "-"). In that case, the title needs to be taken from the base file name and processed to remove things that are part of the way PMS wants the file to be stored, additional local conventions, and finally re-establishing of local non-ASCII characters. That all needs to be configurable.
Particularly when the corresponding media files have different titles (e.g. containing "Part 1" or so).
When a media file is renamed while the fixups are runing, the resulting exception is not handled.
For example, during the video_genre_cleanup fixup:
Changing genres of movie ...
Traceback (most recent call last):
File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Andi\Envs\plex37\Scripts\plexmediafixup.exe\__main__.py", line 7, in <module>
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexmediafixup\cli.py", line 412, in main
config=config, fixup_kwargs=fixup_kwargs)
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexmediafixup\fixups\video_genre_cleanup.py", line 173, in run
change_rev, remove, if_empty)
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexmediafixup\fixups\video_genre_cleanup.py", line 217, in process_item
item.reload()
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexapi\base.py", line 341, in reload
return self._reload(key=key, **kwargs)
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexapi\base.py", line 350, in _reload
data = self._server.query(key)
File "C:\Users\Andi\Envs\plex37\lib\site-packages\plexapi\server.py", line 667, in query
raise NotFound(message)
plexapi.exceptions.NotFound: (404) not_found; http://192.168.0.12:32400/library/metadata/91991?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1 <html><head><title>Not Found</title></head><body><h1>404 Not Found</h1></body></html>
The sync_title fixup currently gets the title only from the metadata within the media file.
If a media file does not have a title set in the metadata, it is particularly important to do this right, because PMS uses the file base name and folds in things it should not (for example, words after the last "-").
Support should be added to get the title by transforming the media file name, if not set in the metadata. The transformation should remove things that are part of the way PMS wants the file to be stored, consider additional local conventions, and re-establish non-ASCII characters. That all needs to be configurable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.