From de6cd2408dfe617df6e5d23aee100efe2c072609 Mon Sep 17 00:00:00 2001 From: Rolux Date: Thu, 8 May 2008 10:25:44 +0200 Subject: [PATCH] adding criterion module (depends on imdb module, which is currently broken) --- ox/criterion.py | 32 ++++++++++++++++++++++++++++++++ ox/imdb.py | 1 + ox/lyricsfly.py | 4 +--- 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 ox/criterion.py diff --git a/ox/criterion.py b/ox/criterion.py new file mode 100644 index 0000000..5062503 --- /dev/null +++ b/ox/criterion.py @@ -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, '(.*?)
').split('') + strings.pop(0) + for string in strings: + criterionid = findRe(string, '"release.asp\?id=(.*?)"') + criterionTitle = findRe(string, 'class="title">(.*?)') + criterionTitle = re.sub('(?<=\\w)
(?=\\w)', ' / ', criterionTitle) + criterionTitle = criterionTitle.replace('
', '') + criteriondirector = stripTags(findRe(string, '.*?(.*?)')).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') \ No newline at end of file diff --git a/ox/imdb.py b/ox/imdb.py index 78b84b7..e1d9c67 100644 --- a/ox/imdb.py +++ b/ox/imdb.py @@ -25,6 +25,7 @@ def getMovieId(title, director='', year=''): query = 'site:imdb.com %s "%s"' % (director, title) else: query = 'site:imdb.com "%s"' % title + print google.find(query, 3) for (name, url, desc) in google.find(query, 3): if url.startswith('http://www.imdb.com/title/tt'): return url[28:35] diff --git a/ox/lyricsfly.py b/ox/lyricsfly.py index eb72537..7ae489e 100644 --- a/ox/lyricsfly.py +++ b/ox/lyricsfly.py @@ -16,6 +16,4 @@ def getLyrics(title, artist): return lyrics if __name__ == '__main__': - print getLyrics('Election Day', 'Arcadia') - print getLyrics('Kool Thing', 'Sonic Youth') - getLyrics('Material Girl', 'Madonna') \ No newline at end of file + print getLyrics('Election Day', 'Arcadia') \ No newline at end of file