doc: http://open.youku.com/docs/doc?id=59
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()
1296275
def open
      unless addon_name = shift_argument
        error("Usage: heroku addons:open ADDON\nMust specify ADDON to open.")
      end
      validate_arguments!
      requires_preauth

      addon = resolve_addon!(addon_name)
      web_url = addon['web_url']

      begin
        attachment = resolve_attachment!(addon_name)
        web_url = attachment['web_url']
      rescue Heroku::API::Errors::NotFound
        # no-op
      rescue Heroku::API::Errors::RequestFailed => e
        if MultiJson.decode(e.response.body)["id"] != "multiple_matches"
          raise
        end
      end

      service = addon['addon_service']['name']
      launchy("Opening #{service} (#{addon['name']}) for #{addon['app']['name']}", web_url)
    end
101312
function(){
		var pzl = this, col = pzl.cols, row = pzl.rows, out = [];

		/* URLにつけるオプション */
		if(pzl.type!==URL_KANPEN && pzl.type!==URL_HEYAAPP){
			if(pzl.type===URL_KANPENP || !!pzl.pflag){ out.push(pzl.pflag);}
		}

		/* サイズを表す文字列 */
		if(pzl.type===URL_KANPEN){
			if(pzl.pid==="kakuro"){
				out.push(row + 1);
				out.push(col + 1);
			}
			else if(pzl.pid==="sudoku"){
				out.push(col);
			}
			else{
				out.push(row);
				out.push(col);
			}
		}
		else if(pzl.type===URL_HEYAAPP){
			out.push([col, row].join("x"));
		}
		else{
			out.push(col);
			out.push(row);
		}

		/* サイズ以降のデータを設定 */
		out.push(pzl.body);

		/* 末尾が0-9,a-z,A-Z以外の時にt.coで情報が欠落しないよう/を追加 */
		var body = out.join("/");
		if(!body.charAt(body.length-1).match(/[a-zA-Z0-9]/)){ body+='/';}
		return body;
	}
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()
467526
function getVideoIdYoutube (str) {
  // link : https://youtube.com/watch?v=HBHJ0XGZfLs
  // share : https://youtu.be/HBHJ0XGZfLs
  // embed : https://youtube.com/embed/HBHJ0XGZfLs
  var re = /\/\/(?:www\.)?youtu(?:\.be|be\.com)\/(?:watch\?v=|embed\/)?([a-z0-9_\-]+)/i
  var matches = re.exec(str)
  return matches && matches[1]
}
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']
15007
def search_keyword_complete(self, keyword):
        
        url = 'https://openapi.youku.com/v2/searches/keyword/complete.json'
        params = {
            'client_id': self.client_id,
            'keyword': keyword
        }
        r = requests.get(url, params=params)
        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
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()
217356
function f_teklif_urun_idleri(_teklif_id) {

        return result.dbQ.hget(result.kp.teklif.hsetUrunleri, _teklif_id)
            .then(function (_dbUrun_idler) {
                console.log("f_db_teklif_urun_idleri>" + _dbUrun_idler);
                //teklifler array olmalıdır değilse parse ile array e dönüştürmeliyiz
                _dbUrun_idler = Array.isArray(_dbUrun_idler) ? _dbUrun_idler : JSON.parse(_dbUrun_idler);

                return _dbUrun_idler;
            });
    }
