def get_download_link(cookie, tokens, path):
 metas = get_metas(cookie, tokens, path)
 if ((not metas) or (metas.get('errno', (-1)) != 0) or ('info' not in metas) or (len(metas['info']) != 1)):
  logger.error(('pcs.get_download_link(): %s' % metas))
  return None
 dlink = metas['info'][0]['dlink']
 url = '{0}&cflg={1}'.format(dlink, cookie.get('cflag').value)
 req = net.urlopen_without_redirect(url, headers={'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'cflag'), 'Accept': const.ACCEPT_HTML})
 if (not req):
  return url
 else:
  return req.getheader('Location', url)

def get_download_link ( cookie , tokens , path ) : metas = get_metas ( cookie , tokens , path ) if ( ( not metas ) or ( metas . get ( 'errno' , ( - 1 ) ) != 0 ) or ( 'info' not in metas ) or ( len ( metas [ 'info' ] ) != 1 ) ) : logger . error ( ( 'pcs.get_download_link(): %s' % metas ) ) return None dlink = metas [ 'info' ] [ 0 ] [ 'dlink' ] url = '{0}&cflg={1}' . format ( dlink , cookie . get ( 'cflag' ) . value ) req = net . urlopen_without_redirect ( url , headers = { 'Cookie' : cookie . sub_output ( 'BAIDUID' , 'BDUSS' , 'cflag' ) , 'Accept' : const . ACCEPT_HTML } ) if ( not req ) : return url else : return req . getheader ( 'Location' , url )
path - 一个文件的绝对路径 .