From 2ea147cb7c0a6fbdd24369131a9aae083cd12d13 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 14 Oct 2011 21:18:17 +0200 Subject: [PATCH] new piratecinema poster module --- ox/web/piratecinema.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ox/web/piratecinema.py b/ox/web/piratecinema.py index 5a58721..9176e6c 100644 --- a/ox/web/piratecinema.py +++ b/ox/web/piratecinema.py @@ -1,12 +1,17 @@ # -*- coding: utf-8 -*- # vi:si:et:sw=4:sts=4:ts=4 -import ox.cache -from ox.cache import exists - +import re +from ox.cache import readUrlUnicode def getPosterUrl(id): - url = "http://piratecinema.org/posters/%s/%s.jpg" % (id[:4], id) - if ox.cache.exists(url): - return url + url = 'http://piratecinema.org/posters/' + html = readUrlUnicode(url) + results = re.compile('src="(.+)" title=".+\((\d{7})\)"').findall(html) + for result in results: + if result[1] == id: + return url + result[0] return '' +if __name__ == '__main__': + print getPosterUrl('0749451') +