1311685
def find_comments_by_ids(self, comment_ids):
        
        url = 'https://openapi.youku.com/v2/comments/show_batch.json'
        params = {
            'client_id': self.client_id,
            'comment_ids': comment_ids
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
553098
def search_shows_by_keyword(self, keyword, unite=0, source_site=None,
                                category=None, release_year=None,
                                area=None, orderby='view-count',
                                paid=None, hasvideotype=None,
                                page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/searches/show/by_keyword.json'
        params = {
            'client_id': self.client_id,
            'keyword': keyword,
            'unite': unite,
            'source_site': source_site,
            'category': category,
            'release_year': release_year,
            'area': area,
            'orderby': orderby,
            'paid': paid,
            'hasvideotype': hasvideotype,
            'page': page,
            'count': count
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
848469
function(){
		/* URLの種類からURLを取得する */
		var domain = (!pzpr.env.node ? document.domain : ''), url = "", pid = this.pid;
		if(!!domain){ domain += location.pathname;}
		else{ domain = "pzv.jp/p.html";}
		switch(this.type){
			case URL_PZPRV3:  url="http://"+domain+"?%PID%/"; break;
			case URL_KANPEN:  url="http://www.kanpen.net/%KID%.html?problem="; break;
			case URL_KANPENP: url="http://www.kanpen.net/%KID%.html?pzpr="; break;
			case URL_HEYAAPP: url="http://www.geocities.co.jp/heyawake/?problem="; break;
		}

		return url.replace("%PID%", pzpr.variety(pid).urlid)
				  .replace("%KID%", pzpr.variety(pid).kanpenid);
	}
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);
}
678224
def user(self, name):
        
        anime_data = requests.get(self.apiusers, params={'u': name, 'status': 'all', 'type': 'anime'},
                                  headers=self.header)

        if anime_data.status_code != 200:
            raise ConnectionError(
                "Anime Data Request failed. Please Open a bug on https://github.com/ccubed/Pymoe and include the following data.\nStatus Code: {}\n\nText:{}".format(
                    anime_data.status_code, anime_data.text))

        manga_data = requests.get(self.apiusers, params={'u': name, 'status': 'all', 'type': 'manga'},
                                  headers=self.header)

        if manga_data.status_code != 200:
            raise ConnectionError(
                "Manga Data Request failed. Please Open a bug on https://github.com/ccubed/Pymoe and include the following data.\nStatus Code: {}\n\nText:{}".format(
                    manga_data.status_code, manga_data.text))

        root = ET.fromstring(anime_data.text)
        uid = root.find('myinfo').find('user_id').text
        uname = root.find('myinfo').find('user_name').text
        anime_object_list = self.parse_anime_data(anime_data.text)
        manga_object_list = self.parse_manga_data(manga_data.text)
        return User(uid=uid,
                    name=uname,
                    anime_list=NT_USER_ANIME(
                        watching=[x for x in anime_object_list['data'] if x.status.user == "Currently Watching"],
                        completed=[x for x in anime_object_list['data'] if x.status.user == "Completed"],
                        held=[x for x in anime_object_list['data'] if x.status.user == "On Hold"],
                        dropped=[x for x in anime_object_list['data'] if x.status.user == "Dropped"],
                        planned=[x for x in anime_object_list['data'] if x.status.user == "Plan to Watch"]
                    ),
                    anime_days=anime_object_list['days'],
                    manga_list=NT_USER_MANGA(
                        reading=[x for x in manga_object_list['data'] if x.status.user == "Currently Reading"],
                        completed=[x for x in manga_object_list['data'] if x.status.user == "Completed"],
                        held=[x for x in manga_object_list['data'] if x.status.user == "On Hold"],
                        dropped=[x for x in manga_object_list['data'] if x.status.user == "Dropped"],
                        planned=[x for x in manga_object_list['data'] if x.status.user == "Plan to Read"]
                    ),
                    manga_days=manga_object_list['days'])
80011
function local(backendTplServer) {
    backendTplServer.app.get('/news/local', function(request, response) {
        // 公共的数据模型可以抽取到出来, 作为一个文件 require 进来, 防止多处重复定义数据模型的规则
        var data = Mock.mock({
            'news|10-20': [news]
        });

        // 单独修改其中的某个数据
        data.news[0].getUrls = function() {
            return [
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,',
                'http://dummyimage.com/112x74,'
            ]
        };

        response.render('news/local.html', data);
    });
}