Exemplo n.º 1
0
def load_item_cb(content, data):
    # Infos
    title_match = title_re.search(content)
    summary_match = summary_re.search(content)
    cover_match = cover_re.search(content)
    if None in (title_match, summary_match, cover_match):
        moonplayer.warn('Bilibili: Fails to get bangumi info!')
        return
    title = title_match.group(1)
    summary = summary_match.group(1)
    cover = unicode_escape(cover_match.group(1))
    if not cover.startswith('http'):
        cover = 'http:' + cover

    # Urls
    match = srcs_re.search(content)
    if not match:
        moonplayer.warn('Bilibili: Parsing fails!')
        return
    data = json.loads(match.group(1))
    srcs = []
    for item in data:
        name = '[%s] %s' % (item['title'], item['longTitle'])
        url = 'https://www.bilibili.com/bangumi/play/ep' + str(item['id'])
        srcs.append(name)
        srcs.append(url)

    result = {
        'name': title,
        'image': cover,
        'summary': summary,
        'source': srcs
    }
    moonplayer.show_detail(result)
Exemplo n.º 2
0
def parse_danmaku_cb(page, data):
    options, result, url = data
    match = cid_re.search(page)
    if match:
        danmaku = 'http://comment.bilibili.com/%s.xml' % match.group(1)
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD, danmaku)
        elif options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                moonplayer.download_with_danmaku(result, danmaku)
            else:
                moonplayer.download_with_danmaku(result, danmaku, result[0])
        else:
            moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD)
        elif options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                moonplayer.download(result)
            else:
                moonplayer.download(result, result[0])
        else:
            moonplayer.play(result)
Exemplo n.º 3
0
def parse(url, options):
    # albums
    if url.startswith("http://www.youku.com/playlist_show/"):
        prefix = url.split(".html")[0]
        moonplayer.get_url(url, parse_album_cb, (prefix, 1, []))
        return
    elif url.startswith("/search_playlistdetail?"):
        prefix = url = "http://www.soku.com" + url
        moonplayer.get_url(url, parse_album2_cb, (prefix, 1, []))
        return
    # details
    elif url.startswith("/detail/show/"):
        url = "http://www.soku.com" + url
        moonplayer.get_url(url, parse_details_cb, None)
        return
    # movies or tv series
    elif url.startswith("http://www.youku.com/show_page/id_"):
        load_item(url)
        return
    # single video
    match = id_re.match(url)
    if not match:
        moonplayer.warn("Please input a valid youku url.")
        return
    url = "http://www.flvcd.com/parse.php?go=1&kw=" + url
    if options & moonplayer.OPT_QL_SUPER:
        url += "&format=super"
    elif options & moonplayer.OPT_QL_HIGH:
        url += "&format=high"
    print url
    moonplayer.get_url(url, parse_cb, options)
Exemplo n.º 4
0
 def parse_cb(self, page, options):
     #page = content.decode('GBK').encode('UTF-8')
     page = convert_to_utf8(page)
     name_match = name_re.search(page)
     if not name_match:
         moonplayer.warn('Cannot get video name.')
         return
     self.name = name_match.group(1)
     
     if options & moonplayer.OPT_QL_SUPER:
         i = 5
     elif options & moonplayer.OPT_QL_HIGH:
         i = 3
     else:
         i = 2
     vlist = [None] * 6
     iid_match = iid_re.search(page)
     while iid_match:
         (pt, k) = iid_match.group(1, 2)
         pt = int(pt)
         if pt < 6:
             if vlist[pt] == None:
                 vlist[pt] = []
             vlist[pt].append(k)
         iid_match = iid_re.search(page, iid_match.end(0))
     while i >= 0:
         if vlist[i]:
             self.keys = vlist[i]
             self.result = []
             url = 'http://v2.tudou.com/f?id=' + self.keys[0]
             moonplayer.get_url(url, self.parse_keys, options)
             return
         i -= 1
     moonplayer.warn('Fail!')
Exemplo n.º 5
0
def parse(url, options):
    #albums
    if url.startswith('http://www.youku.com/playlist_show/'):
        prefix = url[0:-5]
        moonplayer.get_url(url, parse_album_cb, (prefix, 1, []))
        return
    #details
    elif url.startswith('/detail/show/'):
        url = 'http://www.soku.com' + url
        moonplayer.get_url(url, parse_details_cb, None)
        return
    #movies or tv series
    elif url.startswith('http://www.youku.com/show_page/id_'):
        url2 = url.replace('/show_page/', '/show_episode/')
        moonplayer.get_url(url2, parse_series_cb, url)
        return
    #single video
    match = id_re.match(url)
    if not match:
        moonplayer.warn('Please input a valid youku url.')
        return
    url = 'http://www.flvcd.com/parse.php?kw=' + url
    if options & moonplayer.OPT_QL_SUPER:
        url += '&format=super'
    elif options & moonplayer.OPT_QL_HIGH:
        url += '&format=high'
    moonplayer.get_url(url, parse_cb, options)
