diff options
author | Luo Jinghua <sunmoon1997@gmail.com> | 2009-12-26 12:27:23 +0800 |
---|---|---|
committer | Luo Jinghua <sunmoon1997@gmail.com> | 2009-12-26 12:27:23 +0800 |
commit | acf6a4bb2924099aecf4a12d3fe3162922cbbc5b (patch) | |
tree | f1e030d0694cb60969a9a412711f44e47803402f | |
parent | fa11ac7511359c46a4a8d1840890e77c8876608e (diff) |
ppslist: fixed searching movies by keywords
-rw-r--r-- | totem/plugin/ppslist.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/totem/plugin/ppslist.py b/totem/plugin/ppslist.py index 5ef7628..515b375 100644 --- a/totem/plugin/ppslist.py +++ b/totem/plugin/ppslist.py @@ -12,6 +12,7 @@ import os import StringIO import copy import sys +import time from xml.dom import minidom import BeautifulSoup @@ -236,13 +237,16 @@ class PPSMovie: for f in self.files: f.parent = self -def download(url): - for i in range (3): +def download(url, max_retry = 3, interval = 5): + if not url: + return '' + for i in range (max_retry): try: res = urllib.urlopen (url).read () except Exception, e: print "Coudn't open url: ", e res = None + time.sleep (interval) if res: break return res @@ -400,10 +404,11 @@ class PPSList: def searchMovieList(self, keyword, page_id = 0): baseurl = 'http://kan.pps.tv/search/' keyword = unicode(keyword, 'utf-8').encode('gb18030') - url = baseurl + keyword + url = baseurl + urllib.quote(keyword) + '/' if page_id > 0: url += "%d.html" % page_id - s = download(url) + s = download(url, interval = 10) + #print keyword, url, gbk2utf8(s) return s def parseMovieList(self, movie_class, s, page_id = 0): |