def parse_keys_cb(self, page, options): skey = json.loads(page.split("=")[1][:-1])["key"] vurl = "%s%s?vkey=%s" % (self.urlpre, self.fn, skey) name = "%s_%i.mp4" % (self.name, self.current) self.result.append(name) self.result.append(vurl) if self.current < self.count: self.parse_keys(options) elif options & lplayer.OPT_DOWNLOAD: lplayer.download(self.result, self.name + ".mp4") else: lplayer.play(self.result)
def parse_keys_cb(self, page, options): skey = json.loads(page.split('=')[1][:-1])['key'] vurl = '%s%s?vkey=%s' % (self.urlpre, self.fn, skey) name = '%s_%i.mp4' % (self.name, self.current) self.result.append(name) self.result.append(vurl) if self.current < self.count: self.parse_keys(options) elif options & lplayer.OPT_DOWNLOAD: lplayer.download(self.result, self.name + '.mp4') else: lplayer.play(self.result)
def parse_keys(self, content, options): root = ET.fromstring(content) i = len(self.result) / 2 self.result.append('%s_%i.f4v' % (self.name, i)) self.result.append(root.text) i += 1 if i < len(self.keys): url = 'http://v2.tudou.com/f?id=' + self.keys[i] lplayer.get_url(url, self.parse_keys, options) elif options & lplayer.OPT_DOWNLOAD: lplayer.download(self.result, self.name + '.f4v') else: lplayer.play(self.result)
def parse_cb(page, data): options = data[0] url = data[1] match = cantonese_re.search(page) if match and not '_lang=1' in lplayer.final_url: if lplayer.question('是否解析为粤语版?'): url = match.group(1) if not url.startswith('http://'): url = 'http://www.flvcd.com/' + url url += '&go=1' lplayer.get_url(url, parse_cb, data) return lplayer.warn('解析为粤语版失败!') result = parse_flvcd_page(page, None) if len(result) == 0: lplayer.warn('Cannot parse this video:\n' + url) elif options & lplayer.OPT_DOWNLOAD: lplayer.download(result, result[0]) else: lplayer.play(result)