Exemplo n.º 6
0
def parse_cb(page, options):
    data = json.loads(page)
    if data[u'msg'] != u'ok':
        moonplayer.warn(data[u'msg'].encode('utf-8'))
        return
    info = data[u'info']
    name = info[u'Subject'].encode('utf-8')
    urls = [None] * 3
    for rfile in info[u'rfiles']:
        if rfile[u'type'] == u'super':
            urls[2] = rfile[u'url'].encode('utf-8')
        elif rfile[u'type'] == u'clear':
            urls[1] = rfile[u'url'].encode('utf-8')
        elif rfile[u'type'] == u'normal':
            urls[0] = rfile[u'url'].encode('utf-8')
    if options & moonplayer.OPT_QL_SUPER:
        q = 2
    elif options & moonplayer.OPT_QL_HIGH:
        q = 1
    else:
        q = 0
    for i in xrange(q, -1, -1):
        if urls[i]:
            if options & moonplayer.OPT_DOWNLOAD:
                moonplayer.download([name, urls[i]])
            else:
                moonplayer.play([name, urls[i]])
            return
Exemplo n.º 7
0
def parse_cb(page, options):
    result = parse_flvcd_page(page, None)
    if options & moonplayer.OPT_DOWNLOAD:
        moonplayer.warn(warning_msg)
        moonplayer.download(result, result[0])
    else:
        moonplayer.play(result)
Exemplo n.º 8
0
def parse_danmaku_cb(page, data):
    options, result, url = data
    # Cannot get the video name from flvcd.com page correctly
    match = name_re.search(page)
    if match:
        name = match.group(1) + ".flv"
    else:
        name = result[0]
        
    match = cid_re.search(page)
    if match:
        danmaku = 'http://danmu.aixifan.com/V2/' + match.group(1)
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD, danmaku)
        elif options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                result[0] = name
                moonplayer.download_with_danmaku(result, danmaku)
            else:
                moonplayer.download_with_danmaku(result, danmaku, name)
        else:
            moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD)
        if options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                result[0] = name
                moonplayer.download(result)
            else:
                moonplayer.download(result, name)
        else:
            moonplayer.play(result)
Exemplo n.º 9
0
def parse_danmaku_cb(page, data):
    options, result, url = data
    # Cannot get the video name from flvcd.com page correctly
    match = name_re.search(page)
    if match:
        name = match.group(1) + ".flv"
    else:
        name = result[0]
        
    match = cid_re.search(page)
    if match:
        danmaku = 'http://danmu.aixifan.com/V2/' + match.group(1)
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD, danmaku)
        elif options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                result[0] = name
                moonplayer.download_with_danmaku(result, danmaku)
            else:
                moonplayer.download_with_danmaku(result, danmaku, name)
        else:
            moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        if len(result) == 0:
            moonplayer.use_fallback_parser(url, options & moonplayer.OPT_DOWNLOAD)
        if options & moonplayer.OPT_DOWNLOAD:
            if len(result) == 2:
                result[0] = name
                moonplayer.download(result)
            else:
                moonplayer.download(result, name)
        else:
            moonplayer.play(result)
Exemplo n.º 10
0
def parse_cb(page, options):
    #page = content.decode('GBK').encode('UTF-8')
    page = convert_to_utf8(page)
    name_match = name_re.search(page)
    if not name_match:
        moonplayer.warn('Cannot get video name.')
        return
    name = name_match.group(1)
    
    if options & moonplayer.OPT_QL_SUPER:
        i = 5
    elif options & moonplayer.OPT_QL_HIGH:
        i = 3
    else:
        i = 2
    vlist = [None] * 6
    iid_match = iid_re.search(page)
    while iid_match:
        (pt, k) = iid_match.group(1, 2)
        pt = int(pt)
        if pt < 6:
            vlist[pt] = k
        iid_match = iid_re.search(page, iid_match.end(0))
    while i >= 0:
        if vlist[i]:
            url = 'http://v2.tudou.com/f?id=' + vlist[i]
            moonplayer.get_url(url, parse_cb2, (name, options))
            return
        i -= 1
    moonplayer.warn('Fail!')
Exemplo n.º 11
0
 def parse_cb(self, page, options):
     #page = content.decode('GBK').encode('UTF-8')
     page = convert_to_utf8(page)
     name_match = name_re.search(page)
     if not name_match:
         moonplayer.warn('Cannot get video name.')
         return
     self.name = name_match.group(1)
     
     if options & moonplayer.OPT_QL_SUPER:
         i = 5
     elif options & moonplayer.OPT_QL_HIGH:
         i = 3
     else:
         i = 2
     vlist = [None] * 6
     iid_match = iid_re.search(page)
     while iid_match:
         (pt, k) = iid_match.group(1, 2)
         pt = int(pt)
         if pt < 6:
             if vlist[pt] == None:
                 vlist[pt] = []
             vlist[pt].append(k)
         iid_match = iid_re.search(page, iid_match.end(0))
     while i >= 0:
         if vlist[i]:
             self.keys = vlist[i]
             self.result = []
             url = 'http://v2.tudou.com/f?id=' + self.keys[0]
             moonplayer.get_url(url, self.parse_keys, options)
             return
         i -= 1
     moonplayer.warn('Fail!')
