Python-Netflix
Python-Netflix is a Python Library to interface with Netflix REST API & OAuth
Features
Retrieve user information
Retrieve queue information
Add items to queue
And many more, supports all REST endpoints
Installation
Installing Python-Netflix is simple:
$ pip install python-netflix
Usage
Handling the callback
# In Django, you'd do something like
# oauth_token = request.GET.get('oauth_verifier')
# oauth_verifier = request.GET.get('oauth_verifier')
oauth_token = *Grab oauth token from URL*
oauth_verifier = *Grab oauth verifier from URL*
#Initiate the NetflixAPI class in your callback.
n = NetflixAPI(api_key='*your app key*',
api_secret='*your app secret*',
oauth_token=oauth_token,
oauth_token_secret=session['netflix_session_keys'][ 'oauth_token_secret'])
authorized_tokens = n.get_auth_tokens(oauth_verifier)
final_oauth_token = authorized_tokens['oauth_token']
final_oauth_token_secret = authorized_tokens['oauth_token_secret']
final_user_id = authorized_tokens['user_id']
Save those tokens and user_id to the database for a later use?
Return a list of the users Instant Queue
n = NetflixAPI(api_key = '*your app key*',
api_secret = '*your app secret*',
oauth_token=final_tokens['oauth_token'],
oauth_token_secret=final_tokens['oauth_token_secret'])
instant_queue = n.get('users/*final_user_id*/queues/instant')
print instant_queue
Add Gabriel Iglesias: Hot and Fluffy to Instant Queue
# Assume you are using the same NetflixAPI instance as above
try:
add_to_queue = n.post('users/*final_user_id*/queues/instant', params={'title_ref': 'http://api.netflix.com/catalog/titles/movies/70072945'})
print add_to_queue
# You can also added "position" to the params to set where this media will be positioned on the users queue.
except NetflixAPIError:
# This returns the added item if successful.
# If it's already in the queue, it will return a NetflixAPIError, code 412
Remove Gabriel Iglesias: Hot and Fluffy to Instant Queue
# Assume you are using the same NetflixAPI instance as above
# When querying for the users Queue, when iterating over the Queue items
# you can use the 'id' for the next call. Where it says *final_user_id*
# that is automatically returned from the Netflix Instant Queue response.
del_from_queue = n.delete('http://api-public.netflix.com/users/*final_user_id*/queues/instant/available/2/70072945')
print del_from_queue
Rate Gabriel Iglesias: Hot and Fluffy
try:
# Create a new rating
create_rating = n.post('users/*final_user_id*/ratings/title/actual/70072945', params={'rating': '5'})
print create_rating
except NetflixAPIError:
# This returns a status message if successful.
# If it's already been rated, it will return a NetflixAPIError, code 422
pass
# Update/Clear rating
update_rating = n.put('users/*final_user_id*/ratings/title/actual/70072945', params={'rating': 'no_opinion'})
print update_rating
Metadata
Release files for python-netflix 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-netflix-0.4.1.tar.gz | 4.5 kB | Without provenance | Details for python-netflix-0.4.1.tar.gz |
Release files / python-netflix-0.4.1.tar.gz
| Download URL | python-netflix-0.4.1.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
df1720901c720f6368bf48cd4a21078e9c17371efdcb55ec56b46242497f4f81
|
|
BLAKE2b-256 checksum How to use checksums |
744973b9250c0c53494b3433d0885f10d6b10b909bc00db122e060acadd0acd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-netflix 0.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.