Skip to content

Commit

Permalink
InternalNetflixError.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryszard committed Sep 2, 2009
1 parent 65e9220 commit c8b2fec
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions netflix/__init__.py
Original file line number Diff line number Diff line change
@@ -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
[<CatalogTitle The Sopranos: Season 1 http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356>,
<CatalogTitle The Sopranos: Season 6: Part 2 http:https://api.netflix.com/catalog/titles/series/60030356/seasons/70058397>,
<CatalogTitle The Sopranos: Season 6: Part 1 http:https://api.netflix.com/catalog/titles/series/60030356/seasons/70020010>]
>>> season1 = sopranos[0]
>>> season1.average_rating
4.4000000000000004
>>> season1.categories
[<NetflixCategory TV-MA>,
<NetflixCategory Television>,
<NetflixCategory TV Dramas>,
<NetflixCategory TV Crime Dramas>,
<NetflixCategory Must-See TV Dramas>,
<NetflixCategory HBO>,
<NetflixCategory Blu-ray>]
>>> season1.title
u'The Sopranos: Season 1'
>>> season1.links
{u'The Sopranos': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356>,
u'cast': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/cast>,
u'directors': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/directors>,
u'discs': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/discs>,
u'formats': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/format_availability>,
u'languages and audio': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/languages_and_audio>,
u'official webpage': <NetflixLink http:https://www.hbo.com/sopranos/>,
u'screen formats': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/screen_formats>,
u'similars': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/similars>,
u'synopsis': <NetflixLink http:https://api.netflix.com/catalog/titles/series/60030356/seasons/60030356/synopsis>,
u'web page': <NetflixLink http:https://www.netflix.com/Movie/The_Sopranos_Season_1/60030356>}
>>> discs = season1.links['discs'].get(flix)
>>> discs
[<CatalogTitle The Sopranos: Season 1: Disc 1 http:https://api.netflix.com/catalog/titles/discs/60003464>,
<CatalogTitle The Sopranos: Season 1: Disc 2 http:https://api.netflix.com/catalog/titles/discs/60003465>,
<CatalogTitle The Sopranos: Season 1: Disc 3 http:https://api.netflix.com/catalog/titles/discs/60003466>,
<CatalogTitle The Sopranos: Season 1: Disc 4 http:https://api.netflix.com/catalog/titles/discs/60003467>]
"""



from oauth import oauth
from oauth.oauth import OAuthRequest, OAuthToken
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c8b2fec

Please sign in to comment.