Exemplo n.º 12
0
def parse_cb(page, options):
    #page = content.decode('GBK').encode('UTF-8')
    page = convert_to_utf8(page)
    name_match = name_re.search(page)
    if not name_match:
        moonplayer.warn('Cannot get video name.')
        return
    name = name_match.group(1)

    if options & moonplayer.OPT_QL_SUPER:
        i = 5
    elif options & moonplayer.OPT_QL_HIGH:
        i = 3
    else:
        i = 2
    vlist = [None] * 6
    iid_match = iid_re.search(page)
    while iid_match:
        (pt, k) = iid_match.group(1, 2)
        pt = int(pt)
        if pt < 6:
            vlist[pt] = k
        iid_match = iid_re.search(page, iid_match.end(0))
    while i >= 0:
        if vlist[i]:
            url = 'http://v2.tudou.com/f?id=' + vlist[i]
            moonplayer.get_url(url, parse_cb2, (name, options))
            return
        i -= 1
    moonplayer.warn('Fail!')
Exemplo n.º 13
0
def parse_cb(page, options):
    data = json.loads(page)
    if data[u'msg'] != u'ok':
        moonplayer.warn(data[u'msg'].encode('utf-8'))
        return
    info = data[u'info']
    name = info[u'Subject'].encode('utf-8')
    urls = [None] * 3
    for rfile in info[u'rfiles']:
        if rfile[u'type'] == u'super':
            urls[2] = rfile[u'url'].encode('utf-8')
        elif rfile[u'type'] == u'clear':
            urls[1] = rfile[u'url'].encode('utf-8')
        elif rfile[u'type'] == u'normal':
            urls[0] = rfile[u'url'].encode('utf-8')
    if options & moonplayer.OPT_QL_SUPER:
        q = 2
    elif options & moonplayer.OPT_QL_HIGH:
        q = 1
    else:
        q = 0
    for i in xrange(q, -1, -1):
        if urls[i]:
            if options & moonplayer.OPT_DOWNLOAD:
                moonplayer.download([name, urls[i]])
            else:
                moonplayer.play([name, urls[i]])
            return
Exemplo n.º 14
0
def parse_my_cb(page, msg):
    page = json_pre_process(page)
    page = json.loads(page)
    data = page[u'data']
    #try other quality
    try:
        if not data:
            moonplayer.warn('解析失败!换个清晰度试试?')
            return
        elif msg[1] & moonplayer.OPT_QL_SUPER and u'superVid' in data:
            newvid = str(data[u'superVid'])
        elif msg[1] & (moonplayer.OPT_QL_HIGH | moonplayer.OPT_QL_SUPER):
            newvid = str(data[u'highVid'])
        else:
            newvid = str(data[u'norVid'])
        if len(newvid) > 0 and newvid != msg[0] and newvid != '0':
            msg[0] = newvid
            url = 'http://my.tv.sohu.com/play/videonew.do?af=1&out=0&g=8&vid=' + newvid
            moonplayer.get_url(url, parse_my_cb, msg)
            return
    except KeyError:
        pass
    #parse
    vid = msg[0]
    su = data[u'su']
    ip = page[u'allot']
    name = data[u'tvName'].encode('UTF-8')
    result = []
    i = 0
    #make cdnlist
    cdnlist = [
        'http://%s/cdnList?new=%s&vid=%s' % (ip, new, vid) for new in su
    ]
    data = {'result': [], 'cdnlist': cdnlist, 'name': name, 'options': msg[1]}
    moonplayer.get_url(cdnlist[0], parse_cdnlist, data)
Exemplo n.º 15
0
def parse(url, options):
    #albums
    if url.startswith('http://www.youku.com/playlist_show/'):
        prefix = url[0:-5]
        moonplayer.get_url(url, parse_album_cb, (prefix, 1, []))
        return
    #details
    elif url.startswith('/detail/show/'):
        url = 'http://www.soku.com' + url
        moonplayer.get_url(url, parse_details_cb, None)
        return
    #movies or tv series
    elif url.startswith('http://www.youku.com/show_page/id_'):
        load_item(url)
        return
    #single video
    match = id_re.match(url)
    if not match:
        moonplayer.warn('Please input a valid youku url.')
        return
    url = 'http://www.flvcd.com/parse.php?kw=' + url
    if options & moonplayer.OPT_QL_SUPER:
        url += '&format=super'
    elif options & moonplayer.OPT_QL_HIGH:
        url += '&format=high'
    moonplayer.get_url(url, parse_cb, options)
Exemplo n.º 16
0
def parse_cb2(page, msg):
    page = json_pre_process(page)
    page = json.loads(page)
    data = page[u'data']
    #try other quality
    try:
        if not data:
            moonplayer.warn('解析失败!换个清晰度试试?')
            return
        elif msg[2] & moonplayer.OPT_QL_SUPER and u'superVid' in data:
            newvid = str(data[u'superVid'])
        elif msg[2] & (moonplayer.OPT_QL_HIGH | moonplayer.OPT_QL_SUPER):
            newvid = str(data[u'highVid'])
        else:
            newvid = str(data[u'norVid'])
        if len(newvid) > 0 and newvid != msg[0] and newvid != '0':
            msg[0] = newvid
            url = 'http://hot.vrs.sohu.com/vrs_flash.action?out=0&g=8&r=1&vid=%s&plid=%s' % (msg[0],msg[1])
            moonplayer.get_url(url, parse_cb2, msg)
            return
    except KeyError:
        pass
    #parse
    vid = msg[0]
    su = data[u'su']
    ip = page[u'allot']
    name = data[u'tvName'].encode('UTF-8')
    result = []
    i = 0
    #make cdnlist
    cdnlist = ['http://%s/cdnList?new=%s&vid=%s' % (ip, new, vid) for new in su]
    data = {'result': [], 'cdnlist': cdnlist, 'name': name, 'options': msg[2]}
    moonplayer.get_url(cdnlist[0], parse_cdnlist, data)
