def cloud_add_link_task(cookie, tokens, source_url, save_path, vcode='', vcode_input=''):
 url = ''.join([const.PAN_URL, 'rest/2.0/services/cloud_dl?channel=chunlei&clienttype=0&web=1', '&bdstoken=', tokens['bdstoken']])
 type_ = ''
 if source_url.startswith('ed2k'):
  type_ = '&type=3'
 if (not save_path.endswith('/')):
  save_path = (save_path + '/')
 data = ['method=add_task&app_id=250528', '&source_url=', encoder.encode_uri_component(source_url), '&save_path=', encoder.encode_uri_component(save_path), '&type=', type_]
 if vcode:
  data.append('&input=')
  data.append(vcode_input)
  data.append('&vcode=')
  data.append(vcode)
 data = ''.join(data)
 req = net.urlopen(url, headers={'Cookie': cookie.header_output()}, data=data.encode())
 if req:
  content = req.data
  return json.loads(content.decode())
 else:
  return None

def cloud_add_link_task ( cookie , tokens , source_url , save_path , vcode = '' , vcode_input = '' ) : url = '' . join ( [ const . PAN_URL , 'rest/2.0/services/cloud_dl?channel=chunlei&clienttype=0&web=1' , '&bdstoken=' , tokens [ 'bdstoken' ] ] ) type_ = '' if source_url . startswith ( 'ed2k' ) : type_ = '&type=3' if ( not save_path . endswith ( '/' ) ) : save_path = ( save_path + '/' ) data = [ 'method=add_task&app_id=250528' , '&source_url=' , encoder . encode_uri_component ( source_url ) , '&save_path=' , encoder . encode_uri_component ( save_path ) , '&type=' , type_ ] if vcode : data . append ( '&input=' ) data . append ( vcode_input ) data . append ( '&vcode=' ) data . append ( vcode ) data = '' . join ( data ) req = net . urlopen ( url , headers = { 'Cookie' : cookie . header_output ( ) } , data = data . encode ( ) ) if req : content = req . data return json . loads ( content . decode ( ) ) else : return None
source_url - 可以是http/https/ftp等一般的链接 可以是emule这样的链接 path - 要保存到哪个目录 .