# -*- coding: UTF-8 -*- # vi:si:et:sw=4:sts=4:ts=4 import re import oxlib.cache from oxlib.cache import getUrlUnicode from oxlib.html import stripTags from oxlib.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): ''' >>> getData('1333')['imdbId'] '0060304' >>> getData('236')['posters'][0] 'http://criterion_production.s3.amazonaws.com/release_images/1586/ThirdManReplace.jpg' >>> getData('786')['posters'][0] 'http://criterion_production.s3.amazonaws.com/product_images/185/343_box_348x490.jpg' ''' data = { "url": getUrl(id) } try: html = getUrlUnicode(data["url"]) except: html = oxlib.cache.getUrl(data["url"]) data["number"] = findRe(html, "

(.*?)

") data["title"] = findRe(html, "

(.*?)

") data["director"] = findRe(html, "

(.*?)

") results = re.compile("

(.*?)

").findall(html) data["country"] = results[0] data["year"] = results[1] result = findRe(html, "
(.*?)
") data["synopsis"] = findRe(result, "

(.*?)

") result = findRe(html, "
(.*?)
") if 'Blu-Ray' in result or 'Essential Art House DVD' in result: result = re.compile("
(.*?)
", re.DOTALL).findall(html)[1] result = findRe(result, "") if not "/boxsets/" in result: data["posters"] = [result] else: html_ = getUrlUnicode(result) result = findRe(html_, "(.*?)" % id) result = findRe(result, "src=\"(.*?)\"") data["posters"] = [result.replace("_w100", "")] result = findRe(html, "