Exemplo n.º 17
0
def parse(url, options):
    if url.startswith('http://www.tudou.com/listplay/') or \
    url.startswith('http://www.tudou.com/programs/view/') or \
    url.startswith('http://www.tudou.com/albumplay/'):  #single video
        parser.feed(url, options)
        
    else:  #wrong url
        moonplayer.warn('Please input a valid tudou url.')
Exemplo n.º 18
0
def parse_danmaku_cb(page, result):
    match = cid_re.search(page)
    if match:
        danmaku = 'http://danmu.aixifan.com/V2/' + match.group(1)
        moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        moonplayer.play(result)
Exemplo n.º 19
0
def parse(url, options):
    if url.startswith('http://www.tudou.com/listplay/') or \
    url.startswith('http://www.tudou.com/programs/view/') or \
    url.startswith('http://www.tudou.com/albumplay/'):  #single video
        parser.feed(url, options)

    else:  #wrong url
        moonplayer.warn('Please input a valid tudou url.')
Exemplo n.º 20
0
def parse_danmaku_cb(page, result):
    match = cid_re.search(page)
    if match:
        danmaku = 'http://comment.bilibili.com/%s.xml' % match.group(1)
        moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        moonplayer.play(result)
Exemplo n.º 21
0
def parse_cb(page, data):
    (options, url) = data
    result = parse_flvcd_page(page, None)
    if len(result) == 0:
        moonplayer.warn("Cannot parse bilibili's video!")
    elif options & moonplayer.OPT_DOWNLOAD and len(result) > 2:
        moonplayer.download(result, result[0])
    else:
        moonplayer.get_url(url, parse_danmaku_cb, (options, result))
Exemplo n.º 22
0
def load_youku_item_url_cb(page, data):
    match = yk_item_url_re.search(page)
    if match:
        url = match.group(1)
        if url.startswith('//'):
            url = 'http:' + url
        moonplayer.download_page(url, load_youku_item_cb, None)
    else:
        moonplayer.warn('Parse failed!')
Exemplo n.º 23
0
def parse_cb(page, options):
    result = parse_flvcd_page(page, None)
    if options & moonplayer.OPT_DOWNLOAD:
        try:
            process_redirections(result)
            moonplayer.download(result, result[0])
        except:
            moonplayer.warn("Network error")
    else:
        moonplayer.play(result)
Exemplo n.º 24
0
def parse(url, options):
    if url.startswith('http://www.tudou.com/playlist/id/'):  #album
        url = 'http://www.tudou.com/plcover/coverPage/getIndexItems.html?page=1&pageSize=512&lid=' + url.split('/')[-2]
        moonplayer.get_url(url, parse_album_cb, None)
        
    elif url.startswith('http://www.tudou.com/listplay/') or url.startswith('http://www.tudou.com/programs/view/'):  #single video
        parser.feed(url, options)
        
    else:  #wrong url
        moonplayer.warn('Please input a valid tudou url.')
Exemplo n.º 25
0
def parse_cb(page, options):
    result = parse_flvcd_page(page, None)
    if options & moonplayer.OPT_DOWNLOAD:
        try:
            process_redirections(result)
            moonplayer.download(result, result[0])
        except:
            moonplayer.warn('Network error')
    else:
        moonplayer.play(result)
Exemplo n.º 26
0
def parse_cb(page, options):
    vid_match = vid_re.search(page)
    plid_match = plid_re.search(page)
    if vid_match and plid_match:
        vid = vid_match.group(1)
        plid = plid_match.group(1)
        msg = [vid, plid, options]
        url = 'http://hot.vrs.sohu.com/vrs_flash.action?out=0&g=8&r=1&vid=%s&plid=%s' % (msg[0], msg[1])
        moonplayer.get_url(url, parse_cb2, msg)
    else:
        moonplayer.warn('Fail')
Exemplo n.º 27
0
def parse(url, options):
    if url.startswith('http://www.tudou.com/playlist/id/'):  #album
        url = 'http://www.tudou.com/plcover/coverPage/getIndexItems.html?page=1&pageSize=512&lid=' + url.split(
            '/')[-2]
        moonplayer.get_url(url, parse_album_cb, None)

    elif url.startswith('http://www.tudou.com/listplay/') or url.startswith(
            'http://www.tudou.com/programs/view/'):  #single video
        moonplayer.get_url(url, parse_cb, options)

    else:  #wrong url
        moonplayer.warn('Please input a valid tudou url.')
