doc: http://open.youku.com/docs/docs?id=89
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()
86214
def find_video_by_url(self, video_url):
        
        url = 'https://openapi.youku.com/v2/videos/show_basic.json'
        params = {
            'client_id': self.client_id,
            'video_url': video_url
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
715516
def find_comments_by_video(self, video_id, page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/comments/by_video.json'
        params = {
            'client_id': self.client_id,
            'video_id': video_id,
            'page': page,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
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()
1214794
def set_cover_video_for_playlist(self, access_token, playlist_id,
                                     video_id):
        
        url = 'https://openapi.youku.com/v2/playlists/video/setcover.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'playlist_id': playlist_id,
            'video_id': video_id
        }
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
867706
def authorize_url(self, state=''):
        
        url = 'https://openapi.youku.com/v2/oauth2/authorize?'
        params = {
            'client_id': self.client_id,
            'response_type': 'code',
            'state': state,
            'redirect_uri': self.redirect_uri
        }
        return url + urlencode(params)
1209154
function f_getIhale(_ihale) {
        console.log("---------- F_GET_IHALE -------------");
        var defer = db.redis.dbQ.Q.defer(),
            sayfa = '';

        options.method = 'GET';
        options.path = _ihale.yonlendirilenAdres || _ihale.adres.replace('www.', '');
        delete options.headers['Content-Length'];
        delete options.headers['Content-Type'];

        http.request(options, function (res) {
                console.log('STATUS: ' + res.statusCode);
                console.log('HEADERS: ' + JSON.stringify(res.headers));

                res.on('error', function () {
                        var error = "f_getIhale sırasında, Response Error: " + JSON.stringify(arguments);
                        console.log(error);
                        defer.reject(error);
                    })
                    .on('data', function (chunk) {
                        sayfa += f_encodeTurkish(chunk);
                    });

                if (res.statusCode == 302) {
                    console.log("-------------- LOCATION -----------\n" + res.headers.location);
                    _ihale.yonlendirilenAdres = 'http://saglikbank.com/' + res.headers.location;
                    options.headers.Referer = options.path;
                    console.log(_ihale.yonlendirilenAdres);
                    res.on('end', function () {
                        sayfa = '';
                        f_getIhale(_ihale)
                            .then(function (_ihale) {
                                console.log("ikinci kez getIhale");
                                defer.resolve(_ihale);
                            })
                            .fail(function () {
                                var error = "f_getIhale sırasında Error: " + JSON.stringify(arguments);
                                console.log(error);
                                defer.reject(error);
                            });
                    });
                } else {
                    res.on('end', function () {
                        $sayfa = $(sayfa);

                        var ihaleUsul = $sayfa.find("#UsulLBL").text().trim();
                        var ihaleNo = $sayfa.find("#KayitNoLBL").text().trim();
                        var ihaleKonusu = $sayfa.find("#IhaleKonusuLBL").text().trim();

                        var kurumAdi = $sayfa.find("#ctl00_KurumAdi2LBL").text().trim();
                        var ihaleTarihi = $sayfa.find("#ctl00_IhaleTarihi2LBL").text().trim();
                        var tarih1 = moment(ihaleTarihi, "DD.MM.YYYY");

                        var kurumTelNo = $sayfa.find("#ctl00_KurumTelefonNoLBL").text().trim();
                        var sistemeEklenmeTarihi = $sayfa.find("#ctl00_EklemeTarihiLBL").text();
                        var tarih2 = moment(sistemeEklenmeTarihi, "DD.MM.YYYY hh:mm");

                        var kurumFaksNo = $sayfa.find("#ctl00_KurumFaksNoLBL").text().trim();
                        var kurumEmail = $sayfa.find("#ctl00_KurumEmailTB").find("a").text().trim();
                        var kurumAdres = $sayfa.find("#ctl00_KurumAdresiLBL").text().trim();
                        var sartnameAdres = $sayfa.find("#ctl00_SartnameListesiLBL").find("a").text().trim();
//TODO: Sadece bir şartname varsa tamam ama zeyilname ya da birden fazla dosya için kontrol edilecek

                        var yeni_ihale = {
                            "Kurum": {
                                "Adi": kurumAdi,
                                "Id": 0,
                                "Tel": kurumTelNo,
                                "Eposta": kurumEmail == "[email protected]" ? "" : kurumEmail,
                                "Faks": kurumFaksNo,
                                "AcikAdres": kurumAdres
                            },
                            "IhaleNo": ihaleNo.replace('(', '').replace(')', ''),
                            "Konusu": ihaleKonusu,
                            "IhaleTarihi": new Date(tarih1).getTime(),
                            "IhaleUsul": ihaleUsul,
                            "YapilacagiAdres": "",
                            "SartnameAdres": sartnameAdres,
                            "SistemeEklenmeTarihi": new Date(tarih2).getTime()
                        };

                        var tbl = $sayfa.find(".listeTablosu").parents("table").first().find("tr").map(function () {
                            if ($(this).attr("style")) {
                                return {
                                    "SiraNo": $(this).find("td").first().find("strong").text().trim(),
                                    "MalzemeCinsi": $(this).find("td:nth-child(1)").text().replace('\n', '').replace('\r', '').trim(),
                                    "Miktar": $(this).find("td:nth-child(2)").text().trim(),
                                    "Birim": $(this).find("td:nth-child(3)").text().trim(),
                                    "Aciklama": $(this).find('td:nth-child(4)').text().replace('\n', '').replace('\r', '').trim()
                                }
                            }
                        }).toArray();
                        yeni_ihale.Kalemler = tbl;

                        _ihale = _.extend(_ihale, yeni_ihale);
                        console.log("oluşan ihale:" + JSON.stringify(_ihale));
                        defer.resolve(_ihale);
                    });
                }
            })
            .on('error', function (e) {
                var error = 'Problem with request: ' + e.message;
                console.log(error);
                defer.reject(error);
            })
            .on('end', function (e) {
            })
            .end();
        return defer.promise;
    }
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()
779163
def getURL(self, CorpNum, UserID, ToGo):
        
        if ToGo == None or ToGo == '':
            raise PopbillException(-99999999, "TOGO값이 입력되지 않았습니다.")

        result = self._httpget('/Message/?TG=' + ToGo, CorpNum, UserID)

        return result.url
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()
126575
def find_video_detail_by_id(self, video_id, ext=None):
        
        url = 'https://api.youku.com/videos/show.json'
        params = {
            'client_id': self.client_id,
            'video_id': video_id
        }
        if ext:
            params['ext'] = ext
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
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()
441965
function getYTVideoID(url) {
      var regexp = /(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i;
      var match = url.match(regexp);
      return match && match.length === 2 ? match[1] : false;
    }
393475
function(){
		// this.bodyが空の場合はEncode.jsの仕様により対象外
		// カンペンには以下のパズルは存在しないのでURL_KANPENPも対象外
		if(!this.body || (this.type!==URL_PZPRV3 && this.type!==URL_PZPRAPP)){ return;}
		
		switch(this.pid){
		case 'ichimaga':
			if     (this.pflag.indexOf('m')>=0){ this.pid = 'ichimagam';}
			else if(this.pflag.indexOf('x')>=0){ this.pid = 'ichimagax';}
			else                               { this.pid = 'ichimaga'; }
			break;
		case 'icelom':
			if(this.pflag.indexOf('a')<0){ this.pid = 'icelom2';}
			break;
		case 'pipelink':
			if(this.body.match(/[0-9]/)){ this.pid = 'pipelinkr';}
			break;
		case 'bonsan':
			if(this.pflag.indexOf('c')<0){
				var col = this.cols, row = this.rows;
				if(this.body.substr(0,((((col-1)*row+4)/5)|0)+(((col*(row-1)+4)/5)|0)||0).match(/[^0]/)){
					this.pid = 'heyabon';
				}
			}
			break;
		case 'kramma':
			if(this.pflag.indexOf('c')<0){
				var len=(this.cols-1)*(this.rows-1), cc=0;
				for(var i=0;i<this.body.length;i++){
					var ca = this.body.charAt(i);
					if(ca.match(/\w/)){
						cc += parseInt(ca,36);
						if(cc<len){ this.pid = 'kramman'; break;}
					}
					else if(ca === '.'){ cc+=36;}
					if(cc>=len){ break;}
				}
			}
			break;
		}
	}
1317579
public function updateNews($news_media_id) {
		$newsMedia = WechatNewsMedia::findOne($news_media_id);
		if(!$newsMedia) {
			throw new ErrorException('数据查询失败');
		}

		if($newsMedia->news->count_item == count($newsMedia->thumbMaterialMediaIdList)) {
			$articles = $media->news->getArticles($this);
			$thumb_material_media_ids = [];
			$success = true;
			foreach($articles as $index => $article) {
				$thumb_material_media_ids[] = $article['thumb_material_media_id'];
				$data = $this->getData('/cgi-bin/material/update_news', [
					'access_token' => $this->getAccessToken(),
				], Json::encode([
					'media_id' => $media->media_id,
					'index' => $index,
					'articles' => $article,
				]));
				if($this->errcode != 0) {
					$success = false;
					break;
				}
			}
			if($success) {
				$media->thumb_material_media_ids = Json::encode($thumb_material_media_ids);
				if($details = $this->getNews($media->media_id)) {
					$media->urls = Json::encode(ArrayHelper::getColumn($details['news_item'], 'url'));
					$media->thumb_urls = Json::encode(ArrayHelper::getColumn($details['news_item'], 'thumb_url'));
				}
				if($media->save()) {
					return $media->id;
				}
			}
		} else {
			$newsid = $media->newsid;
			if($this->deleteNews($media->id)) {
				return $this->addNews($newsid);
			}
		}

		return 0;
	}
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);
  }
559427
def find_shows_by_category(self, category, genre=None, area=None,
                               release_year=None, paid=None,
                               orderby='view-today-count',
                               streamtypes=None, person=None,
                               page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/shows/by_category.json'
        params = {
            'client_id': self.client_id,
            'category': category,
            'genre': genre,
            'area': area,
            'release_year': release_year,
            'paid': paid,
            'orderby': orderby,
            'streamtypes': streamtypes,
            'person': person,
            'page': page,
            'count': count
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()