adding impawards module
This commit is contained in:
parent
9578097c45
commit
8e9d0e8304
2 changed files with 49 additions and 4 deletions
|
@ -22,16 +22,16 @@ def getMovieId(title = '', director = '', imdbId = ''):
|
|||
return ''
|
||||
|
||||
def getMovieData(title = '', director = '', imdbId = ''):
|
||||
data = {}
|
||||
if not imdbId:
|
||||
imdbId = imdb.getMovieId(title, director)
|
||||
id = getMovieId(imdbId = imdbId)
|
||||
if id:
|
||||
html = getUrlUnicode('http://criterion.com/asp/release.asp?id=%s' % id)
|
||||
data = {}
|
||||
data['synopsis'] = stripTags(findRe(html, '<h3>Synopsis</h3>(.*?)</div>'))
|
||||
data['id'] = id
|
||||
data['posterUrl'] = 'http://criterion.com/content/images/full_boxshot/%s_box_348x490.jpg' % id
|
||||
return data
|
||||
return {}
|
||||
data['synopsis'] = stripTags(findRe(html, '<h3>Synopsis</h3>(.*?)</div>'))
|
||||
return data
|
||||
|
||||
if __name__ == '__main__':
|
||||
print getMovieData('Le mepris', 'Jean-Luc Godard')
|
45
ox/impawards.py
Normal file
45
ox/impawards.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
import re
|
||||
|
||||
import ox.imdb as imdb
|
||||
from oxutils.cache import getUrlUnicode
|
||||
from oxutils.text import findRe
|
||||
|
||||
|
||||
def getMovieData(title = '', director = '', imdbId = ''):
|
||||
data = {'posterUrls': []}
|
||||
if not imdbId:
|
||||
imdbId = imdb.getMovieId(title, director)
|
||||
print imdbId
|
||||
html = getUrlUnicode('http://impawards.com/archives/latest.html', timeout = 0)
|
||||
pages = int(findRe(html, '<a href = page(.*?).html>'))
|
||||
for page in range(pages + 1, 0, -1):
|
||||
print page
|
||||
if page <= pages:
|
||||
html = getUrlUnicode('http://impawards.com/archives/page%s.html' % page, timeout = -1)
|
||||
urls = parseArchivePage(html)
|
||||
print urls
|
||||
for url in urls:
|
||||
html = getUrlUnicode(url)
|
||||
d = parseMoviePage(html)
|
||||
print d
|
||||
if d['imdbId'] == imdbId:
|
||||
data['posterUrls'].append(d['posterUrl'])
|
||||
print d['posterUrl']
|
||||
data['posterUrls'].sort()
|
||||
return data
|
||||
|
||||
def parseArchivePage(html):
|
||||
urls = []
|
||||
results = re.compile('<a href = \.\./(.*?)>', re.DOTALL).findall(html)
|
||||
for result in results:
|
||||
urls.append('http://impawards.com/%s' % result)
|
||||
return urls
|
||||
|
||||
def parseMoviePage(html):
|
||||
data = {}
|
||||
data['imdbId'] = findRe(html, 'imdb.com/title/tt(.*?) ')
|
||||
data['posterUrl'] = 'http://impawards.com/%s' % findRe(html, '<td align=center><br><img SRC="(.*?)"')
|
||||
return data
|
||||
|
||||
if __name__ == '__main__':
|
||||
getMovieData('Brick', 'Rian Johnson')
|
Loading…
Reference in a new issue