adding criterion module (depends on imdb module, which is currently broken)
This commit is contained in:
parent
791f19a4e1
commit
de6cd2408d
3 changed files with 34 additions and 3 deletions
32
ox/criterion.py
Normal file
32
ox/criterion.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import re
|
||||||
|
|
||||||
|
import ox.imdb as imdb
|
||||||
|
from oxutils.cache import getUrl
|
||||||
|
from oxutils.html import stripTags
|
||||||
|
from oxutils.text import findRe
|
||||||
|
|
||||||
|
def getPosterUrl(title, director):
|
||||||
|
html = getUrl('http://criterion.com/asp/list.asp?sort=spine')
|
||||||
|
strings = findRe(html, '<table cellspacing="0" id="browse-all-table">(.*?)</table>').split('<tr>')
|
||||||
|
strings.pop(0)
|
||||||
|
for string in strings:
|
||||||
|
criterionid = findRe(string, '"release.asp\?id=(.*?)"')
|
||||||
|
criterionTitle = findRe(string, 'class="title">(.*?)</a>')
|
||||||
|
criterionTitle = re.sub('(?<=\\w)<br>(?=\\w)', ' / ', criterionTitle)
|
||||||
|
criterionTitle = criterionTitle.replace('<br>', '')
|
||||||
|
criteriondirector = stripTags(findRe(string, '</a>.*?</td>(.*?)</td>')).strip()
|
||||||
|
print '%s %s (%s)' % (criterionId, criterionTitle, criterionDirector)
|
||||||
|
# imdb module is currently broken
|
||||||
|
'''
|
||||||
|
imdbId = imdb.getMovieId(title, director)
|
||||||
|
imdbData = imdb.getMovieData(imdbId)
|
||||||
|
if imdbData['title'] == title and imdbData['director'] == director:
|
||||||
|
return 'http://criterion.com/content/images/full_boxshot/%s_box_348x490.jpg' % criterionId
|
||||||
|
'''
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def test():
|
||||||
|
return
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
getPosterUrl('Le Mepris', 'Jean-Luc Godard')
|
|
@ -25,6 +25,7 @@ def getMovieId(title, director='', year=''):
|
||||||
query = 'site:imdb.com %s "%s"' % (director, title)
|
query = 'site:imdb.com %s "%s"' % (director, title)
|
||||||
else:
|
else:
|
||||||
query = 'site:imdb.com "%s"' % title
|
query = 'site:imdb.com "%s"' % title
|
||||||
|
print google.find(query, 3)
|
||||||
for (name, url, desc) in google.find(query, 3):
|
for (name, url, desc) in google.find(query, 3):
|
||||||
if url.startswith('http://www.imdb.com/title/tt'):
|
if url.startswith('http://www.imdb.com/title/tt'):
|
||||||
return url[28:35]
|
return url[28:35]
|
||||||
|
|
|
@ -16,6 +16,4 @@ def getLyrics(title, artist):
|
||||||
return lyrics
|
return lyrics
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print getLyrics('Election Day', 'Arcadia')
|
print getLyrics('Election Day', 'Arcadia')
|
||||||
print getLyrics('Kool Thing', 'Sonic Youth')
|
|
||||||
getLyrics('Material Girl', 'Madonna')
|
|
Loading…
Reference in a new issue