Plex API: Missing argument title or season is required
Closed this issue · 1 comments
Running as a python script with command in admin powershell on Windows 10 VM:
python3 main.py -c ./config.yaml
logs
2022-10-28 11:18:33,523 [INFO] Parsing config file './config.yaml'
2022-10-28 11:18:33,528 [INFO] The provided configuration has been successfully validated
2022-10-28 11:18:33,535 [INFO] Starting scheduler
2022-10-28 11:18:34,690 [INFO] Successfully connected as user 'aadgh' (id: 1)
2022-10-28 11:18:34,696 [INFO] Scanning all episodes from the Plex library, this action should only take a few seconds but can take several minutes for larger libraries
Traceback (most recent call last):
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\main.py", line 118, in <module>
plex_auto_languages.start()
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\main.py", line 68, in start
self.init()
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\main.py", line 45, in init
self.plex = PlexServer(self.config.get("plex.url"), self.config.get("plex.token"), self.notifier, self.config)
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\plex_auto_languages\plex_server.py", line 110, in __init__
self.cache = PlexServerCache(self)
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\plex_auto_languages\plex_server_cache.py", line 44, in __init__
self.refresh_library_cache()
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\plex_auto_languages\plex_server_cache.py", line 68, in refresh_library_cache
for episode in self._plex.episodes():
File "C:\Users\Alex\Desktop\Plex-Auto-Languages\plex_auto_languages\plex_server.py", line 62, in episodes
return self._plex.library.all(libtype="episode", container_size=1024)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\library.py", line 114, in all
for item in section.all(**kwargs):
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\library.py", line 672, in all
return self.search(libtype=libtype, **kwargs)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\library.py", line 1519, in search
return self._search(key, maxresults, container_start, container_size, **kwargs)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\library.py", line 1531, in _search
subresults = self.fetchItems(key, container_start=container_start,
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\library.py", line 451, in fetchItems
items = self.findItems(data, cls, ekey, **kwargs)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 312, in findItems
item = self._buildItemOrNone(elem, cls, initpath)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 101, in _buildItemOrNone
return self._buildItem(elem, cls, initpath)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 93, in _buildItem
return ecls(self._server, elem, initpath)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 56, in __init__
self._loadData(data)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\video.py", line 854, in _loadData
if self.skipParent and not self.parentRatingKey:
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 502, in __getattribute__
self._reload(_overwriteNone=False)
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\base.py", line 378, in _reload
self._loadData(data[0])
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\video.py", line 860, in _loadData
self.parentRatingKey = self.show().season(season=self.parentIndex).ratingKey
File "C:\Users\Alex\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\plexapi\video.py", line 556, in season
raise BadRequest('Missing argument: title or season is required')
plexapi.exceptions.BadRequest: Missing argument: title or season is required
I installed the dependencies from the requirements.txt.
config.yaml
plexautolanguages:
# Update language for the entire show or only for the current season
# Accepted values:
# - show (default)
# - season
update_level: "show"
# Update all episodes of the show/season or only the next ones
# Accepted values:
# - all (default)
# - next
update_strategy: "all"
# Whether or not playing a file should trigger a language update, defaults to 'true'
trigger_on_play: true
# Whether or not scanning the library for new files should trigger a language update, defaults to 'true'
# A newly added episode will be updated based on the most recently watched episode, or the first episode of the show if it has never been watched
trigger_on_scan: true
# Whether or not navigating the Plex library should trigger a language update, defaults to 'false'
# Only the Plex web client and the Plex for Windows app support this feature
# Set this to 'true' only if you want to perform changes whenever the default track of an episode is updated, even when the episode is not played.
# Setting this parameter to 'true' can result in higher resource usage.
trigger_on_activity: false
# Whether or not to refresh the cached library whenever the Plex server scans its own library, defaults to 'true'
# Disabling this parameter will prevent PlexAutoLanguages from detecting updated files for an already existing episode
# It is recommended to disable this parameter if you have a large TV Show library (10k+ episodes)
refresh_library_on_scan: true
# Plex configuration
plex:
# A valid Plex URL (required)
url: "http://127.0.0.1:32400"
# A valid Plex Token (required)
token: "********"
scheduler:
# Whether of not to enable the scheduler, defaults to 'true'
# The scheduler will perform a deeper analysis of all recently played TV Shows
enable: true
# The time at which the scheduler start its task with the format 'HH:MM', defaults to '02:00'
schedule_time: "04:30"
notifications:
# Whether or not to enable the notifications through Apprise, defaults to 'false'
# A notification is sent whenever a language change is performed
enable: true
# An array of Apprise configurations, see Apprise docs for more information: https://github.com/caronc/apprise
# The array 'users' can be specified in order to link notification URLs with specific users
# Defaults to all users if not present
# The array 'events' can be specified in order to get notifications only for specific events
# Valid event values: "play_or_activity" "new_episode" "updated_episode" "scheduler"
# Defaults to all events if not present
apprise_configs:
# This URL will be notified of all changes during all events
- "discord://webhook_id/webhook_token"
# These URLs will only be notified of language change for users "MyUser1" and "MyUser2"
- urls:
- "gotify://hostname/token"
- "pover://user@token"
users:
- "MyUser1"
- "MyUser2"
# This URL will only be notified of language change for user "MyUser3" during play or activity events
- urls:
- "tgram://bottoken/ChatID"
users:
- "MyUser3"
events:
- "play_or_activity"
# This URL will be notified of language change during scheduler tasks only
- urls:
- "gotify://hostname/token"
events:
- "scheduler"
- "..."
# Whether or not to enable the debug mode, defaults to 'false'
# Enabling debug mode will significantly increase the number of output logs
debug: false
I haven't edited the config past adding my plex config. I have tried to use http://192.168.1.114:32400
for my URL as well and that didn't help.
Thanks for any help :)
Hi @Dacilla, thank you for opening an issue !
It looks like the error you are getting is coming from the plexapi
package instead. I've looked for similar issues on their side but couldn't find any.
Do you have any tv show that may not be properly organized ? Or one that has not been associated correctly ?
Here is a script you can try:
from plexapi.server import PlexServer
from plexapi.exceptions import BadRequest
PLEX_URL = "<YOU_PLEX_URL>"
PLEX_TOKEN = "<YOUR_PLEX_TOKEN>"
plex = PlexServer(PLEX_URL, PLEX_TOKEN)
try:
for episode in plex.library.all(libtype="episode", container_size=1024):
print(f"{episode.show().title} - Season {episode.seasonNumber} - Episode {episode.episodeNumber}")
except BadRequest as e:
print(f"=> Bad request: {e}")
except Exception as e:
print(f"=> Exception: {e}")
It will simply print out all the episodes from your library. Make sure that you replace the PLEX_URL
and PLEX_TOKEN
variables with the correct one. Let me know if some episodes are correctly listed before the BadRequest
happens, and if any exception occurs.