mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 05:25:02 +03:00
add support for ifeng
This commit is contained in:
parent
0f94b999f6
commit
2ef99eae96
@ -3,6 +3,7 @@
|
||||
from .acfun import *
|
||||
from .bilibili import *
|
||||
from .cntv import *
|
||||
from .ifeng import *
|
||||
from .iqiyi import *
|
||||
from .ku6 import *
|
||||
from .pptv import *
|
||||
|
36
you_get/downloader/ifeng.py
Normal file
36
you_get/downloader/ifeng.py
Normal file
@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
__all__ = ['ifeng_download', 'ifeng_download_by_id']
|
||||
|
||||
from ..common import *
|
||||
|
||||
def ifeng_download_by_id(id, title = None, output_dir = '.', merge = True, info_only = False):
|
||||
assert r1(r'([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})', id), id
|
||||
url = 'http://v.ifeng.com/video_info_new/%s/%s/%s.xml' % (id[-2], id[-2:], id)
|
||||
xml = get_html(url, 'utf-8')
|
||||
title = r1(r'Name="([^"]+)"', xml)
|
||||
title = unescape_html(title)
|
||||
url = r1(r'VideoPlayUrl="([^"]+)"', xml)
|
||||
from random import randint
|
||||
r = randint(10, 19)
|
||||
url = url.replace('http://video.ifeng.com/', 'http://video%s.ifeng.com/' % r)
|
||||
assert url.endswith('.mp4')
|
||||
type, ext, size = url_info(url)
|
||||
|
||||
print_info(site_info, title, 'mp4', size)
|
||||
if not info_only:
|
||||
download_urls([url], title, 'mp4', size, output_dir, merge = merge)
|
||||
|
||||
def ifeng_download(url, output_dir = '.', merge = True, info_only = False):
|
||||
id = r1(r'/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.shtml$', url)
|
||||
if id:
|
||||
return ifeng_download_by_id(id, None, output_dir = output_dir, merge = merge, info_only = info_only)
|
||||
|
||||
html = get_html(url)
|
||||
id = r1(r'var vid="([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})"', html)
|
||||
assert id, "can't find video info"
|
||||
return ifeng_download_by_id(id, None, output_dir = output_dir, merge = merge, info_only = info_only)
|
||||
|
||||
site_info = "ifeng.com"
|
||||
download = ifeng_download
|
||||
download_playlist = playlist_not_supported('ifeng')
|
@ -23,6 +23,7 @@ def url_to_module(url):
|
||||
'bilibili': bilibili,
|
||||
'cntv': cntv,
|
||||
'iask': sina,
|
||||
'ifeng': ifeng,
|
||||
'iqiyi': iqiyi,
|
||||
'kankanews': bilibili,
|
||||
'ku6': ku6,
|
||||
|
Loading…
Reference in New Issue
Block a user