doc: http://open.youku.com/docs/doc?id=78
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()
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()
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;
	});
}
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']
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
696032
def url
      url = @path.sub(%r[^#{Regexp::quote(::Pupu.media_root)}], Regexp::quote(::Pupu.media_prefix))
      "/#{url}"
    end
1138539
function () {
    scan_mode = false;
    log.i('Now start qiniu watch.'.yellow);
    var watcher = chokidar.watch(local_dir, {ignored: /[\/\\]\./, persistent: true});
   
    watcher.on('add', function(file, event) {
        
        var name = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name);
    });
   
    watcher.on('change', function(file, event) {
        
        var name2 = path.join(dirPrefix, file.replace(local_dir, '')).replace(/\\/g, '/').replace(/^\//g, '');
        check_upload(file, name2);
    });
}
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)
851671
def search_show_top_unite(self, category, genre=None, area=None,
                              year=None, orderby=None, headnum=1,
                              tailnum=1, onesiteflag=None,
                              page=1, count=20):
        
        url = 'https://openapi.youku.com/v2/searches/show/top_unite.json'
        params = {
            'client_id': self.client_id,
            'category': category,
            'genre': genre,
            'area': area,
            'year': year,
            'orderby': orderby,
            'headnum': headnum,
            'tailnum': tailnum,
            'onesiteflag': onesiteflag,
            'page': page,
            'count': count
        }
        params = remove_none_value(params)
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
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()
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);
}
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);
    });
}
128483
def fetcher(date=datetime.today(), url_pattern=URL_PATTERN):
    
    api_url = url_pattern % date.strftime('%Y-%m-%d')

    headers = {'Referer': 'http://n.pl/program-tv'}
    raw_result = requests.get(api_url, headers=headers).json()
    return raw_result
897132
function downloadFile(url) {
  requestProgress(request({
    url: url,
    header: {
      'User-Agent': userAgent
    }
  }))
    .on('progress', function (state) {
      if (!bar) {
        console.log('downloading %s', url)
        bar = new ProgressBar(':bar :percent(:current byte)', {
          total: state.size.total,
          width: 12 + url.length
        })
      }
      bar.curr = state.size.transferred
      bar.tick()
    })
    .on('end', function () {
      bar.curr = bar.total
      bar.tick()
      // 为了显示 100% 和换行 所以下面代码运行在 nextTick
      process.nextTick(function () {
        console.log('download completed: ' + tmpZipFilePath)
        var fileMd5 = md5File.sync(tmpZipFilePath)
        if (expectedMd5 !== fileMd5) {
          console.error('md5 does not match, expect ' + expectedMd5 + ' but got ' + fileMd5)
          onInterrupted()
        }
        console.log('md5 check ok')
        console.log('unzip to ' + tmpZipFilePath)
        unZipFile(tmpZipFilePath)
      })
    })
    .pipe(fs.createWriteStream(tmpZipFilePath))
}
947265
def find_videos_by_related(self, video_id, count=20):
        
        url = 'https://openapi.youku.com/v2/videos/by_related.json'
        params = {
            'client_id': self.client_id,
            'video_id': video_id,
            'count': count
        }
        r = requests.get(url, params=params)
        check_error(r)
        return r.json()
1081263
function(){
		var inp = this.qdata.split("/"), col = 0, row = 0;
		delete this.qdata;
		/* URLにつけるオプション */
		if(this.type!==URL_KANPEN && this.type!==URL_HEYAAPP){
			if(!!inp[0] && !isNaN(inp[0])){ inp.unshift("");}
			this.pflag = inp.shift();
		}
		
		/* サイズを表す文字列 */
		if(this.type===URL_KANPEN){
			if(this.pid==="kakuro"){
				row = +inp.shift() - 1;
				col = +inp.shift() - 1;
			}
			else if(this.pid==="sudoku"){
				row = col = +inp.shift();
			}
			else{
				row = +inp.shift();
				col = +inp.shift();
			}
		}
		else if(this.type===URL_HEYAAPP){
			var size = inp.shift().split("x");
			col = +size[0];
			row = +size[1];
		}
		else{
			col = +inp.shift() || NaN;
			row = +inp.shift() || NaN;
		}
		this.rows = row;
		this.cols = col;

		/* サイズ以降のデータを取得 */
		if(!inp[inp.length-1]){ inp.pop();}
		this.body = inp.join("/");
	}