A package to interact with Movielens unpublished API
Project description
movielens-private-api
Unofficial Python API for the Movielens unpublished API, using the requests
module. Tested with Python 2.7 and 3.6, but should be compatible with more.
Installing movielens-private-api
You can either clone the repository and install the package with pip:
$ git clone git://github.com/Mello-Yello/movielens-private-api.git
$ cd movielens-private-api
$ python -m pip install .
Or directly from PyPI:
$ python -m pip install movielens-private-api
Usage
Setup
Since operations are performed on a specific account, you need to either log in or provide the HTTP cookie containing a valid session.
from movielens_private_api import Movielens
m = Movielens()
cookie = m.login(username, password)
The variable cookie from above can be saved to a file to be reused later during class initialization
from movielens_private_api import Movielens
m = Movielens(cookie)
Exceptions
If the class wasn't initiated with a cookie, calling any method before login()
will raise a MovielensException
. This class encapsulates any API error received in the response, and is raised after an improper request. To access the original error message you have to catch the exception and use str()
on it.
from movielens_private_api import Movielens, MovielensException
m = Movielens()
try:
m.getMe()
except MovielensException as e:
msg = str(e)
print(msg)
--------------------------------------
Output: "authenticated user required"
Movielens
Movielens(cookie=None, timeoutSececonds=30, api_endpoint='https://movielens.org/api/', verifySSL=True)
cookie
: The HTTP cookie for movielens with a valid sessiontimeoutSececonds
: An exception is raised if the server has not issued a response for timeoutSececonds secondsapi_endpoint
: The api endpoint to connect toverifySSL
: Whether or not to verify SSL
User info methods
login(email, password)
Logs into the provided account, and returns the HTTP cookie
getMe()
Obtain information about the user: number of movies rated, email, username, time of account creation, time of last login, preferences, recommender used, ...
getMyTags()
Statistics on movie related tags the user has left on different films. E.g. desert, black comedy, zombie
getMyStats()
History of ratings, rating distribution, list of movies rated much more or much less that the average.
Movie exploration / search
All of the methods here have the params parameter, a dictionary with parameters to pass to the request. Possible parameters are listed in the documentation for explore(). params is optional for all the methods, and if provided is forwarded to explore()
explore(params)
Used to query Movielens, it can perform searches with various parameters.
q
: string --> Is used to specify the title searchsortBy
: string --> Possible values include: prediction, releaseDate, avgRating, dateAdded, userRatedDate, userListedDatehasWishlisted
: string in ['yes', 'no', 'ignore'] --> Show wishlisted movies onlyhasRated
: string in ['yes', 'no'', 'ignore'] --> Show rated movies onlyhasHidden
: string in ['yes', 'no'', 'ignore'] --> Show hidden movies only
m.explore({'q': 'Dune'})
topPicks(params)
Returns suggested movies based on the given ratings and the chosen recommender
recentReleases(params)
Returns recently released movies
favoritesYear(params)
Returns a selection of higly rated movies from the previous year
newAdditions(params)
Returns movies recently added to Movielens
getMyRatings(params)
Returns movies rated by the user
getMyWishlist(params)
Returns movies added to the whishlist by the user
getMyHiddenMovies(params)
Returns movies hidden by the user
Movie operations
rate(movieId, rating)
Rate a movie on a scale from 0 to 5, with half values (like 3.5) accepted.
addToWishlist(movieId)
Add a movie to the user whishlist
hide(movieId)
Hide a movie from the user. Equivalent to rating the movie -1
removeFromWishlist(movieId)
Remove a movie from the user whishlist
resetRating(movieId)
Delete the rating for the given movie.
unhide(movieId)
Unhide a hidden movie. Calls resetRating()
getMovieInfo(movieId)
Returns both the movie info and the interaction the user had with the movie (rating, hidden, wishlisted, predicted score, ....)
Miscellaneous
getGenres()
Statistics on how many movies are in Movielens, divided by genre. Also the most frequent tags for each genre
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file movielens_private_api-0.0.1.tar.gz
.
File metadata
- Download URL: movielens_private_api-0.0.1.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d52f8743fe326bb40975652fb5606c90d1d782dfffb0eb9a4be360111c750818 |
|
MD5 | 2febc6e842b3c1384d966618bea7937f |
|
BLAKE2b-256 | 4bdb8d416e53ee14db185195007198749f49a3824100f39deef01af69dd9474e |
File details
Details for the file movielens_private_api-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: movielens_private_api-0.0.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.6.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4772bea51b7b1358dd04afb5e988a18e28d54b6c3f7c91a3305e4c29151e138e |
|
MD5 | 7ae697a627151abb1301ef538b432111 |
|
BLAKE2b-256 | 32051ff9b30b51990b2ad2dc79cb6c68ebd22bf54dea21dbe009da0963e531e4 |