Exemplo n.º 28
0
def parse(url, options):
    if url.startswith('http://www.iqiyi.com/a_'):
        moonplayer.get_url(url, parse_a_cb, None)
    elif url.startswith('http://www.iqiyi.com/lib/m_'):
        moonplayer.get_url(url, parse_tv_cb, None)
    elif url.startswith('http://www.iqiyi.com/v_') or \
    url.startswith('http://www.iqiyi.com/w_') or \
    url.startswith('http://www.iqiyi.com/dianshiju/') or \
    url.startswith('http://www.iqiyi.com/dianying/'):
        parser.feed(url, options)
    else:
        moonplayer.warn('Wrong URL!')
Exemplo n.º 29
0
def parse(url, options):
    if url.startswith('http://so.tv.sohu.com/show/') or \
        url.startswith('http://tv.sohu.com/item/'): #tv series
        moonplayer.get_url(url, parse_tv_cb, None)
    elif url.startswith('http://tv.sohu.com/2'):  #videos
        moonplayer.get_url(url, parse_cb, options)
    elif url.startswith('http://my.tv.sohu.com/us/'):
        vid = url.split('/')[-1].split('.')[0]
        url = 'http://my.tv.sohu.com/play/videonew.do?af=1&out=0&g=8&vid=' + vid
        moonplayer.get_url(url, parse_my_cb, [vid, options])
    else:
        moonplayer.warn('Wrong url')
Exemplo n.º 30
0
def search(args):
    if "key" in args:
        moonplayer.warn("Not supported.")
        return
    tag = args["tag"]
    country = args["country"]
    if tag == "全部":
        tag = ""
    if country == "全部":
        country = ""
    url = "http://www.youku.com/v_olist/c_97_g_%s_a_%s_s_1_d_2_pt_1_p_%i.html" % (tag, country, args["page"])
    moonplayer.get_url(url, search_cb, None)
Exemplo n.º 31
0
def parse(url, options):
    if url.startswith('http://so.tv.sohu.com/show/') or \
        url.startswith('http://tv.sohu.com/item/'): #tv series
        moonplayer.get_url(url, parse_tv_cb, None)
    elif url.startswith('http://tv.sohu.com/2'): #videos
        moonplayer.get_url(url, parse_cb, options)
    elif url.startswith('http://my.tv.sohu.com/us/'):
        vid = url.split('/')[-1].split('.')[0]
        url = 'http://my.tv.sohu.com/play/videonew.do?af=1&out=0&g=8&vid=' + vid
        moonplayer.get_url(url, parse_my_cb, [vid, options])
    else:
        moonplayer.warn('Wrong url')
Exemplo n.º 32
0
def parse_cb(page, options):
    vid_match = vid_re.search(page)
    plid_match = plid_re.search(page)
    if vid_match and plid_match:
        vid = vid_match.group(1)
        plid = plid_match.group(1)
        msg = [vid, plid, options]
        url = 'http://hot.vrs.sohu.com/vrs_flash.action?out=0&g=8&r=1&vid=%s&plid=%s' % (
            msg[0], msg[1])
        moonplayer.get_url(url, parse_cb2, msg)
    else:
        moonplayer.warn('Fail')
Exemplo n.º 33
0
def parse(url, options):
    match = album_re.search(url) # albums
    if match:
        (wid, aid) = match.group(1, 2)
        AlbumParser(wid, aid)
        return
    match = enid_re.search(url) # videos
    if match and '56.com' in url:
        enid = match.group(1)
        url = 'http://vxml.56.com/json/' + enid + '/?src=site'
        moonplayer.get_url(url, parse_cb, options)
        return
    moonplayer.warn('Wrong url.')
Exemplo n.º 34
0
def parse(url, options):
    match = album_re.search(url)  # albums
    if match:
        (wid, aid) = match.group(1, 2)
        AlbumParser(wid, aid)
        return
    match = enid_re.search(url)  # videos
    if match and '56.com' in url:
        enid = match.group(1)
        url = 'http://vxml.56.com/json/' + enid + '/?src=site'
        moonplayer.get_url(url, parse_cb, options)
        return
    moonplayer.warn('Wrong url.')
Exemplo n.º 35
0
 def parse_final_url(self, content, options):
     i = len(self.result) / 2
     self.result.append('%s_%i.mp4' % (self.name, i))
     self.result.append(str(json.loads(content)['l']))
     i += 1
     if i < len(self.urls):  # Parse next final url
         moonplayer.get_url(self.urls[i], self.parse_final_url, options)
     elif options & moonplayer.OPT_DOWNLOAD:
         moonplayer.download(self.result, self.name + '.mp4')
     else:
         if len(self.urls) > 2:
             moonplayer.warn('本视频较长,爱奇艺视频地址10分钟变化一次,建议下载后播放,避免播放到一半时下载地址失效!')
         moonplayer.play(self.result)
Exemplo n.º 36
0
def parse_subject2(page, vid):
    match = vinfo_re.search(page)
    if match:
        result = []
        data = json.loads(match.group(1))[u'dvideos'][0][u'videos']
        for item in data:
            name = item[u'title'].encode('utf-8')
            url = 'http://www.fun.tv' + str(item[u'url'])
            result.append(name)
            result.append(url)
        moonplayer.show_album(result)
    else:
        moonplayer.warn('Parse fail!')
