Table Of Contents

Previous topic

humphrey.core.exceptions

Next topic

humphrey.core.movie

This Page

humphrey.core.model

This module manages all activities relating to the database.

API

class humphrey.core.model.Model(connection, drop=False, echo=False, cache=None)

Data model of the collection.

Parameters:
  • connection (str) – Connection string for the database.
  • drop (bool) – Whether existing tables will be dropped.
  • echo (bool) – Whether SQL commands will be echoed.
  • cache (humphrey.core.cache.Cache) – Cache to use for IMDb lookups. If not given, a new cache will be created.
LATEST_VERSION
Version number of the latest model.
add(ob)
Add an object to the model.
clear_cache(force=False)

Remove all expired objects from the cache.

Parameter:force (bool) – Whether non-expired entries will also be removed.
close()
Disconnect from the database.
delete(ob)
Delete an object from the model.
get_movie(imdb_id, imdb=False)

Return a movie found in the local collection or the IMDb.

Return type:

humphrey.core.movie.Movie

Parameters:
  • imdb_id (unicode) – IMDb id of the movie to find.
  • imdb (bool) – Whether the movie will also be searched on the IMDb.
get_movies(year=None)

Return all movies in the collection ordered by their titles.

Return type:list of humphrey.core.movie.Movie

The movies will be sorted according to their sortable titles and years.

Parameter:year (int) – Restrict the result to the movies made in this year.
get_person(imdb_id)

Return a person found in the local collection.

Return type:humphrey.core.person.Person
Parameter:imdb_id (unicode) – IMDb id of the person to find.
get_version()
Get the version number of the model.
get_years()

Return all distinct movie years.

Return type:list of int
make_movie(imdb_movie, check=True)

Return a movie created from an IMDbPY movie.

Return type:

humphrey.core.movie.Movie

Parameters:
  • imdb_movie (imdb.Movie.Movie) – IMDbPY movie to convert.
  • check (bool) – Whether to check if the movie exists in the database. If it does, that movie will be returned. If not, a new movie will be created and returned.
make_person(imdb_person, check=True)

Return a person created from an IMDbPY person.

Return type:

humphrey.core.person.Person

Parameters:
  • imdb_person (imdb.Person.Person) – IMDbPY person to convert.
  • check (bool) – Whether to check if the person exists in the database. If it does, that person will be returned. If not, a new person will be created.
search_movie(title, imdb=True)

Search for movies in the local collection and the IMDb.

The local results will be the titles containing the search terms. The IMDb results will be movies with titles similar to the search.

Return type:

list of humphrey.core.movie.Movie

Parameters:
  • title (unicode) – Title search terms.
  • imdb (bool) – Whether the title will also be searched on the IMDb.
search_person(name, imdb=True)

Search for persons in the local collection and the IMDb.

The local results will be the names containing the search terms. The IMDb results will be persons with names similar to the search.

Return type:

list of humphrey.core.person.Person

Parameters:
  • name (unicode) – Name search terms.
  • imdb (bool) – Whether the name will also be searched on the IMDb.
set_version(version)
Set the version number of the model.
update(ob)
Add an object to the model.
version
(unicode) Version string of the model.