doc: http://open.youku.com/docs/doc?id=63
188232
def find_shows_by_related(self, show_id,
                              count=20):
        
        url = 'https://openapi.youku.com/v2/shows/by_related.json'
        params = {
            'client_id': self.client_id,
            'show_id': show_id,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
194402
def find_next_video_in_playlist(self, playlist_id, cur_video_id):
        
        url = 'https://openapi.youku.com/v2/playlists/video/next.json'
        params = {
            'client_id': self.client_id,
            'playlist_id': playlist_id,
            'video_id': cur_video_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
524779
def search_videos_by_keyword(self, keyword, category=None,
                                 period='week', orderby='relevance',
                                 public_type='all', paid=None,
                                 timeless=None, timemore=None,
                                 streamtypes=None,
                                 page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/searches/video/by_keyword.json'
        params = {
            'client_id': self.client_id,
            'keyword': keyword,
            'category': category,
            'period': period,
            'orderby': orderby,
            'public_type': public_type,
            'paid': paid,
            'timeless': timeless,
            'timemore': timemore,
            'streamtypes': streamtypes,
            'page': page,
            'count': count
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
958833
function jsonRet(req,res) {
    var state = 200;
    var data = {
        code:state,
        message:""
    };

    //错误判断（404）
    if(!req.input) {
        state = 404;
        req.app.yolog.log('error','error 404');
    } else if(req.input.error) {
        state = 500;
        data.message = req.input.message ? req.input.message:'';
        req.app.yolog.log('error','error 500',req.input);
    } else {
        data.data = res.proxyData;
    } 
    req.app.yolog.log('verbose','pjax vo: %j',data,{});
    data.code = state;
    res.status(state).json(data);
}
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()
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;
	});
}
776068
def update_video(self, access_token, video_id, title=None,
                     tags=None, category=None, copyright_type=None,
                     public_type=None, watch_password=None,
                     description=None, thumbnail_seq=None):
        
        url = 'https://openapi.youku.com/v2/videos/update.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'video_id': video_id,
            'title': title,
            'tags': tags,
            'category': category,
            'copyright_type': copyright_type,
            'public_type': public_type,
            'watch_password': watch_password,
            'description': description,
            'thumbnail_seq': thumbnail_seq
        }
        data = remove_none_value(data)
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
458541
def find_favorite_videos_by_userid(self, user_id,
                                       orderby='favorite-time',
                                       page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/videos/favorite/by_user.json'
        params = {
            'client_id': self.client_id,
            'user_id': user_id,
            'orderby': orderby,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
267569
def comment_expression(self):
        
        url = 'https://openapi.youku.com/v2/schemas/comment/expression.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
536068
def upload_spec(self):
        
        url = 'https://openapi.youku.com/v2/schemas/upload/spec.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
438649
private function parseLink()
    {
        $value = $this->RAW();

        if (!$value) {
            return false;
        }

        $output = false;

        if (preg_match(
            '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/i',
            $value,
            $matches
        )) {
            foreach ($matches as $match) {
                if (preg_match('/^[0-9]{6,12}$/', $match)) {
                    $output = [
                        'VideoID'      => $match,
                        'VideoService' => 'Vimeo',
                    ];
                }
            }
        } elseif (preg_match('/https?:\/\/youtu\.be\/([a-z0-9\_\-]+)/i', $value, $matches)) {
            $output = [
                'VideoID'      => $matches[1],
                'VideoService' => 'YouTube',
            ];
        } elseif (preg_match('/youtu\.?be/i', $value)) {
            $query_string = [];
            parse_str(parse_url($value, PHP_URL_QUERY), $query_string);
            if (!empty($query_string['v'])) {
                $output = [
                    'VideoID'      => $query_string['v'],
                    'VideoService' => 'YouTube',
                ];
            }
        }

        return ($output) ? $output : false;
    }
711038
def add_videos_to_playlist(self, access_token, playlist_id, video_ids):
        
        url = 'https://openapi.youku.com/v2/playlists/video/add.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'playlist_id': playlist_id,
            'video_ids': video_ids
        }
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
698599
def friendship_followings(self, user_id=None, user_name=None,
                              page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/users/friendship/followings.json'
        data = {
            'client_id': self.client_id,
            'page': page,
            'count': count,
            'user_id': user_id,
            'user_name': user_name
        }
        data = remove_none_value(data)
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()
208458
def subscribe_get(self, access_token, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/users/subscribe/get.json'
        params = {
            'client_id': self.client_id,
            'access_token': access_token,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
696032
def url
      url = @path.sub(%r[^#{Regexp::quote(::Pupu.media_root)}], Regexp::quote(::Pupu.media_prefix))
      "/#{url}"
    end
1287078
public static function preprocess($url_parsed) {

        // different path for different domain
        if (strtolower($url_parsed['host'])=='player.youku.com') {
            $regex = '/^\/player\.php\/sid\/([a-zA-Z0-9]+)(\=\/v\.swf|\/v\.swf)$/';
        } elseif (strtolower($url_parsed['host'])=='v.youku.com') {
            $regex = '/^\/v_show\/id_(.+?)(\=|)\.html/';
        }

        // match sid from path
        if (preg_match($regex, $url_parsed['path'], $matches) == 1) {
            return array(
                'sid' => $matches[1],
            );
        }

        return FALSE;
    }
1048424
def update_playlist(self, access_token, playlist_id, title,
                        tags=None, category=None, description=None):
        
        url = 'https://openapi.youku.com/v2/playlists/update.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'playlist_id': playlist_id,
            'title': title,
            'tags': tags,
            'category': category,
            'description': description
        }
        data = remove_none_value(data)
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']