Skip to content

Commit

Permalink
Add Weibo Miaopai support
Browse files Browse the repository at this point in the history
  • Loading branch information
cnbeining committed Aug 23, 2015
1 parent 86b5509 commit 01a137b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -61,6 +61,7 @@ Fork me on GitHub: <https://github.com/soimort/you-get>
* QianMo (阡陌视频) <http://qianmo.com/>
* QQ (腾讯视频) <http://v.qq.com>
* Sina (新浪视频) <http://video.sina.com.cn>
* Weibo Miaopai (新浪微博秒拍视频) <http://video.weibo.com/>
* Sohu (搜狐视频) <http://tv.sohu.com>
* SongTaste <http://www.songtaste.com>
* SoundCloud <http://soundcloud.com>
Expand Down
3 changes: 2 additions & 1 deletion src/you_get/common.py
Expand Up @@ -922,7 +922,7 @@ def script_main(script_name, download, download_playlist = None):
sys.exit(1)

def url_to_module(url):
from .extractors import netease, w56, acfun, baidu, baomihua, bilibili, blip, catfun, cntv, cbs, coursera, dailymotion, dongting, douban, douyutv, ehow, facebook, freesound, google, sina, ifeng, alive, instagram, iqiyi, joy, jpopsuki, khan, ku6, kugou, kuwo, letv, lizhi, magisto, miomio, mixcloud, mtv81, nicovideo, pptv, qianmo, qq, sohu, songtaste, soundcloud, ted, theplatform, tudou, tucao, tumblr, twitter, vid48, videobam, vidto, vimeo, vine, vk, xiami, yinyuetai, youku, youtube, zhanqi
from .extractors import netease, w56, acfun, baidu, baomihua, bilibili, blip, catfun, cntv, cbs, coursera, dailymotion, dongting, douban, douyutv, ehow, facebook, freesound, google, sina, ifeng, alive, instagram, iqiyi, joy, jpopsuki, khan, ku6, kugou, kuwo, letv, lizhi, magisto, miaopai, miomio, mixcloud, mtv81, nicovideo, pptv, qianmo, qq, sohu, songtaste, soundcloud, ted, theplatform, tudou, tucao, tumblr, twitter, vid48, videobam, vidto, vimeo, vine, vk, xiami, yinyuetai, youku, youtube, zhanqi

video_host = r1(r'https?://([^/]+)/', url)
video_url = r1(r'https?://[^/]+(.*)', url)
Expand Down Expand Up @@ -991,6 +991,7 @@ def url_to_module(url):
'videobam': videobam,
'vidto': vidto,
'vimeo': vimeo,
'weibo': miaopai,
'vine': vine,
'vk': vk,
'xiami': xiami,
Expand Down
1 change: 1 addition & 0 deletions src/you_get/extractors/__init__.py
Expand Up @@ -27,6 +27,7 @@
from .letv import *
from .lizhi import *
from .magisto import *
from .miaopai import *
from .miomio import *
from .mixcloud import *
from .mtv81 import *
Expand Down
36 changes: 36 additions & 0 deletions src/you_get/extractors/miaopai.py
@@ -0,0 +1,36 @@
#!/usr/bin/env python

__all__ = ['miaopai_download']

from ..common import *
import urllib.error

def miaopai_download(url, output_dir = '.', merge = False, info_only = False):
'''Source: Android mobile'''
if re.match(r'http://video.weibo.com/show\?fid=(\d{4}:\w{32})\w*', url):
fake_headers_mobile = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'UTF-8,*;q=0.5',
'Accept-Encoding': 'gzip,deflate,sdch',
'Accept-Language': 'en-US,en;q=0.8',
'User-Agent': 'Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36'
}
webpage_url = re.search(r'(http://video.weibo.com/show\?fid=\d{4}:\w{32})\w*', url).group(1) + '&type=mp4' #mobile

#grab download URL
a = get_content(webpage_url, headers= fake_headers_mobile , decoded=True)
url = match1(a, r'<video src="(.*?)\"\W')

#grab title
b = get_content(webpage_url) #normal
title = match1(b, r'<meta name="description" content="(.*?)\"\W')

type_, ext, size = url_info(url)
print_info(site_info, title, type_, size)
if not info_only:
download_urls([url], title, ext, total_size=None, output_dir=output_dir, merge=merge)


site_info = "miaopai"
download = miaopai_download
download_playlist = playlist_not_supported('miaopai')

0 comments on commit 01a137b

Please sign in to comment.