mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.5k stars 206 forks source link

Small improvements for Jellyfin and Plex post-process scripts #1684

Closed fortiko closed 8 months ago

fortiko commented 9 months ago

I had some small issues with the existing post-process scripts after discovering them in https://github.com/mdhiggins/sickbeard_mp4_automator/issues/1564. Changing them slightly makes them work perfectly. Perhaps you could consider applying those changes. Thank you in advance!

Changes for Jellyfin are basically a slightly updated URL following the API documentation and correcting the method from GET to POST, and removing the JSON output because Jellyfin does not return a JSON for the request, rather just a simple code and text.

diff jellyfin.py ../setup/post_process/jellyfin.py

9c9
<     url = "https://jellyfin.tld:8096/Library/Refresh"
---
>     url = "https://jellyfin.tld/library/refresh"
16c16
<         r = requests.post(url, headers=headers)
---
>         r = requests.get(url, headers=headers)
18c18
<         print(r.text)
---
>         print(r.json())

Changes for Plex are an updated API access method and renaming the variable SERVERNAME to FRIENDLY_NAME to distinguish it clearly from the PLEX_URL we need for API access:

diff plex.py ../setup/post_process/plex.py

4d3
< import plexapi
8,11c7,9
< PASSWORD = ""
< FRIENDLY_NAME = "MY-MEDIA-SERVER"
< PLEX_URL = "http://plex.tld:32400/"
< PLEX_TOKEN = ""
---
> TOKEN = ""
> SERVERNAME = ""
>
15,16c13,15
<     plex = PlexServer(PLEX_URL, PLEX_TOKEN)
<     sectionType = "show" if os.environ.get("SMA_SEASON") or os.environ.get("SMA_EPISODE") else "movie"
---
>     account = MyPlexAccount(username=USERNAME, token=TOKEN)
>     plex: PlexServer = account.resource(SERVERNAME).connect()
>     sectionType = "show" if os.env.get("SMA_SEASON") or os.env.get("SMA_EPISODE") else "movie"
19c18
<             print("Updating section %s on server %s" % (section.title, FRIENDLY_NAME))
---
>             print("Updating section %s on server %s" % (section.title, SERVERNAME))
mdhiggins commented 9 months ago

If you wanted to submit a pull request with these changes I'd be happy to take a look and merge

These are really just very basic sample scripts to help show how the environment variables can work etc (especially for Plex since the script has full Plex integration built in already) but definitely want them to be functional samples

mdhiggins commented 8 months ago

ced493e63fcc32f353e76d9d8fe14398eb703770