2008-07-06 18:12:30 +00:00
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
2009-07-13 21:12:06 +00:00
|
|
|
from oxlib.cache import getUrlUnicode
|
2008-07-06 18:12:30 +00:00
|
|
|
from oxlib import findRe
|
|
|
|
|
2009-07-13 21:12:06 +00:00
|
|
|
def getData(id):
|
|
|
|
data = {
|
|
|
|
"url": getUrl(id)
|
|
|
|
}
|
|
|
|
data["posters"] = getPostersByUrl(data["url"])
|
|
|
|
return data
|
|
|
|
|
|
|
|
def getId(url):
|
|
|
|
return url.split("/")[-2]
|
|
|
|
|
|
|
|
def getPostersByUrl(url):
|
|
|
|
posters = []
|
|
|
|
html = getUrlUnicode(url)
|
|
|
|
results = re.compile('<a href="(http://www.movieposterdb.com/group/.*?)">', re.DOTALL).findall(html)
|
|
|
|
for result in results:
|
|
|
|
posters += getPostersByUrl(result)
|
|
|
|
results = re.compile('<a href="(http://www.movieposterdb.com/poster/.*?)">', re.DOTALL).findall(html)
|
|
|
|
for result in results:
|
|
|
|
html = getUrlUnicode(result)
|
|
|
|
posters.append(findRe(html, '"(http://www.movieposterdb.com/posters/.*?\.jpg)"'))
|
|
|
|
return posters
|
|
|
|
|
|
|
|
def getUrl(id):
|
|
|
|
return "http://www.movieposterdb.com/movie/%s/" % id
|
2008-07-06 18:12:30 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2009-07-13 21:12:06 +00:00
|
|
|
print getData('0060304')
|
|
|
|
print getData('0133093')
|