From c8b2feca077a4bf927b0ee5c8f541eca6ce8dd5f Mon Sep 17 00:00:00 2001 From: Ryszard Szopa Date: Wed, 2 Sep 2009 10:05:38 +0200 Subject: [PATCH] InternalNetflixError. --- netflix/__init__.py | 60 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/netflix/__init__.py b/netflix/__init__.py index 60973ed..b90f4fd 100644 --- a/netflix/__init__.py +++ b/netflix/__init__.py @@ -1,3 +1,58 @@ +""" + >>> NETFLIX_API_KEY, NETFLIX_API_SECRET, NETFLIX_APPLICATION_NAME = your_credentials + + >>> flix = Netflix(key=NETFLIX_API_KEY, + secret=NETFLIX_API_SECRET, + application_name=NETFLIX_APPLICATION_NAME) + + >>> sopranos = flix.request('/catalog/titles/', term="The Sopranos", max_results=3) + + >>> sopranos + [, + , + ] + + + >>> season1 = sopranos[0] + + >>> season1.average_rating + 4.4000000000000004 + + >>> season1.categories + [, + , + , + , + , + , + ] + + >>> season1.title + u'The Sopranos: Season 1' + + >>> season1.links + {u'The Sopranos': , + u'cast': , + u'directors': , + u'discs': , + u'formats': , + u'languages and audio': , + u'official webpage': , + u'screen formats': , + u'similars': , + u'synopsis': , + u'web page': } + + >>> discs = season1.links['discs'].get(flix) + + >>> discs + [, + , + , + ] +""" + + from oauth import oauth from oauth.oauth import OAuthRequest, OAuthToken @@ -45,6 +100,9 @@ class TooManyRequestsPerDayError(TooManyRequestsError): class InvalidOrExpiredToken(AuthError): pass +class InternalNetflixError(NetflixError): + pass + class NetflixObject(object): def get(self, netflix=None, token=None, key=None, secret=None): netflix = netflix or getattr(self, 'netflix', None) or Netflix(key=key, secret=secret) @@ -357,6 +415,8 @@ def analyze_error(self, exc): raise MissingAccessTokenError(message) elif code == 412 and message == 'Title is already in queue': raise TitleAlreadyInQueue() + elif code >= 500: + raise InternalNetflixError(message) raise NetflixError(code, message)