mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Merge pull request #451 from jjlawren/raise_notfound
Raise NotFound on 404 errors
This commit is contained in:
commit
0da9e3994a
4 changed files with 12 additions and 1 deletions
|
@ -5,7 +5,7 @@ import requests
|
|||
from plexapi import BASE_HEADERS, CONFIG, TIMEOUT, log, logfilter, utils
|
||||
from plexapi.base import PlexObject
|
||||
from plexapi.compat import ElementTree
|
||||
from plexapi.exceptions import BadRequest, Unauthorized, Unsupported
|
||||
from plexapi.exceptions import BadRequest, NotFound, Unauthorized, Unsupported
|
||||
from plexapi.playqueue import PlayQueue
|
||||
from requests.status_codes import _codes as codes
|
||||
|
||||
|
@ -163,6 +163,8 @@ class PlexClient(PlexObject):
|
|||
message = '(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext)
|
||||
if response.status_code == 401:
|
||||
raise Unauthorized(message)
|
||||
elif response.status_code == 404:
|
||||
raise NotFound(message)
|
||||
else:
|
||||
raise BadRequest(message)
|
||||
data = response.text.encode('utf8')
|
||||
|
|
|
@ -185,6 +185,8 @@ class MyPlexAccount(PlexObject):
|
|||
message = '(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext)
|
||||
if response.status_code == 401:
|
||||
raise Unauthorized(message)
|
||||
elif response.status_code == 404:
|
||||
raise NotFound(message)
|
||||
else:
|
||||
raise BadRequest(message)
|
||||
data = response.text.encode('utf8')
|
||||
|
|
|
@ -427,6 +427,8 @@ class PlexServer(PlexObject):
|
|||
message = '(%s) %s; %s %s' % (response.status_code, codename, response.url, errtext)
|
||||
if response.status_code == 401:
|
||||
raise Unauthorized(message)
|
||||
elif response.status_code == 404:
|
||||
raise NotFound(message)
|
||||
else:
|
||||
raise BadRequest(message)
|
||||
data = response.text.encode('utf8')
|
||||
|
|
|
@ -90,6 +90,11 @@ def _detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=T
|
|||
return 'blackandwhite'
|
||||
|
||||
|
||||
def test_server_fetchitem_notfound(plex):
|
||||
with pytest.raises(NotFound):
|
||||
plex.fetchItem(123456789)
|
||||
|
||||
|
||||
def test_server_search(plex, movie):
|
||||
title = movie.title
|
||||
# this search seem to fail on my computer but not at travis, wtf.
|
||||
|
|
Loading…
Reference in a new issue