Exemplo n.º 37
0
def search(args):
    if 'key' in args:
        moonplayer.warn('Not supported.')
        return
    tag = args['tag']
    country = args['country']
    if tag == '全部':
        tag = ''
    if country == '全部':
        country = ''
    url = 'http://www.youku.com/v_olist/c_96_g_%s_a_%s_s_1_d_2_pt_1_p_%i.html' % \
           (tag, country, args['page'])
    moonplayer.get_url(url, search_cb, None)
Exemplo n.º 38
0
def search(args):
    if 'key' in args:
        moonplayer.warn('Not supported.')
        return
    tag = args['tag']
    country = args['country']
    if tag == '全部':
        tag = ''
    if country == '全部':
        country = ''
    url = 'http://www.youku.com/v_olist/c_96_g_%s_a_%s_s_1_d_2_pt_1_p_%i.html' % \
           (tag, country, args['page'])
    moonplayer.get_url(url, search_cb, None)
Exemplo n.º 39
0
 def parse_final_url(self, content, options):
     i = len(self.result) / 2
     self.result.append('%s_%i.mp4' % (self.name, i))
     self.result.append(str(json.loads(content)['l']))
     i += 1
     if i < len(self.urls):  # Parse next final url
         moonplayer.get_url(self.urls[i], self.parse_final_url, options)
     elif options & moonplayer.OPT_DOWNLOAD:
         moonplayer.download(self.result, self.name + '.mp4')
     else:
         if len(self.urls) > 2:
             moonplayer.warn(
                 '本视频较长,爱奇艺视频地址10分钟变化一次,建议下载后播放,避免播放到一半时下载地址失效!')
         moonplayer.play(self.result)
Exemplo n.º 40
0
def load_item(url):
    if url.startswith('bilibili://bangumi/season/'):
        season = url.replace('bilibili://bangumi/season/', '')
    elif url.startswith('/bangumi/i/'):
        season = url.replace('/bangumi/i/', '')
    elif '/anime/' in url:
        season = url.split('/anime/')[1]
    else:
        moonplayer.warn('Bilibili: Cannot open url:' + url)
        return
    if season.endswith('/'):
        season = season[:-1]
    url = 'https://www.bilibili.com/bangumi/play/ss' + season
    moonplayer.download_page(url, load_item_cb, None)
Exemplo n.º 41
0
def parse_cb(page, options):
    # Check errors
    try:
        data = json.loads(page)['data'][0]
    except:
        moonplayer.warn('Video not found!')
        return
    if 'error' in data:
        moonplayer.warn('Error: ' + data['error'])
        return
    
    # Get title, ep, ip, vid
    title = data['title'].encode('utf-8')
    ep = data['ep']
    ip = data['ip']
    vid = data['vidEncoded']
    # Select video quality
    try:
        if options & moonplayer.OPT_QL_SUPER and 'hd2' in data['streamsizes']:
            streamtype = 'hd2'
            streamsize = data['streamsizes']['hd2']
        elif options & (moonplayer.OPT_QL_SUPER|moonplayer.OPT_QL_HIGH) and \
        'mp4' in data['streamsizes']:
            streamtype = 'mp4'
            streamsize = data['streamsizes']['mp4']
        else:
            streamtype = 'flv'
            streamsize = data['streamsizes']['flv']
    except:
        if options & moonplayer.OPT_QL_SUPER and 'hd2' in data['streamtypes_o']:
            streamtype = 'hd2'
        elif options & (moonplayer.OPT_QL_SUPER|moonplayer.OPT_QL_HIGH) and \
        'mp4' in data['streamtypes_o']:
            streamtype = 'mp4'
        else:
            streamtype = 'flv'
        streamsize = 0
    new_ep, sid, token = generate_ep(vid, ep)
    m3u8_url = 'http://pl.youku.com/playlist/m3u8?ctype=12\
    &ep=%s\
    &ev=1\
    &keyframe=1\
    &oip=%i\
    &sid=%s\
    &token=%s\
    &ts=%i\
    &type=%s\
    &vid=%s' % (new_ep, ip, sid, token, int(time.time()), streamtype, vid)
    m3u8_url = m3u8_url.replace(' ', '')
    moonplayer.get_url(m3u8_url, parse_m3u8_cb, (options, title))
Exemplo n.º 42
0
 def parse_key(self, content, options):
     result = []
     key = moonplayer.final_url.split('key=')[1]
     for i in xrange(len(self.urls)):
         name = '%s_%d.%s' % (self.name, i, self.suffix)
         result.append(name) #name
         result.append(self.urls[i] + '?key=' + key) #url
         
     if options & moonplayer.OPT_DOWNLOAD:
         moonplayer.download(result, result[0])
     else:
         if len(self.urls) > 2:
             moonplayer.warn('本视频较长,爱奇艺视频地址10分钟变化一次,建议下载后播放,避免播放到一半时下载地址失效!')
         moonplayer.play(result)
Exemplo n.º 43
0
def parse_danmaku_cb(page, data):
    (options, result) = data
    match = cid_re.search(page)
    if match:
        danmaku = 'http://comment.bilibili.com/%s.xml' % match.group(1)
        if options & moonplayer.OPT_DOWNLOAD:
            moonplayer.download_with_danmaku(result, danmaku)
        else:
            moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        if options & moonplayer.OPT_DOWNLOAD:
            moonplayer.download(result)
        else:
            moonplayer.play(result)
