Ignore:
Timestamp:
Aug 19, 2011, 9:48:11 AM (15 years ago)
Author:
bonkel
Message:

fix swapmytube

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipk/source.sh4/swapplayers_mytube_1_0/var/swap/extensions/MyTube/MyTubeService.py

    r7451 r8953  
    11# -*- coding: iso-8859-1 -*-
     2from __init__ import bin2long, long2bin, rsa_pub1024, decrypt_block
    23import gdata.youtube
    34import gdata.youtube.service
     
    224225                                infopage = urlopen2(request).read()
    225226                                videoinfo = parse_qs(infopage)
    226                                 if 'fmt_url_map' in videoinfo:
     227                                if ('url_encoded_fmt_stream_map' or 'fmt_url_map') in videoinfo:
    227228                                        break
    228229                        except (URLError, HTTPException, socket.error), err:
     
    230231                                return video_url
    231232
    232                 if 'fmt_url_map' not in videoinfo:
     233                if ('url_encoded_fmt_stream_map' or 'fmt_url_map') not in videoinfo:
    233234                        # Attempt to see if YouTube has issued an error message
    234235                        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'
    236237                        else:
    237238                                reason = unquote_plus(videoinfo['reason'][0])
     
    241242                video_fmt_map = {}
    242243                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(',')       
    244248                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('|')               
    246255                        if VIDEO_FMT_PRIORITY_MAP.has_key(fmtid):
    247256                                video_fmt_map[VIDEO_FMT_PRIORITY_MAP[fmtid]] = { 'fmtid': fmtid, 'fmturl': unquote_plus(fmturl) }
     
    250259                if video_fmt_map and len(video_fmt_map):
    251260                        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]
    253262                        print "[MyTube] found best available video url:",video_url
    254263               
Note: See TracChangeset for help on using the changeset viewer.