- print "got",sorted(fmt_infomap.iterkeys())
- if video_fmt_map and len(video_fmt_map):
- video_url = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmturl'].split(';')[0]
- #print "found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid']
- #print "found best available video url:",video_url
- return video_url
+ print "fmtinfomap :",sorted(fmt_infomap.iterkeys())
+
+ video_url_list = []
+ if video_fmt_map:
+ idx = 0
+ sorted_fmt_keys = sorted(video_fmt_map.iterkeys())
+ for x in video_fmt_map:
+ try:
+ videofmt = video_fmt_map[sorted_fmt_keys[idx]]
+ video_url = videofmt['fmturl'].split(';')[0]
+ quality_str = self.qCode2String(videofmt['fmtid'])
+ #print "detected video : quality [%s], url [%s]" % (quality_str, video_url)
+ if video_url and quality_str:
+ video_url_list.append((quality_str, video_url))
+ print "added quality [%s], url [%s]" % (quality_str, video_url)
+ except Exception, msg: print "Error >>", msg
+ idx = idx + 1
+ return video_url_list
+
+ def qCode2String(self, qcode):
+ qstr = None
+ try:
+ qstr = self.QUALITY_CODE[qcode]
+ except: pass
+ #print "quality : code[%s], str[%s]" % (qcode, qstr)
+ return qstr