On Oct 29, Davide Alberani <[EMAIL PROTECTED]> wrote:
> I'm sure a lot of you noticed the new IMDb feature: character pages.
I have a more or less working prototype.
In the CVS there's a branch called "character"; check it out
with:
cvs -z3 -d:pserver:[EMAIL PROTECTED]:/cvsroot/imdbpy co -r character imdbpy
In the attachemnt to this email, a short example.
There's also a new branch (again, "character") of the imdbpyweb
program, to _partially_ handle character support (it's not able to
search or show characters, but they are handled in movies' and persons'
pages).
Keep in mind that probably every client program will require a
bit of attention, to support this new feature.
Any help is welcome.
The movie.currentRole and person.currentRole are now properties:
even when a (unicode/plain) string is passed, a Character object
is instanced. [1]
The Character object can be printed and used in '%s' substitutions
as if it is a normal unicode string (as it was before).
Character names/links in the text (in biographies and so on) are
collected and handled by the usual imdb.utils.modifyStrings function.
Movie instances have the character.currentPlayer attribute, set
to a Person object referring to the actor/actress impersonating
the role in a given movie: this is only set parsing the "filmography"
of a given character.
Every aspect of the current implementation is subject to
rethought: feel free to express doubts and hints.
Caveats:
- actually only 'http' works: 'mobile' support will be easy (at
least I think...), while I really need to think more about 'local'
and 'sql'.
- the utils.modifyStrings and helpers.makeModCGILinks functions now
take another parameter to handle characterRefs; this breaks
client-side code.
I'll see if it's possible to use some reasonable defaults, but
I'm not sure.
- Character class is very similar in anything to the Person (or even
to the Movie) class, but is inherently diffent in one important
fashion: Person and Movie instances are _always_ supposed to have
the p.personID or m.movieID attribute set to something meaningful.
Character objects are different: there can be no "role" (previously
an empty unicode string, now an empty Character instance) associated
to a given person/movie or there can be a "role", but with no
"Character" page associated to it (look at the filmography of some
actor in the web site).
This is a nuisance, client-side: you have to manage separately
the cases where the Character is not set, and cases where it's set,
but it doesn't have a characterID.
I hope to come out with a library-based solution, maybe an
optional keyword of the makeModCGILinks, to handle these cases.
- It's still assumed that an interpreter plays a single character,
in a movie: this is not always true, and I don't really have idea
about how to support this (without breaking A LOT of code).
- the current patch is over 1000 lines written in few days: this means
that the code is getting worse and more fragile.
A lot of care will be needed, and I really need some help looking at
the overall design and implementation of the code.
+++
[1] not that simple: there are some tricks to prevent circular
instantiations (maybe not completely required, to tell the truth).
--
Davide Alberani <[EMAIL PROTECTED]> [PGP KeyID: 0x465BFD47]
http://erlug.linux.it/~da/
#!/usr/bin/env python
import sys
from imdb import IMDb
i = IMDb()
bradpitt = i.get_person('0000093')
print 'BRAD PITT KEYS:', bradpitt, repr(bradpitt)
jessejames = bradpitt['actor'][7].currentRole
print jessejames, repr(jessejames)
print 'JESSE JAMES KEYS:', jessejames.keys()
i.update(jessejames)
print 'JESSE JAMES KEYS AFTER UPDATE:', jessejames.keys()
amovie = jessejames['filmography'][0]
print amovie.currentPlayer, repr(amovie.currentPlayer)
print
searchjj = i.search_character('Jesse James')
for res in searchjj:
print repr(res)
#print
#print i.character2imdbID('Jesse James')
sys.exit()
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Imdbpy-devel mailing list
Imdbpy-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/imdbpy-devel