[funshion] fix (partly) #1304 and close #1378

This commit is contained in:
Mort Yao 2016-08-30 12:42:50 +02:00
parent 5e612e870c
commit 44c09c542f
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -10,9 +10,9 @@ import json
def funshion_download(url, output_dir = '.', merge = False, info_only = False, **kwargs):
""""""
if re.match(r'http://www.fun.tv/vplay/v-(\w+)', url): #single video
funshion_download_by_url(url, output_dir = '.', merge = False, info_only = False)
elif re.match(r'http://www.fun.tv/vplay/g-(\w+)', url): #whole drama
funshion_download_by_drama_url(url, output_dir = '.', merge = False, info_only = False)
funshion_download_by_url(url, output_dir=output_dir, merge=merge, info_only=info_only)
elif re.match(r'http://www.fun.tv/vplay/.*g-(\w+)', url): #whole drama
funshion_download_by_drama_url(url, output_dir=output_dir, merge=merge, info_only=info_only)
else:
return
@ -25,7 +25,7 @@ def funshion_download_by_url(url, output_dir = '.', merge = False, info_only = F
if re.match(r'http://www.fun.tv/vplay/v-(\w+)', url):
match = re.search(r'http://www.fun.tv/vplay/v-(\d+)(.?)', url)
vid = match.group(1)
funshion_download_by_vid(vid, output_dir = '.', merge = False, info_only = False)
funshion_download_by_vid(vid, output_dir=output_dir, merge=merge, info_only=info_only)
#----------------------------------------------------------------------
def funshion_download_by_vid(vid, output_dir = '.', merge = False, info_only = False):
@ -34,11 +34,11 @@ def funshion_download_by_vid(vid, output_dir = '.', merge = False, info_only = F
"""
title = funshion_get_title_by_vid(vid)
url_list = funshion_vid_to_urls(vid)
for url in url_list:
type, ext, size = url_info(url)
print_info(site_info, title, type, size)
if not info_only:
download_urls(url_list, title, ext, total_size=None, output_dir=output_dir, merge=merge)
@ -63,14 +63,11 @@ def funshion_download_by_drama_url(url, output_dir = '.', merge = False, info_on
"""str->None
url = 'http://www.fun.tv/vplay/g-95785/'
"""
if re.match(r'http://www.fun.tv/vplay/g-(\w+)', url):
match = re.search(r'http://www.fun.tv/vplay/g-(\d+)(.?)', url)
id = match.group(1)
id = r1(r'http://www.fun.tv/vplay/.*g-(\d+)', url)
video_list = funshion_drama_id_to_vid(id)
for video in video_list:
funshion_download_by_id((video[0], id), output_dir = '.', merge = False, info_only = False)
funshion_download_by_id((video[0], id), output_dir=output_dir, merge=merge, info_only=info_only)
# id is for drama, vid not the same as the ones used in single video
#----------------------------------------------------------------------
@ -81,11 +78,11 @@ def funshion_download_by_id(vid_id_tuple, output_dir = '.', merge = False, info_
(vid, id) = vid_id_tuple
title = funshion_get_title_by_id(vid, id)
url_list = funshion_id_to_urls(vid)
for url in url_list:
type, ext, size = url_info(url)
print_info(site_info, title, type, size)
if not info_only:
download_urls(url_list, title, ext, total_size=None, output_dir=output_dir, merge=merge)
@ -95,7 +92,7 @@ def funshion_drama_id_to_vid(episode_id):
id: 95785
->[('626464', '1'), ('626466', '2'), ('626468', '3'),...
Drama ID to vids used in drama.
**THIS VID IS NOT THE SAME WITH THE ONES USED IN SINGLE VIDEO!!**
"""
html = get_content('http://pm.funshion.com/v5/media/episode?id={episode_id}&cl=aphone&uc=5'.format(episode_id = episode_id))
@ -118,7 +115,7 @@ def funshion_get_title_by_id(single_episode_id, drama_id):
Get title for single drama video."""
html = get_content('http://pm.funshion.com/v5/media/episode?id={id}&cl=aphone&uc=5'.format(id = drama_id))
c = json.loads(html)
for i in c['episodes']:
if i['id'] == str(single_episode_id):
return c['name'] + ' - ' + i['name']
@ -127,11 +124,11 @@ def funshion_get_title_by_id(single_episode_id, drama_id):
#----------------------------------------------------------------------
def select_url_from_video_api(html):
"""str(html)->str(url)
Choose the best one.
Used in both single and drama download.
code definition:
{'tv': 'liuchang',
'dvd': 'biaoqing',