Table Of Contents

Previous topic

humphrey.core.model

Next topic

humphrey.core.person

This Page

humphrey.core.movie

This module contains the classes regarding movies.

Every movie has a title which must be specified on initialization. The title may not be empty and may not consist only of whitespace. Other information about a movie includes its year, directors and cast.

It is possible -and recommended- to store the IMDb ids of movies. The IMDb id is a 7-digit string and it will be used as the primary value to identify a movie. Two movies are considered equal if they have the same IMDb id, regardless of their other data:

>>> m1 = Movie(u"The Matrix Reloaded", imdb_id=u'0234215')
>>> m2 = Movie(u"The Matrix 2", imdb_id=u'0234215')
>>> m1 == m2
True

If they have no IMDb ids, their titles will be checked. A comparison between a movie and a title is also valid:

>>> m = Movie(u"The Matrix")
>>> m == u"The Matrix"
True

For every movie, there is also a sortable title which is used for comparing titles. In sortable titles, articles like “The”, “An” will not be considered. This is also the default when comparing two movies:

>>> m1 = Movie(u"The Matrix")
>>> m2 = Movie(u"Suspiria")
>>> m1 < m2
True

If two movies have the same sortable title, the older movie comes first:

>>> m1 = Movie(u"The Shining", year=1980)
>>> m2 = Movie(u"The Shining", year=1997)
>>> m1 < m2
True

Other Titles

Movies can have more than one title and they can have different titles in different countries and languages. An AKA (also known as) represents another title for a movie.

An AKA must be initialized with a title text and can be checked for equality against a title:

>>> a = AKA(u"Deep Red")
>>> a == u"Deep Red"
True

When another title for a movie is obtained from IMDb, it is checked to see whether it is for a country for which titles will be accepted. These countries are kept in Movie.AKA_COUNTRIES. The following helper functions can be used for getting the title and notes from an a.k.a. string as provided by IMDb:

humphrey.core.movie.get_aka_info(unicode) → unicode
Return the title from an annotated a.k.a. string.
humphrey.core.movie.get_aka_notes(unicode) → unicode
Return the notes from an annotated a.k.a. string.

API

class humphrey.core.movie.Movie(title, imdb_id=None, sortable_title=None, year=None, runtime=None, akas=None, directors=None, cast=None)

A movie.

AKA_COUNTRIES
Countries for which local titles will be accepted.
add_aka(aka)

Add another title to the movie.

The new title will not be added if it is empty, same as the main title, already present in the list of other titles, or local to a country which has not been selected.

Parameter:aka (unicode | humphrey.core.movie.AKA) – New title to add to the movie.
add_cast_member(person)

Add a cast member to the movie.

Parameter:person (humphrey.core.person.CastMember | humphrey.core.person.Person) – Person to add as cast member.
add_director(person)

Add a director to the movie.

Parameter:person (humphrey.core.person.Director | humphrey.core.person.Person) – Person to add as director.
akas
(list of humphrey.core.movie.AKA) Other titles of the movie.
asXML()
Return an XML representation of the movie.
cast
(list of humphrey.core.person.Person) Cast members of the movie.
directors
(list of humphrey.core.person.Person) Directors of the movie.
get_akas()
Return the other titles of the movie.
get_cast()
Return the cast members of the movie.
get_directors()
Return the directors of the movie.
get_imdb_id()
Return the IMDb id of the movie.
get_runtime()
Return the runtime of the movie.
get_sortable_title()
Return the sortable title of the movie.
get_title()
Return the title of the movie.
get_year()
Return the year of the movie.
imdb_id
(unicode) IMDb id of the movie.
remove_aka(aka)

Remove a title from the other titles of a movie.

Parameter:aka (unicode | humphrey.core.movie.AKA) – Title to remove.
remove_cast_member(person)

Remove a person from the cast members of a movie.

Parameter:person (humphrey.core.person.CastMember | humphrey.core.person.Person | unicode) – Person to remove.
remove_director(person)

Remove a person from the directors list of a movie.

Parameter:person (humphrey.core.person.Director | humphrey.core.person.Person | unicode) – Person to remove.
runtime
(int) Runtime of the movie.
set_akas(akas)

Set the other titles of the movie.

Parameter:akas (list of { unicode | humphrey.core.movie.AKA }) – New list of titles to set.
set_cast(cast)

Set the cast members of the movie.

Parameter:cast (list of { humphrey.core.person.CastMember | humphrey.core.person.Person }) – New list of cast members to set.
set_directors(directors)

Set the directors of the movie.

Parameter:directors (list of { humphrey.core.person.Director | humphrey.core.person.Person }) – New list of directors to set.
set_imdb_id(imdb_id)

Set the IMDb id of the movie.

Parameter:imdb_id (unicode | str | int | long) – New IMDb id value to set. If a number or a string, it will be converted to unicode.
Raises ValueError:
 If the IMDb id is invalid.
set_runtime(runtime)

Set the runtime of the movie.

Parameter:runtime (int) – New runtime value to set. If 0, it will be regarded as unspecified.
set_sortable_title(sortable_title, remove_article=False)

Set the sortable title of the movie.

Parameters:
  • sortable_title (unicode) – New sortable_title value to set. It will be stripped of leading and trailing whitespace and the first letter of the first word will be capitalized. If empty, it will be derived from the title.
  • remove_article (bool) – Whether the article should be removed from the title.
set_title(title)

Set the title of the movie.

Parameter:title (unicode) – New title value to set. It will be stripped of leading and trailing whitespace. If empty, it will be regarded as unspecified.
Raises ValueError:
 If title is not specified.
set_year(year)

Set the year of the movie.

Parameter:year (int) – New year value to set. If 0, it will be regarded as unspecified.
sortable_title
(unicode) Title to use when sorting movies.
title
(unicode) Title of the movie.
year
(int) Year of the movie.
class humphrey.core.movie.AKA(title)

A different title for a movie.

get_title()
Return the title.
movie
(humphrey.core.movie.Movie) Movie which has this title.
set_title(title)

Set the title.

Parameter:title (unicode) – New title value to set. It will be stripped of leading and trailing whitespace. If empty, it will be regarded as unspecified.
Raises ValueError:
 If title is not specified.
title
(unicode) Text of the title.