Exemplo n.º 44
0
 def parse_vid(self, content, options):
     name_match = name_re.search(content)
     if name_match:
         self.name = name_match.group(1)
     else:
         self.name = '未知视频名称'
     tvid_match = tvid_re.search(content)
     vid_match = vid_re.search(content)
     if tvid_match and vid_match:
         tvid = tvid_match.group(1)
         vid = vid_match.group(1)
         url = 'http://cache.video.qiyi.com/vd/%s/%s/' % (tvid, vid)
         moonplayer.get_url(url, self.parse_vurl, options)
     else:
         moonplayer.warn('Fail!')
Exemplo n.º 45
0
def parse_cb(page, data):
    options = data[0]
    url = data[1]
    result = parse_flvcd_page(page, None)
    if len(result) == 0:
        moonplayer.warn('Cannot parse this video:\n' + url)
        
    elif options & moonplayer.OPT_DOWNLOAD:
        if len(result) == 2: # single clip
            moonplayer.download(result)
        else:
            moonplayer.download(result, result[0])
    
    else:
        moonplayer.get_url(url, parse_danmaku_cb, result)
Exemplo n.º 46
0
 def parse_vms(self, content, options):
     info = json.loads(content)
     if info['code'] != 'A000000':
         moonplayer.warn('Code Error')
         return
     if info["data"]['vp']["tkl"]=='':
         moonplayer.warn('Error: empty data.')
         return
     # Read urls of all qualities
     vs = info["data"]["vp"]["tkl"][0]["vs"]
     bids = [None] * 5
     for v in vs:
         bid = int(v[u'bid']) - 1
         if bid < 5 and bid >= 0:
             bids[bid] = v['fs']
             if not v["fs"][0]["l"].startswith("/"):
                 tmp = self.getVrsEncodeCode(v["fs"][0]["l"])
                 if tmp.endswith('mp4'):
                     bids[bid] = v["flvs"]
     # Select quality
     if options & moonplayer.OPT_QL_SUPER:
         q = 3
     elif options & moonplayer.OPT_QL_HIGH:
         q = 1
     else:
         q = 0
     for i in xrange(q, -1, -1):
         if bids[i]:
             self.video_links = bids[i]
             break
     if options & moonplayer.OPT_DOWNLOAD and bids[4]:
         if moonplayer.question('是否下载1080P版本?'):
             self.video_links = bids[4]
     
     # Get video's key
     self.urls = []
     self.vlinks = []
     self.key_roots = []
     self.info = info
     for i in self.video_links:
         vlink = i['l']
         if not vlink.startswith('/'):
             vlink = self.getVrsEncodeCode(vlink)
         self.vlinks.append(vlink)
         self.key_roots.append(vlink.split("/")[-1].split(".")[0])
     url = "http://data.video.qiyi.com/t?tn=" + str(random())
     moonplayer.get_url(url, self.parse_key, options)
Exemplo n.º 47
0
    def parse_vms(self, content, options):
        info = json.loads(content)
        if info['code'] != 'A000000':
            moonplayer.warn('Code Error')
            return
        if info["data"]['vp']["tkl"] == '':
            moonplayer.warn('Error: empty data.')
            return
        # Read urls of all qualities
        vs = info["data"]["vp"]["tkl"][0]["vs"]
        bids = [None] * 5
        for v in vs:
            bid = int(v[u'bid']) - 1
            if bid < 5 and bid >= 0:
                bids[bid] = v['fs']
                if not v["fs"][0]["l"].startswith("/"):
                    tmp = self.getVrsEncodeCode(v["fs"][0]["l"])
                    if tmp.endswith('mp4'):
                        bids[bid] = v["flvs"]
        # Select quality
        if options & moonplayer.OPT_QL_SUPER:
            q = 3
        elif options & moonplayer.OPT_QL_HIGH:
            q = 1
        else:
            q = 0
        for i in xrange(q, -1, -1):
            if bids[i]:
                self.video_links = bids[i]
                break
        if options & moonplayer.OPT_DOWNLOAD and bids[4]:
            if moonplayer.question('是否下载1080P版本?'):
                self.video_links = bids[4]

        # Get video's key
        self.urls = []
        self.vlinks = []
        self.key_roots = []
        self.info = info
        for i in self.video_links:
            vlink = i['l']
            if not vlink.startswith('/'):
                vlink = self.getVrsEncodeCode(vlink)
            self.vlinks.append(vlink)
            self.key_roots.append(vlink.split("/")[-1].split(".")[0])
        url = "http://data.video.qiyi.com/t?tn=" + str(random())
        moonplayer.get_url(url, self.parse_key, options)
