you-get/src/you_get/extractors/baomihua.py

45 lines
1.7 KiB
Python
Raw Normal View History

2013-01-20 08:56:16 +04:00
#!/usr/bin/env python
__all__ = ['baomihua_download', 'baomihua_download_by_id']
from ..common import *
import urllib
2020-03-14 08:33:34 +03:00
def baomihua_headers(referer=None, cookie=None):
# a reasonable UA
ua = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36'
headers = {'Accept': '*/*', 'Accept-Language': 'en-US,en;q=0.5', 'User-Agent': ua}
if referer is not None:
headers.update({'Referer': referer})
if cookie is not None:
headers.update({'Cookie': cookie})
return headers
2015-10-18 04:07:02 +03:00
def baomihua_download_by_id(id, title=None, output_dir='.', merge=True, info_only=False, **kwargs):
html = get_html('http://play.baomihua.com/getvideourl.aspx?flvid=%s&devicetype=phone_app' % id)
2013-01-20 08:56:16 +04:00
host = r1(r'host=([^&]*)', html)
assert host
type = r1(r'videofiletype=([^&]*)', html)
assert type
2015-10-18 04:07:02 +03:00
vid = r1(r'&stream_name=([^&]*)', html)
2013-01-20 08:56:16 +04:00
assert vid
2017-08-04 16:42:15 +03:00
dir_str = r1(r'&dir=([^&]*)', html).strip()
url = "http://%s/%s/%s.%s" % (host, dir_str, vid, type)
2020-03-14 08:33:34 +03:00
_, ext, size = url_info(url, headers=baomihua_headers())
2013-01-20 08:56:16 +04:00
print_info(site_info, title, type, size)
if not info_only:
2020-03-14 08:33:34 +03:00
download_urls([url], title, ext, size, output_dir, merge = merge, headers=baomihua_headers())
2013-01-20 08:56:16 +04:00
2015-10-18 04:07:02 +03:00
def baomihua_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
2013-01-20 08:56:16 +04:00
html = get_html(url)
title = r1(r'<title>(.*)</title>', html)
assert title
2015-10-18 04:07:02 +03:00
id = r1(r'flvid\s*=\s*(\d+)', html)
2013-01-20 08:56:16 +04:00
assert id
2015-10-18 04:07:02 +03:00
baomihua_download_by_id(id, title, output_dir=output_dir, merge=merge, info_only=info_only)
2013-01-20 08:56:16 +04:00
site_info = "baomihua.com"
download = baomihua_download
download_playlist = playlist_not_supported('baomihua')