doc: http://open.youku.com/docs/doc?id=85
6638
def search_show_address_unite(self, progammeId,
                                  source_site=None, type=None):
        
        url = 'https://openapi.youku.com/v2/searches/show/address_unite.json'
        params = {
            'client_id': self.client_id,
            'progammeId': progammeId,
            'source_site': source_site,
            'type': type
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
1289064
protected static String uploadMedia(String url, File file, String params) throws IOException {
		URL urlGet = new URL(url);
		HttpURLConnection conn = (HttpURLConnection) urlGet.openConnection();
		conn.setDoOutput(true);
		conn.setDoInput(true);
		conn.setUseCaches(false);
		conn.setRequestMethod("POST");
		conn.setRequestProperty("connection", "Keep-Alive");
		conn.setRequestProperty("user-agent", DEFAULT_USER_AGENT);
		conn.setRequestProperty("Charsert", "UTF-8");
		// 定义数据分隔线
		String BOUNDARY = "----WebKitFormBoundaryiDGnV9zdZA1eM1yL";
		conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);

		OutputStream out = new DataOutputStream(conn.getOutputStream());
		// 定义最后数据分隔线
		StringBuilder mediaData = new StringBuilder();
		mediaData.append("--").append(BOUNDARY).append("\r\n");
		mediaData.append("Content-Disposition: form-data;name=\"media\";filename=\"" + file.getName() + "\"\r\n");
		mediaData.append("Content-Type:application/octet-stream\r\n\r\n");
		byte[] mediaDatas = mediaData.toString().getBytes();
		out.write(mediaDatas);
		DataInputStream fs = new DataInputStream(new FileInputStream(file));
		int bytes = 0;
		byte[] bufferOut = new byte[1024];
		while ((bytes = fs.read(bufferOut)) != -1) {
			out.write(bufferOut, 0, bytes);
		}
		IOUtils.closeQuietly(fs);
		// 多个文件时，二个文件之间加入这个
		out.write("\r\n".getBytes());
		if (StrKit.notBlank(params)) {
			StringBuilder paramData = new StringBuilder();
			paramData.append("--").append(BOUNDARY).append("\r\n");
			paramData.append("Content-Disposition: form-data;name=\"description\";");
			byte[] paramDatas = paramData.toString().getBytes();
			out.write(paramDatas);
			out.write(params.getBytes(Charsets.UTF_8));
		}
		byte[] end_data = ("\r\n--" + BOUNDARY + "--\r\n").getBytes();
		out.write(end_data);
		out.flush();
		IOUtils.closeQuietly(out);

		// 定义BufferedReader输入流来读取URL的响应
		InputStream in = conn.getInputStream();
		BufferedReader read = new BufferedReader(new InputStreamReader(in, Charsets.UTF_8));
		String valueString = null;
		StringBuffer bufferRes = null;
		bufferRes = new StringBuffer();
		while ((valueString = read.readLine()) != null) {
			bufferRes.append(valueString);
		}
		IOUtils.closeQuietly(in);
		// 关闭连接
		if (conn != null) {
			conn.disconnect();
		}
		return bufferRes.toString();
	}
