2008-07-06 18:12:30 +00:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
from oxlib import cache
|
|
|
|
from oxlib import findRe
|
|
|
|
|
|
|
|
def getPosterUrls(imdbId):
|
|
|
|
url = 'http://www.movieposterdb.com/movie/%s' % imdbId
|
|
|
|
posterUrls = []
|
|
|
|
if cache.exists(url):
|
|
|
|
posterUrls = parsePage(url)
|
|
|
|
return posterUrls
|
|
|
|
|
|
|
|
def parsePage(url):
|
|
|
|
posterUrls = []
|
|
|
|
html = cache.getUrlUnicode(url, timeout=86400)
|
|
|
|
groups = re.compile('<a href="(http://www.movieposterdb.com/group/.*?)">', re.DOTALL).findall(html)
|
|
|
|
for group in groups:
|
|
|
|
posterUrls += parsePage(group)
|
|
|
|
posters = re.compile('<a href="(http://www.movieposterdb.com/poster/.*?)">', re.DOTALL).findall(html)
|
|
|
|
for poster in posters:
|
|
|
|
html = cache.getUrlUnicode(poster)
|
|
|
|
posterUrls.append(findRe(html, '"(http://www.movieposterdb.com/posters/.*?\.jpg)"'))
|
|
|
|
return posterUrls
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2008-07-06 18:13:37 +00:00
|
|
|
print getPosterUrls('0133093')
|
|
|
|
print getPosterUrls('0060304')
|