Git Product home page Git Product logo

plexmediafixup's People

Contributors

andy-maier avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

plexmediafixup's Issues

Add end2end tests

This could be done like PlexAPI does it, by using a docker container with a PMS that is preloaded with some test data.

Fix timeouts

Actual behavior

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)'))

Expected behavior

timeout of 300 sec is honored for operations, but 30 sec stays for connections.

Execution environment

  • PlexMediaFixup version:
  • Python version:
  • Operating System (type+version):

Add support for logging changes

  • Log file configurable, null means no logging.
  • Fixed log format (date, server name, library section title, item title, change message).
  • Only changes, not every output message.
  • TBD: What to do with existing messages.

Fixup for preserving collections to avoid loosing members

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.

Fixup for setting video stream title to language

Actual behavior

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.

Expected behavior

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.

Execution environment

  • PlexMediaFixup version:
  • Python version:
  • Operating System (type+version):

Classify package no longer as development library

Actual behavior

Currently, the package is classified as development and as python library.

Expected behavior

Find classifier values that better describe the nature of the package being scripts for the PMS admin.

Execution environment

  • PlexMediaFixup version:
  • Python version:
  • Operating System (type+version):

Fixup for fixing titles

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:

  1. Use title in media file, if set. Use this title unchanged.

  2. 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.

NotFound exception not handled when renaming files

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>

Support for getting title from media file name

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.