Changeset 8953 for ipk/source.sh4/swapplayers_mytube_1_0/var/swap/extensions/MyTube/MyTubeService.py
- Timestamp:
- Aug 19, 2011, 9:48:11 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ipk/source.sh4/swapplayers_mytube_1_0/var/swap/extensions/MyTube/MyTubeService.py
r7451 r8953 1 1 # -*- coding: iso-8859-1 -*- 2 from __init__ import bin2long, long2bin, rsa_pub1024, decrypt_block 2 3 import gdata.youtube 3 4 import gdata.youtube.service … … 224 225 infopage = urlopen2(request).read() 225 226 videoinfo = parse_qs(infopage) 226 if 'fmt_url_map'in videoinfo:227 if ('url_encoded_fmt_stream_map' or 'fmt_url_map') in videoinfo: 227 228 break 228 229 except (URLError, HTTPException, socket.error), err: … … 230 231 return video_url 231 232 232 if 'fmt_url_map'not in videoinfo:233 if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo: 233 234 # Attempt to see if YouTube has issued an error message 234 235 if 'reason' not in videoinfo: 235 print '[MyTube] Error: unable to extract "fmt_url_map" parameter for unknown reason'236 print '[MyTube] Error: unable to extract "fmt_url_map" or "url_encoded_fmt_stream_map" parameter for unknown reason' 236 237 else: 237 238 reason = unquote_plus(videoinfo['reason'][0]) … … 241 242 video_fmt_map = {} 242 243 fmt_infomap = {} 243 tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',') 244 if videoinfo.has_key('url_encoded_fmt_stream_map'): 245 tmp_fmtUrlDATA = videoinfo['url_encoded_fmt_stream_map'][0].split(',url=') 246 else: 247 tmp_fmtUrlDATA = videoinfo['fmt_url_map'][0].split(',') 244 248 for fmtstring in tmp_fmtUrlDATA: 245 (fmtid,fmturl) = fmtstring.split('|') 249 if videoinfo.has_key('url_encoded_fmt_stream_map'): 250 (fmturl, fmtid) = fmtstring.split('&itag=') 251 if fmturl.find("url=") !=-1: 252 fmturl = fmturl.replace("url=","") 253 else: 254 (fmtid,fmturl) = fmtstring.split('|') 246 255 if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid): 247 256 video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) } … … 250 259 if video_fmt_map and len(video_fmt_map): 251 260 print "[MyTube] found best available video format:",video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmtid'] 252 video_url = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmturl'] 261 video_url = video_fmt_map[sorted(video_fmt_map.iterkeys())[0]]['fmturl'].split(';')[0] 253 262 print "[MyTube] found best available video url:",video_url 254 263
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/openaaf/chrome/common/titannit_trac_banner.png)