doc: http://open.youku.com/docs/doc?id=50
776068
def update_video(self, access_token, video_id, title=None,
                     tags=None, category=None, copyright_type=None,
                     public_type=None, watch_password=None,
                     description=None, thumbnail_seq=None):
        
        url = 'https://openapi.youku.com/v2/videos/update.json'
        data = {
            'client_id': self.client_id,
            'access_token': access_token,
            'video_id': video_id,
            'title': title,
            'tags': tags,
            'category': category,
            'copyright_type': copyright_type,
            'public_type': public_type,
            'watch_password': watch_password,
            'description': description,
            'thumbnail_seq': thumbnail_seq
        }
        data = remove_none_value(data)
        r = requests.post(url, data=data)
        check_error(r)
        return r.json()['id']
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()
598949
def query(botcust2, message):
    
    logger.debug("Getting Mitsuku reply")

    # Set up http request packages
    params = {
        'botid': 'f6a012073e345a08',
        'amp;skin': 'chat'
    }
    headers = {
        'Accept-Encoding': 'gzip, deflate, br',
        'Accept-Language': 'en-US,en;q=0.8',
        'Cache-Control': 'max-age=0',
        'Connection': 'keep-alive',
        'Content-Length': str(len(message) + 34),
        'Content-Type': 'application/x-www-form-urlencoded',
        'Cookie': 'botcust2=' + botcust2,
        'DNT': '1',
        'Host': 'kakko.pandorabots.com',
        'Origin': 'https://kakko.pandorabots.com',
        'Referer': 'https://kakko.pandorabots.com/pandora/talk?botid=f6a012073e345a08&amp;skin=chat',
        'Upgrade-Insecure-Requests': '1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/58.0.3029.110 Safari/537.36'
    }
    data = {
        'botcust2': botcust2,
        'message': message
    }

    # Get response from http POST request to url
    logger.debug("Sending POST request")
    response = requests.post(
        url,
        params=params,
        headers=headers,
        data=data
    )
    logger.debug("POST response {}".format(response))

    # Parse response
    parsed = lxml.html.parse(io.StringIO(response.text)).getroot()
    try:
        result = parsed[1][2][0][2].tail[1:]
        logger.debug("Getting botcust2 successful")
    except IndexError:
        result = False
        logger.critical("Getting botcust2 from html failed")

    return result
535735
function() {
		var api_url,
			self = this;
					
		// Create Dom element
		this._el.content_item = TL.Dom.create("div", "tl-media-twitter", this._el.content);
		this._el.content_container.className = "tl-media-content-container tl-media-content-container-text";
        		
		// Get Media ID
        if(this.data.url.match("^(https?:)?\/*(www.)?twitter\.com"))
        {
		if (this.data.url.match("status\/")) {
			this.media_id = this.data.url.split("status\/")[1];
		} else if (this.data.url.match("statuses\/")) {
			this.media_id = this.data.url.split("statuses\/")[1];
		} else {
			this.media_id = "";
		}
        }
        
        else if(this.data.url.match("<blockquote class=['\"]twitter-tweet['\"]")) {
		
        var found = this.data.url.match(/(status|statuses)\/(\d+)/);
		if (found && found.length > 2) {
		    this.media_id = found[2];
		} else {
		    self.loadErrorDisplay(self._("twitterembed_invalidurl_err"));
		    return;
		}
    }
        
		// API URL
		api_url = "https://api.twitter.com/1/statuses/oembed.json?id=" + this.media_id + "&omit_script=true&include_entities=true&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._("twitter_load_err") + "<br/>" + self.media_id + "<br/>" + type;
				self.loadErrorDisplay(error_text);
			}
		});
		 
	}
398847
def myanimelist(username):
    
    params = {
        "u": username,
        "status": "all",
        "type": "anime"
    }

    resp = requests.request("GET", ENDPOINT_URLS.MYANIMELIST, params=params)

    # Check if MAL's hitting you with a 429 and raise an exception if so.
    if resp.status_code == 429:  # pragma: no cover
        raise MALRateLimitExceededError("MAL rate limit exceeded")

    resp = bs4.BeautifulSoup(resp.content, "xml")

    all_anime = resp.find_all("anime")

    # Check if there's actually any anime being returned to us.
    # If not, user probably doesn't exist.
    # MAL should do a better job of highlighting this, but eh.
    if not len(all_anime):
        raise InvalidUsernameError("User `{}` does not exist"
                                   .format(username))

    scores = []

    for anime in all_anime:
        # See if anime is on their PTW and move on if so.
        # This makes sure rated anime that the user hasn't
        # seen does not get added to `scores`.
        # Why do people even do this?
        # PTW == status "6"
        if anime.my_status.string == "6":
            continue

        id = anime.series_animedb_id.string
        id = int(id)

        score = anime.my_score.string
        # Might need changing if MAL allows float scores.
        score = int(score)

        if score > 0:
            scores.append({"id": id, "score": score})

    # Check if there's actually anything in scores.
    # If not, user probably doesn't have any rated anime.
    if not len(scores):
        raise NoAffinityError("User `{}` hasn't rated any anime"
                              .format(username))

    return scores
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
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()
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']
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()
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()
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()
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()
305384
function () {

/*Line 44 - 'AtomForm.js' */                if (!this.isValid()) {
/*Line 45 - 'AtomForm.js' */                    return;
/*Line 46 - 'AtomForm.js' */                }

/*Line 48 - 'AtomForm.js' */                var data = this.preparePostData();
/*Line 49 - 'AtomForm.js' */                var url = AtomPromise.getUrl(this._postUrl);
/*Line 50 - 'AtomForm.js' */                AtomPromise.json(url, { _tv: Atom.time() }, { type: "POST", data: data }).then(this._success).invoke();
/*Line 51 - 'AtomForm.js' */            }
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;
            });
    }
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()
1053364
def get_random_giphy(phrase):
    """"""
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')

        giphy = giphypop.Giphy()

    results = giphy.search_list(phrase=phrase, limit=100)

    if not results:
        raise ValueError('There were no results for that phrase')

    return random.choice(results).media_url
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);
			}
		});

	}