doc: http://open.youku.com/docs/docs?id=88
353170
def find_persons_by_ids(self, person_ids):
        
        url = 'https://openapi.youku.com/v2/persons/show_batch.json'
        params = {
            'client_id': self.client_id,
            'person_ids': person_ids
        }
        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;
}
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()
696032
def url
      url = @path.sub(%r[^#{Regexp::quote(::Pupu.media_root)}], Regexp::quote(::Pupu.media_prefix))
      "/#{url}"
    end
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;
	}
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()
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()
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()
415898
def closed(self, reason):
        '''
        
        '''
        # 拷贝封面&报头图片文件
        utils.mkdirp(os.path.join(self.build_source_dir, 'images'))
        self._logger.info(self.options)
        shutil.copy(
            self.options.get('img_cover'),
            os.path.join(self.build_source_dir, 'images', 'cover.jpg'))
        shutil.copy(
            self.options.get('img_masthead'),
            os.path.join(self.build_source_dir, 'images', 'masthead.gif'))

        # 拷贝css文件
        css_base_path = self.options.get('css_base')
        css_package_path = self.options.get('css_package')
        css_extra = self.options.get('extra_css', '')
        css_output_dir = os.path.join(self.build_source_dir, 'css')
        utils.mkdirp(css_output_dir)
        if css_base_path:
            shutil.copy(
                css_base_path,
                os.path.join(css_output_dir, 'base.css'))
        if css_package_path:
            shutil.copy(
                css_package_path,
                os.path.join(css_output_dir, 'package.css'))
        if css_extra:
            with codecs.open(
                    os.path.join(css_output_dir, 'custom.css'),
                    'wb', 'utf-8') as fh:
                fh.write(css_extra)

        # 拷贝icons路径文件
        icons_path = self.options.get('icons_path')
        icons_output_dir = os.path.join(self.build_source_dir, 'icons')
        shutil.rmtree(icons_output_dir, ignore_errors=True)
        if icons_path:
            shutil.copytree(icons_path, icons_output_dir)

        # 获取content模板对象
        template_content_path = os.path.join(
            self.template_dir, 'OEBPS', 'content.opf')
        with open(template_content_path, 'r') as fh:
            template_content = Template(fh.read())

        # 渲染content目标文件
        content_path = os.path.join(self.build_source_dir, 'moear.opf')
        with codecs.open(content_path, 'wb', 'utf-8') as fh:
            fh.write(template_content.render(
                data=self.data,
                spider=self.spider,
                options=self.options))

        # 获取toc.ncx模板对象
        template_toc_path = os.path.join(
            self.template_dir, 'OEBPS', 'toc.ncx')
        with open(template_toc_path, 'r') as fh:
            template_toc = Template(fh.read())

        # 渲染toc.ncx目标文件
        toc_path = os.path.join(self.build_source_dir, 'misc', 'toc.ncx')
        utils.mkdirp(os.path.dirname(toc_path))
        with codecs.open(toc_path, 'wb', 'utf-8') as fh:
            fh.write(template_toc.render(
                data=self.data,
                spider=self.spider,
                options=self.options))

        # 获取toc.html模板对象
        template_toc_path = os.path.join(
            self.template_dir, 'OEBPS', 'toc.html')
        with open(template_toc_path, 'r') as fh:
            template_toc = Template(fh.read())

        # 渲染toc.html目标文件
        toc_path = os.path.join(self.build_source_dir, 'html', 'toc.html')
        utils.mkdirp(os.path.dirname(toc_path))
        with codecs.open(toc_path, 'wb', 'utf-8') as fh:
            fh.write(template_toc.render(
                data=self.data,
                options=self.options))

        # 生成mobi文件到mobi_dir
        self.generate_mobi_file()
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;
		}
	}
