def baidu_download(url, output_dir='.', stream_type=None, merge=True, info_only=False, **kwargs):
    if re.match('https?://pan.baidu.com', url):
        (real_url, title, ext, size) = baidu_pan_download(url)
        print_info('BaiduPan', title, ext, size)
        if (not info_only):
            print('Hold on...')
            time.sleep(5)
            download_urls([real_url], title, ext, size, output_dir, url, merge=merge, faker=True)
    elif re.match('http://music.baidu.com/album/\\d+', url):
        id = r1('http://music.baidu.com/album/(\\d+)', url)
        baidu_download_album(id, output_dir, merge, info_only)
    elif re.match('http://music.baidu.com/song/\\d+', url):
        id = r1('http://music.baidu.com/song/(\\d+)', url)
        baidu_download_song(id, output_dir, merge, info_only)
    elif re.match('http://tieba.baidu.com/', url):
        try:
            embed_download(url, output_dir, merge=merge, info_only=info_only, **kwargs)
        except:
            html = get_html(url)
            title = r1('title:"([^"]+)"', html)
            vhsrc = (re.findall('"BDE_Image"[^>]+src="([^"]+\\.mp4)"', html) or re.findall('vhsrc="([^"]+)"', html))
            if (len(vhsrc) > 0):
                ext = 'mp4'
                size = url_size(vhsrc[0])
                print_info(site_info, title, ext, size)
                if (not info_only):
                    download_urls(vhsrc, title, ext, size, output_dir=output_dir, merge=False)
            items = re.findall('//imgsrc.baidu.com/forum/w[^"]+/([^/"]+)', html)
            urls = [('http://imgsrc.baidu.com/forum/pic/item/' + i) for i in set(items)]
            kw = (r1('kw=([^&]+)', html) or r1("kw:'([^']+)'", html))
            tid = (r1('tid=(\\d+)', html) or r1("tid:'([^']+)'", html))
            album_url = ('http://tieba.baidu.com/photo/g/bw/picture/list?kw=%s&tid=%s&pe=%s' % (kw, tid, 1000))
            album_info = json.loads(get_content(album_url))
            for i in album_info['data']['pic_list']:
                urls.append((('http://imgsrc.baidu.com/forum/pic/item/' + i['pic_id']) + '.jpg'))
            ext = 'jpg'
            size = float('Inf')
            print_info(site_info, title, ext, size)
            if (not info_only):
                download_urls(urls, title, ext, size, output_dir=output_dir, merge=False)
def baidu_download(url, output_dir='.', stream_type=None, merge=True, info_only=False, **kwargs):
    if re.match('https?://pan.baidu.com', url):
        (real_url, title, ext, size) = baidu_pan_download(url)
        print_info('BaiduPan', title, ext, size)
        if (not info_only):
            print('Hold on...')
            time.sleep(5)
            download_urls([real_url], title, ext, size, output_dir, url, merge=merge, faker=True)
    elif re.match('http://music.baidu.com/album/\\d+', url):
        id = r1('http://music.baidu.com/album/(\\d+)', url)
        baidu_download_album(id, output_dir, merge, info_only)
    elif re.match('http://music.baidu.com/song/\\d+', url):
        id = r1('http://music.baidu.com/song/(\\d+)', url)
        baidu_download_song(id, output_dir, merge, info_only)
    elif re.match('http://tieba.baidu.com/', url):
        try:
            embed_download(url, output_dir, merge=merge, info_only=info_only, **kwargs)
        except:
            html = get_html(url)
            title = r1('title:"([^"]+)"', html)
            vhsrc = (re.findall('"BDE_Image"[^>]+src="([^"]+\\.mp4)"', html) or re.findall('vhsrc="([^"]+)"', html))
            if (len(vhsrc) > 0):
                ext = 'mp4'
                size = url_size(vhsrc[0])
                print_info(site_info, title, ext, size)
                if (not info_only):
                    download_urls(vhsrc, title, ext, size, output_dir=output_dir, merge=False)
            items = re.findall('//imgsrc.baidu.com/forum/w[^"]+/([^/"]+)', html)
            urls = [('http://imgsrc.baidu.com/forum/pic/item/' + i) for i in set(items)]
            kw = (r1('kw=([^&]+)', html) or r1("kw:'([^']+)'", html))
            tid = (r1('tid=(\\d+)', html) or r1("tid:'([^']+)'", html))
            album_url = ('http://tieba.baidu.com/photo/g/bw/picture/list?kw=%s&tid=%s&pe=%s' % (kw, tid, 1000))
            album_info = json.loads(get_content(album_url))
            for i in album_info['data']['pic_list']:
                urls.append((('http://imgsrc.baidu.com/forum/pic/item/' + i['pic_id']) + '.jpg'))
            ext = 'jpg'
            size = float('Inf')
            print_info(site_info, title, ext, size)
            if (not info_only):
                download_urls(urls, title, ext, size, output_dir=output_dir, merge=False)