doc: http://open.youku.com/docs/doc?id=45
171682
def find_videos_by_ids(self, video_ids):
        
        url = 'https://openapi.youku.com/v2/videos/show_basic_batch.json'
        params = {
            'client_id': self.client_id,
            'video_ids': video_ids
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
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()
459248
def create_friendship(self, access_token,
                          user_id=None, user_name=None):
        
        url = 'https://openapi.youku.com/v2/users/friendship/create.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            '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()
673826
def find_show_premium_by_ids(self, show_ids, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/shows/show_premium.json'
        params = {
            'client_id': self.client_id,
            'show_ids': show_ids,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
1284196
def find_shows_by_ids(self, show_ids):
        
        url = 'https://openapi.youku.com/v2/shows/show_batch.json'
        params = {
            'client_id': self.client_id,
            'show_ids': show_ids
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
315934
def get_streaming(self, path, stype="M3U8_AUTO_480", **kwargs):
        

        params = {
            'path': path,
            'type': stype
        }
        url = 'https://{0}/rest/2.0/pcs/file'.format(BAIDUPCS_SERVER)
        while True:
            ret = self._request('file', 'streaming', url=url, extra_params=params, **kwargs)
            if not ret.ok:
                logging.debug('get_streaming ret_status_code %s' % ret.status_code)
                jdata = json.loads(ret.content)
                if jdata['error_code'] == 31345:
                    # 再试一次
                    continue
                elif jdata['error_code'] == 31066:
                    # 文件不存在
                    return 31066
                elif jdata['error_code'] == 31304:
                    # 文件类型不支持
                    return 31304
                elif jdata['error_code'] == 31023:
                    # params error
                    return 31023
            return ret.content
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;
    }
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()
152357
def searche_top_category(self):
        
        url = 'https://openapi.youku.com/v2/schemas/searche/top/category.json'
        r = requests.get(url)
        check_error(r)
        return r.json()
479828
def find_comments_by_me(self, access_token, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/comments/by_me.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'page': page,
            'count': count
        }
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()
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()
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()
252026
function(url, params, onsuccess, onfail) {
    // url中包含 get 参数和 params 合并
    if (_typeof(params) == 'object') params = _params_2_url(params);
    else params = '';

    if (params) url = url + '?' + params;
    return request('GET', url, '', onsuccess, onfail);
  }
57219
def find_person_by_id(self, person_id):
        
        url = 'https://openapi.youku.com/v2/persons/show.json'
        params = {
            'client_id': self.client_id,
            'person_id': person_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
594488
def refresh_token(self, refresh_token):
        ''''''
        url = 'https://api.youku.com/oauth2/token.json'
        data = {'client_id': self.client_id,
                'grant_type': 'refresh_token',
                'refresh_token': refresh_token}
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()
364831
def getURL(self, CorpNum, UserID, ToGo):
        
        if ToGo == None or ToGo == '':
            raise PopbillException(-99999999, "TOGO값이 입력되지 않았습니다.")

        if ToGo == 'SENDER':
            result = self._httpget('/Message/?TG=' + ToGo, CorpNum, UserID)
        else:
            result = self._httpget('/KakaoTalk/?TG=' + ToGo, CorpNum, UserID)
        return result.url
1237003
def find_favorite_videos_by_username(self, user_name,
                                         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_name': user_name,
            'orderby': orderby,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()