398188
function f_urunle_teklif_verilen_ihale_sayisi(_tahta_id, _urun_id, _onay_id, _para_id, _tarih1, _tarih2) {
        //1 ürünle verilen teklifler için temp oluştur
        //2 tarih aralığındaki ihaleleri bul
        //3 ihaleye verilen teklifleri ile ürüne verilen tekliflerin kesişimi varsa ihale tarihinde teklif verildi diye 1 yaz yoksa 0 yaz
        //4 geçici anahtarı sil
        //5 ihale tarihine göre grupla ve toplamları dön

        var ihale = require('./db_ihale');

        return result.dbQ.Q.all([
            f_urun_teklif_temp(_tahta_id, _urun_id, _para_id, _onay_id),//1
            ihale.f_db_ihale_idler_aktif_tarih_araligindakiler(_tahta_id, _tarih1, _tarih2)//2
        ]).then(function (_ress) {
            var ihale_idler = _ress[1];

            return result.dbQ.hmget_json_parse(result.kp.ihale.tablo, ihale_idler)
                .then(function (ihaleler) {
                    if (ihaleler && ihaleler.length > 0) {
                        var arr = _.map(ihaleler, function (_ihale) {
                            //3

                            return (_onay_id && _onay_id != null && _onay_id != "" && _onay_id > 0
                                ?
                                result.dbQ.zinterstore("temp_utg", "2",
                                    result.kp.ihale.ssetTeklifleri(_ihale.Id),
                                    result.kp.temp.zsetUrunTeklifleriOnayDurumunaGore(_tahta_id, _urun_id, _onay_id))
                                :
                                result.dbQ.zinterstore("temp_utg", "2",
                                    result.kp.ihale.ssetTeklifleri(_ihale.Id),
                                    result.kp.temp.zsetUrunTeklifleriParaBirimli(_tahta_id, _urun_id, _para_id)))
                                .then(function (_iteklif_idler) {
                                    return {
                                        Key: _ihale.IhaleTarihi,
                                        Count: _iteklif_idler ? 1 : 0
                                    };
                                });
                        });
                        return result.dbQ.Q.all(arr)
                            .then(function (_res) {
                                //4 geçici oluşturulan anahtarı siliyoruz
                                result.dbQ.del("temp_utg");
                                return _res;
                            });
                    } else {
                        return [];
                    }
                });

        }).then(function (_result) {
            //5
            //buraya ihale tarihinde teklif atılmış ise teklif toplamları gelir
            //şimdi günlere göre gruplayarak tekliflerin toplamlarını sum ile hesaplamalıyız.
            if (_result && _result.length > 0) {
                var result = _.chain(_result)
                    .groupBy("Key")
                    .map(function (value, key) {
                        return {
                            Key: key,
                            Count: _.sum(_.map(value, "Count"))
                        }
                    })
                    .value();
                return _.sortBy(result, "Key");
            } else {
                return [];
            }
        });
    }
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()
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)
359740
def open_listing_page(trailing_part_of_url):
    
    base_url = 'http://www.bbc.co.uk/programmes/'
    print("Opening web page: " + base_url + trailing_part_of_url)

    try:
        html = requests.get(base_url + trailing_part_of_url).text
    except (IOError, NameError):
        print("Error opening web page.")
        print("Check network connection and/or programme id.")
        sys.exit(1)

    try:
        return lxml.html.fromstring(html)
    except lxml.etree.ParserError:
        print("Error trying to parse web page.")
        print("Maybe there's no programme listing?")
        sys.exit(1)
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()
553293
def find_comment_by_id(self, comment_id):
        
        url = 'https://openapi.youku.com/v2/comments/show.json'
        params = {
            'client_id': self.client_id,
            'comment_id': comment_id
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
1257455
function() {
		var api_url,
			api_language,
			self = this;

		// Create Dom element
		this._el.content_item	= TL.Dom.create("div", "tl-media-item tl-media-wikipedia", this._el.content);
		this._el.content_container.className = "tl-media-content-container tl-media-content-container-text";

		// Get Media ID
		this.media_id	 = this.data.url.split("wiki\/")[1].split("#")[0].replace("_", " ");
		this.media_id	 = this.media_id.replace(" ", "%20");
		api_language	 = this.data.url.split("//")[1].split(".wikipedia")[0];

		// API URL
		api_url = "https://" + api_language + ".wikipedia.org/w/api.php?action=query&prop=extracts|pageimages&redirects=&titles=" + this.media_id + "&exintro=1&format=json&callback=?";

		// API Call
		TL.ajax({
			type: 'GET',
			url: api_url,
			dataType: 'json', //json data type

			success: function(d){
				self.createMedia(d);
			},
			error:function(xhr, type){
				var error_text = "";
				error_text += self._("wikipedia_load_err") + "<br/>" + self.media_id + "<br/>" + type;
				self.loadErrorDisplay(error_text);
			}
		});

	}