25 Feb 2012 15:55
helpers functions to handle AKA titles
Hi all, we're introducing some functions, in the imdb.helpers module, to play a little with titles AKAs (most of the code is a work of Alberto Malagoli; refactoring, bugs and misuses of the original idea are mine). The functions: # akasLanguages(movie) Returns a list of tuples in (lang, AKA) format; lang can be None, if unable to guess. # sortAKAsBySimilarity(movie, title, _titlesOnly=True, _preferredLang=None) Return a list of AKAs for the movie (a Movie instance), sorted on similarity with the given title (a string). This is useful to get most similar title to the one you searched, for example. If _preferredLang is given, titles in that languages are preferred. If _titlesOnly is False, the returned values is no longer a list of titles (unicode strings), but a list of (score, title, language) tuples. # getAKAsInLanguage(movie, lang, _searchedTitle=None) Return all AKAs of the movie object, for the given language. If _searchedTitle is given, the results are sorted based on their similarity to it. Notice that "language" is the English, capitalized, representation of the language. So "English", "Italian", "Turkish" and so on, as defined in the LANG_COUNTRIES of the 'imdb.linguistics' modules (I've renamed the 'imdb.articles' module).(Continue reading)
RSS Feed