<s> __all__ = [ '<STR_LIT>' ] <EOL> from . . common import * <EOL> import urllib . error <EOL> import json <EOL> def funshion_download ( url , output_dir = '<STR_LIT:.>' , merge = False , info_only = False , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if re . match ( r'<STR_LIT>' , url ) : <EOL> funshion_download_by_url ( url , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) <EOL> elif re . match ( r'<STR_LIT>' , url ) : <EOL> funshion_download_by_drama_url ( url , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) <EOL> else : <EOL> return <EOL> def funshion_download_by_url ( url , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) : <EOL> """<STR_LIT>""" <EOL> if re . match ( r'<STR_LIT>' , url ) : <EOL> match = re . search ( r'<STR_LIT>' , url ) <EOL> vid = match . group ( <NUM_LIT:1> ) <EOL> funshion_download_by_vid ( vid , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) <EOL> def funshion_download_by_vid ( vid , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) : <EOL> """<STR_LIT>""" <EOL> title = funshion_get_title_by_vid ( vid ) <EOL> url_list = funshion_vid_to_urls ( vid ) <EOL> for url in url_list : <EOL> type , ext , size = url_info ( url ) <EOL> print_info ( site_info , title , type , size ) <EOL> if not info_only : <EOL> download_urls ( url_list , title , ext , total_size = None , output_dir = output_dir , merge = merge ) <EOL> def funshion_get_title_by_vid ( vid ) : <EOL> """<STR_LIT>""" <EOL> html = get_content ( '<STR_LIT>' . format ( vid = vid ) ) <EOL> c = json . loads ( html ) <EOL> return c [ '<STR_LIT:name>' ] <EOL> def funshion_vid_to_urls ( vid ) : <EOL> """<STR_LIT>""" <EOL> html = get_content ( '<STR_LIT>' . format ( vid = vid ) ) <EOL> return select_url_from_video_api ( html ) <EOL> def funshion_download_by_drama_url ( url , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) : <EOL> """<STR_LIT>""" <EOL> if re . match ( r'<STR_LIT>' , url ) : <EOL> match = re . search ( r'<STR_LIT>' , url ) <EOL> id = match . group ( <NUM_LIT:1> ) <EOL> video_list = funshion_drama_id_to_vid ( id ) <EOL> for video in video_list : <EOL> funshion_download_by_id ( ( video [ <NUM_LIT:0> ] , id ) , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) <EOL> def funshion_download_by_id ( vid_id_tuple , output_dir = '<STR_LIT:.>' , merge = False , info_only = False ) : <EOL> """<STR_LIT>""" <EOL> ( vid , id ) = vid_id_tuple <EOL> title = funshion_get_title_by_id ( vid , id ) <EOL> url_list = funshion_id_to_urls ( vid ) <EOL> for url in url_list : <EOL> type , ext , size = url_info ( url ) <EOL> print_info ( site_info , title , type , size ) <EOL> if not info_only : <EOL> download_urls ( url_list , title , ext , total_size = None , output_dir = output_dir , merge = merge ) <EOL> def funshion_drama_id_to_vid ( episode_id ) : <EOL> """<STR_LIT>""" <EOL> html = get_content ( '<STR_LIT>' . format ( episode_id = episode_id ) ) <EOL> c = json . loads ( html ) <EOL> return [ ( i [ '<STR_LIT:id>' ] , i [ '<STR_LIT>' ] ) for i in c [ '<STR_LIT>' ] ] <EOL> def funshion_id_to_urls ( id ) : <EOL> """<STR_LIT>""" <EOL> html = get_content ( '<STR_LIT>' . format ( id = id ) ) <EOL> return select_url_from_video_api ( html ) <EOL> def funshion_get_title_by_id ( single_episode_id , drama_id ) : <EOL> """<STR_LIT>""" <EOL> html = get_content ( '<STR_LIT>' . format ( id = drama_id ) ) <EOL> c = json . loads ( html ) <EOL> for i in c [ '<STR_LIT>' ] : <EOL> if i [ '<STR_LIT:id>' ] == str ( single_episode_id ) : <EOL> return c [ '<STR_LIT:name>' ] + '<STR_LIT>' + i [ '<STR_LIT:name>' ] <EOL> def select_url_from_video_api ( html ) : <EOL> """<STR_LIT>""" <EOL> c = json . loads ( html ) <EOL> video_dic = { } <EOL> for i in c [ '<STR_LIT>' ] : <EOL> video_dic [ i [ '<STR_LIT:code>' ] ] = i [ '<STR_LIT:http>' ] <EOL> quality_preference_list = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> url = [ video_dic [ quality ] for quality in quality_preference_list if quality in video_dic ] [ <NUM_LIT:0> ] <EOL> html = get_html ( url ) <EOL> c = json . loads ( html ) <EOL> return [ i [ '<STR_LIT>' ] [ <NUM_LIT:0> ] for i in c [ '<STR_LIT>' ] ] <EOL> site_info = "<STR_LIT>" <EOL> download = funshion_download <EOL> download_playlist = playlist_not_supported ( '<STR_LIT>' ) </s>