411853
function showStreams() {
	//http://ibl.api.bbci.co.uk/ibl/v1/channels?lang=en&api_key=APIKEY
	var query = nitro.newQuery();
	query.add(ibl.commonLangEn);
	nitro.make_request(ibl.host,ibl.getChannels,ibl_key,query,{},function(obj){
		console.log(JSON.stringify(obj,null,2));
		for (var i in obj.channels) {
			var ch = obj.channels[i];
			console.log('['+ch.title+'](http://a.files.bbci.co.uk/media/live/manifesto/audio_video/simulcast/hls/uk/hls_tablet_rw/llnw/'+ch.master_brand_id+'.m3u8)');
		}
		return false;
	});
}
966345
def find_show_by_id(self, show_id):
        
        url = 'https://openapi.youku.com/v2/shows/show.json'
        params = {
            'client_id': self.client_id,
            'show_id': show_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
126814
def playlist_category(self):
        
        url = 'https://openapi.youku.com/v2/schemas/playlist/category.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
1138539
function () {
    scan_mode = false;
    log.i('Now start qiniu watch.'.yellow);
    var watcher = chokidar.watch(local_dir, {ignored: /[\/\\]\./, persistent: true});
   
    watcher.on('add', function(file, event) {
        
        var name = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name);
    });
   
    watcher.on('change', function(file, event) {
        
        var name2 = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name2);
    });
}
243420
def find_videos_by_playlist(self, playlist_id, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/playlists/videos.json'
        params = {
            'client_id': self.client_id,
            'playlist_id': playlist_id,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
442301
def create_comment(self, access_token, video_id, content,
                       reply_id=None, captcha_key=None, captcha_text=None):
        
        url = 'https://openapi.youku.com/v2/comments/create.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'video_id': video_id,
            'content': content,
            'reply_id': reply_id,
            'captcha_key': captcha_key,
            'captcha_text': captcha_text
        }
        data = remove_none_value(data)
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
862890
def my_info(self, access_token):
        
        url = 'https://openapi.youku.com/v2/users/myinfo.json'
        data = {'client_id': self.client_id,
                'access_token': access_token}
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()
957547
def stream_url(self):
    ''''''
    path = '/Audio/{}/universal'.format(self.id)
    return self.connector.get_url(path,
              userId=self.connector.userid,
              MaxStreamingBitrate=140000000,
              Container='opus',
              TranscodingContainer='opus',
              AudioCodec='opus',
              MaxSampleRate=48000,
              PlaySessionId=1496213367201 #TODO no hard code
    )
143710
def show_category(self):
        
        url = 'https://openapi.youku.com/v2/schemas/show/category.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
1188322
def get_position_link_to(str = nil, options = {})
      if str.is_a?(Hash)
        options = str
        str = nil
      end
      show_all = nil
      if options.is_a?(Hash)
        options = options.symbolize_keys
        show_all = options.delete(:show_all)
      end

      # TODO: コード汚い
      s = []
      if show_all || request.mobile.instance_of?(Mobile::Docomo)
        s << docomo_foma_gps_link_to(str || 'DoCoMo FOMA(GPS)', options)
      end
      if show_all || request.mobile.instance_of?(Mobile::Au)
        if show_all || request.mobile.supports_gps?
          s << au_gps_link_to(str || 'au(GPS)', options)
        end
        if show_all || (!request.mobile.supports_gps? && request.mobile.supports_location?)
          s << au_location_link_to(str || 'au(antenna)', options)
        end
      end
      if show_all || request.mobile.instance_of?(Mobile::Vodafone) || request.mobile.instance_of?(Mobile::Softbank)
        s << softbank_location_link_to(str || 'Softbank 3G(GPS)', options)
      end
      if show_all || request.mobile.instance_of?(Mobile::Willcom)
        s << willcom_location_link_to(str || 'Willcom', options)
      end
      s.join("<br>\n").html_safe
    end
250919
def subscribe_notice(self, access_token):
        
        url = 'https://openapi.youku.com/v2/users/subscribe/notice.json'
        params = {
            'client_id': self.client_id,
            'access_token': access_token
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
1085439
function getYoutubeID(url) {
    let videoID = '';
    url = url.replace(/(>|<)/gi, '').split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
    if (url[2] !== undefined) {
        videoID = url[2].split(/[^0-9a-z_\-]/i);
        videoID = videoID[0];
    } else {
        videoID = url;
    }
    return videoID;
}
826790
def find_playlist_by_id(self, playlist_id):
        
        url = 'https://openapi.youku.com/v2/playlists/show.json'
        params = {
            'client_id': self.client_id,
            'playlist_id': playlist_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
187122
def find_persons_by_type(self, type, nationality=None, gender=None,
                             firstletter=None, orderby='view-week-count',
                             page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/persons/by_type.json'
        params = {
            'client_id': self.client_id,
            'type': type,
            'nationality': nationality,
            'gender': gender,
            'firstletter': firstletter,
            'orderby': orderby,
            'page': page,
            'count': count
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
181844
function pGetUrl(url, headers){
    //console.log(`\r\n发起远程请求(${Date()})：${url}\r\n`);
    if(!headers){
        headers = {};
    }
    headers['User-Agent'] = 'Request-Promise';
    return rp({
        uri: url,
        headers: headers,
        json: true // Automatically parses the JSON string in the response
    });
}