2008-05-08 08:25:44 +00:00
|
|
|
import re
|
|
|
|
|
|
|
|
import ox.imdb as imdb
|
|
|
|
from oxutils.cache import getUrl
|
|
|
|
from oxutils.html import stripTags
|
|
|
|
from oxutils.text import findRe
|
|
|
|
|
|
|
|
def getPosterUrl(title, director):
|
2008-05-08 08:32:14 +00:00
|
|
|
# imdb module is currently broken
|
|
|
|
'''
|
|
|
|
imdbId = imdb.getMovieId(title, director)
|
|
|
|
'''
|
2008-05-08 08:25:44 +00:00
|
|
|
html = getUrl('http://criterion.com/asp/list.asp?sort=spine')
|
|
|
|
strings = findRe(html, '<table cellspacing="0" id="browse-all-table">(.*?)</table>').split('<tr>')
|
|
|
|
strings.pop(0)
|
|
|
|
for string in strings:
|
|
|
|
criterionid = findRe(string, '"release.asp\?id=(.*?)"')
|
|
|
|
criterionTitle = findRe(string, 'class="title">(.*?)</a>')
|
|
|
|
criterionTitle = re.sub('(?<=\\w)<br>(?=\\w)', ' / ', criterionTitle)
|
|
|
|
criterionTitle = criterionTitle.replace('<br>', '')
|
2008-05-08 08:32:14 +00:00
|
|
|
criterionDirector = stripTags(findRe(string, '</a>.*?</td>(.*?)</td>')).strip()
|
|
|
|
print '%s: %s (%s)' % (criterionId, criterionTitle, criterionDirector)
|
2008-05-08 08:25:44 +00:00
|
|
|
'''
|
2008-05-08 08:32:14 +00:00
|
|
|
if imdb.getMovieId(criterionTitle, criterionDirector) == imdbId:
|
2008-05-08 08:25:44 +00:00
|
|
|
return 'http://criterion.com/content/images/full_boxshot/%s_box_348x490.jpg' % criterionId
|
|
|
|
'''
|
|
|
|
return ''
|
|
|
|
|
|
|
|
def test():
|
|
|
|
return
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2008-05-08 08:32:14 +00:00
|
|
|
getPosterUrl('Le mepris', 'Jean-Luc Godard')
|