Exemplo n.º 48
0
 def parse_cb(self, page, options):
     #page = content.decode('GBK').encode('UTF-8')
     page = convert_to_utf8(page)
     name_match = name_re.search(page)
     if not name_match:
         moonplayer.warn('Cannot get video name.')
         return
     self.name = name_match.group(1)
     
     if options & moonplayer.OPT_QL_1080P:
         i = 6
     if options & moonplayer.OPT_QL_SUPER:
         i = 5
     elif options & moonplayer.OPT_QL_HIGH:
         i = 3
     else:
         i = 2
     vlist = [None] * 7
     iid_match = iid_re.search(page)
     vcode_match = vcode_re.search(page)
     
     # Link to youku
     if vcode_match and not iid_match:
         url = 'http://v.youku.com/v_show/id_%s.html' % vcode_match.group(1)
         flvcd_parser.parse(url, options)
         return
         
     while iid_match:
         (pt, k) = iid_match.group(1, 2)
         pt = int(pt)
         if pt == 99: # Real quality
             pt = 6
         if pt <= 6:
             if vlist[pt] == None:
                 vlist[pt] = []
             vlist[pt].append(k)
         iid_match = iid_re.search(page, iid_match.end(0))
     while i >= 0:
         if vlist[i]:
             self.keys = vlist[i]
             self.result = []
             url = 'http://v2.tudou.com/f?id=' + self.keys[0]
             moonplayer.get_url(url, self.parse_keys, options)
             return
         i -= 1
     moonplayer.warn('Fail!')
Exemplo n.º 49
0
    def parse_cb(self, page, options):
        #page = content.decode('GBK').encode('UTF-8')
        page = convert_to_utf8(page)
        name_match = name_re.search(page)
        if not name_match:
            moonplayer.warn('Cannot get video name.')
            return
        self.name = name_match.group(1)

        if options & moonplayer.OPT_QL_1080P:
            i = 6
        if options & moonplayer.OPT_QL_SUPER:
            i = 5
        elif options & moonplayer.OPT_QL_HIGH:
            i = 3
        else:
            i = 2
        vlist = [None] * 7
        iid_match = iid_re.search(page)
        vcode_match = vcode_re.search(page)

        # Link to youku
        if vcode_match and not iid_match:
            url = 'http://v.youku.com/v_show/id_%s.html' % vcode_match.group(1)
            flvcd_parser.parse(url, options)
            return

        while iid_match:
            (pt, k) = iid_match.group(1, 2)
            pt = int(pt)
            if pt == 99:  # Real quality
                pt = 6
            if pt <= 6:
                if vlist[pt] == None:
                    vlist[pt] = []
                vlist[pt].append(k)
            iid_match = iid_re.search(page, iid_match.end(0))
        while i >= 0:
            if vlist[i]:
                self.keys = vlist[i]
                self.result = []
                url = 'http://v2.tudou.com/f?id=' + self.keys[0]
                moonplayer.get_url(url, self.parse_keys, options)
                return
            i -= 1
        moonplayer.warn('Fail!')
Exemplo n.º 50
0
    def parse_cb(self, page, options):
        match = name_re.search(page)
        if not match:
            moonplayer.warn('Cannot get the video name!')
            return
        self.name = match.group(1)
        if self.name.isdigit():
            match = cover_re.search(page)
            if match:
                self.name = match.group(1) + '-' + self.name

        match = vid_re.search(page)
        if match:
            self.vid = match.group(1)
            url = 'http://vv.video.qq.com/getinfo?otype=json&vids=' + self.vid
            moonplayer.get_url(url, self.parse_cb2, options)
        else:
            moonplayer.warn('Cannot find the vid of this video.')
Exemplo n.º 51
0
def parse_danmaku_cb(page, data):
    (options, result) = data
    match = name_re.search(page)
    if match:
        result[0] = match.group(1) + ".flv"

    match = cid_re.search(page)
    if match:
        danmaku = 'http://danmu.aixifan.com/V2/' + match.group(1)
        if options & moonplayer.OPT_DOWNLOAD:
            moonplayer.download_with_danmaku(result, danmaku)
        else:
            moonplayer.play(result, danmaku)
    else:
        moonplayer.warn('无法获取弹幕!')
        if options & moonplayer.OPT_DOWNLOAD:
            moonplayer.download(result)
        else:
            moonplayer.play(result)
Exemplo n.º 52
0
def search(key, page):
    global pageTokens
    qs = {
        'q': key,
        'maxResults': 25,
        'safeSearch': 'none',
        'part': 'id,snippet',
        'type': 'video',
        'key': appkey
    }
    if page == 1:
        pageTokens = ['', '']
    elif page < len(pageTokens):
        qs['pageToken'] = pageTokens[page]
    else:
        moonplayer.warn("Cannot skip page due to the limitation of Youtube's API.")
        return
    url = 'https://www.googleapis.com/youtube/v3/search?' + urlencode(qs)
    moonplayer.download_page(url, search_cb, page)
Exemplo n.º 53
0
def parse_cb(page, data):
    options = data[0]
    url = data[1]
    match = cantonese_re.search(page)
    if match and not '_lang=1' in moonplayer.final_url:
        if moonplayer.question('是否解析为粤语版?'):
            url = match.group(1)
            if not url.startswith('http://'):
                url = 'http://www.flvcd.com/' + url
            url += '&go=1'
            moonplayer.get_url(url, parse_cb, data)
            return
    result = parse_flvcd_page(page, None)
    if len(result) == 0:
        moonplayer.warn('Cannot parse this video:\n' + url)
    elif options & moonplayer.OPT_DOWNLOAD:
        moonplayer.download(result, result[0])
    else:
        moonplayer.play(result)