mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
[baomihua] fix download 403
This commit is contained in:
parent
8b7566eeb3
commit
7a43ac0782
@ -6,6 +6,16 @@ from ..common import *
|
||||
|
||||
import urllib
|
||||
|
||||
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
|
||||
|
||||
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)
|
||||
host = r1(r'host=([^&]*)', html)
|
||||
@ -16,10 +26,10 @@ def baomihua_download_by_id(id, title=None, output_dir='.', merge=True, info_onl
|
||||
assert vid
|
||||
dir_str = r1(r'&dir=([^&]*)', html).strip()
|
||||
url = "http://%s/%s/%s.%s" % (host, dir_str, vid, type)
|
||||
_, ext, size = url_info(url)
|
||||
_, ext, size = url_info(url, headers=baomihua_headers())
|
||||
print_info(site_info, title, type, size)
|
||||
if not info_only:
|
||||
download_urls([url], title, ext, size, output_dir, merge = merge)
|
||||
download_urls([url], title, ext, size, output_dir, merge = merge, headers=baomihua_headers())
|
||||
|
||||
def baomihua_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
|
||||
html = get_html(url)
|
||||
|
Loading…
Reference in New Issue
Block a user