# -*- coding: UTF-8 -*- # vi:si:et:sw=4:sts=4:ts=4 import re import ox.cache from ox.cache import readUrlUnicode from ox.html import stripTags from ox.text import findRe, removeSpecialCharacters import imdb def getId(url): return url.split("/")[-1] def getUrl(id): return "http://www.criterion.com/films/%s" % id def getData(id, timeout=ox.cache.cache_timeout, get_imdb=False): ''' >>> getData('1333')['imdbId'] u'0060304' >>> getData('236')['posters'][0] u'http://criterion_production.s3.amazonaws.com/release_images/1586/ThirdManReplace.jpg' >>> getData('786')['posters'][0] u'http://criterion_production.s3.amazonaws.com/product_images/185/343_box_348x490.jpg' ''' data = { "url": getUrl(id) } try: html = readUrlUnicode(data["url"], timeout=timeout) except: html = ox.cache.readUrl(data["url"], timeout=timeout) data["number"] = findRe(html, "
  • Spine #(\d+)") data["title"] = findRe(html, "(.*?)")) results = findRe(html, '
    (.*?)
    ') results = re.compile("
  • (.*?)
  • ").findall(results) data["country"] = results[0] data["year"] = results[1] data["synopsis"] = stripTags(findRe(html, "

    SYNOPSIS: (.*?)

    ")) result = findRe(html, "
    (.*?)
    ") if 'Blu-Ray' in result or 'Essential Art House DVD' in result: r = re.compile('

    Other Editions

    (.*?)', re.DOTALL).findall(html) if r: result = r[0] result = findRe(result, "(.*?)' % id) result = findRe(result, "src=\"(.*?)\"") if result: data["posters"] = [result.replace("_w100", "")] else: data["posters"] = [] result = findRe(html, "