Get Youtube videos via channel ID
333382
function getVideos(auth, youtube, channel_id, count, callback) {
  youtube.search.list( // Call the Youtube API
  {
    auth: auth,
    part: "snippet",
    order: "date",
    maxResults : count, //integer 0-50, default 5
    channelId: channel_id
  },
  function(err, res) {
    if (err) {
      console.log("The API returned an error: " + err);
    } else {
      if (res.data.items !== undefined) { // Check if a result was found
        getVideoStatistics(auth, youtube, res.data.items, count, callback); // Get video statistics
      } else {
        callback([]);
      }
    }
  });
}
1110782
public function parseStreamMap($video_html, $video_id)
    {
        $stream_map = array();
        $result = array();

        // http://stackoverflow.com/questions/35608686/how-can-i-get-the-actual-video-url-of-a-youtube-live-stream
        if (preg_match('@url_encoded_fmt_stream_map["\']:\s*["\']([^"\'\s]*)@', $video_html, $matches)) {
            $stream_map = $matches[1];
        } else {

            $gvi = $this->curl("https://www.youtube.com/get_video_info?el=embedded&eurl=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D" . urlencode($video_id) . "&video_id={$video_id}");

            if (preg_match('@url_encoded_fmt_stream_map=([^\&\s]+)@', $gvi, $matches_gvi)) {
                $stream_map = urldecode($matches_gvi[1]);
            }
        }

        if ($stream_map) {
            $parts = explode(",", $stream_map);

            foreach ($parts as $p) {
                $query = str_replace('\u0026', '&', $p);
                parse_str($query, $arr);

                $result[] = $arr;
            }

            return $result;
        }

        // TODO:
        // elseif (strpos($html, 'player-age-gate-content') !== false) { // age-gate
        // youtube must have changed something
        return $result;
    }
1331808
function youtubeApiHandle() {
        for (var i = 0; i < YTTemp.length; i++) {
            var iframe = YTTemp[i];
            var player = new YT.Player(iframe);
            videoPlayers[iframe.id] = player;
        }
    }
939043
async function fetchDetails(id, fetch, gAuthKey) {
  try {
    const res = await fetch(
      `https://www.googleapis.com/youtube/v3/videos?id=${id}&key=${gAuthKey}&part=snippet,statistics`
    )
    const data = await res.json()
    return data.items[0]
  } catch (e) {
    console.log(e)
    return {}
  }
}
63646
public function getVideoDetail($id)
    {
        $this->setId($id);

        $data = $this->getData($this->baseVideoUrl);

        if(!$data) {
            throw new \Exception("Video not found");
        }

        $data = $data[0];

        return array(
            'id'              => $data->id,
            'title'           => $data->title,
            'description'     => $data->description,
            'thumbnail_small' => $data->thumbnail_small,
            'thumbnail_large' => $data->thumbnail_large,
            'duration'        => $data->duration,
            'upload_date'     => $data->upload_date,
            'like_count'      => isset($data->stats_number_of_likes) ? $data->stats_number_of_likes : 0,
            'view_count'      => isset($data->stats_number_of_plays) ? $data->stats_number_of_plays : 0,
            'comment_count'   => isset($data->stats_number_of_comments) ? $data->stats_number_of_comments : 0,
            'uploader'        => $data->user_name
        );
    }
1142812
public static function retrieve($sub_app_id, $channel, $options = null)
    {
        $url = static::instanceUrlWithChannel($sub_app_id, $channel);
        return static::_directRequest('get', $url, array(), $options);
    }
1300948
def history(self, channel_name, **kwargs):
        
        channel_id = self.get_channel_id(channel_name)
        self.params.update({'channel': channel_id})
        if kwargs:
            self.params.update(kwargs)
        return FromUrl('https://slack.com/api/channels.history', self._requests)(data=self.params).get()
413047
def get(video_id)
      params = {:id => video_id, :part => 'snippet,statistics'}
      request = Yourub::REST::Videos.list(self,params)
      Yourub::Result.format(request).first
    end
829977
def get_channel(self, name):
        
        return self._api_get('/api/channels/{0}'.format(
            urllib.parse.quote_plus(name)
        ))
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()
1026047
function onYouTubePlayerAPIReady() {
  // Loop through each iframe video on the page
  jQuery( "iframe.copy-video__video").each(function (index) {

    // Create IDs dynamically
    var iframeID = "js-copy-video-" + index;
    var buttonID = "js-copy-video-" + index + "__button";

    // Set IDs
    jQuery(this).attr('id', iframeID);
    jQuery(this).next('button.copy-video__button').attr('id', buttonID);

    // Associate video player with button via index
    players[buttonID] = { player: null, }

    // Set-up a player object for each video
    players[buttonID].player =  new YT.Player(iframeID, {
      events: { 'onReady': onPlayerReady }
    });
  });
}
681608
def get_views(video_id)
      params = { :id => video_id, :part => 'statistics' }
      request = Yourub::REST::Videos.list(self,params)
      v = Yourub::Result.format(request).first
      v ? Yourub::CountFilter.get_views_count(v) : nil
    end
217538
function(username) {
        var result = q.defer();
        this.robot.http('https://gdata.youtube.com/feeds/api/users/' + username + '/uploads?alt=json')
            .header('Accept', 'application/json')
            .get()(function (err, res, body) {
            if (err) {
                result.reject(err);
                return;
            }

            if(res.statusCode >= 400) {
                result.reject(body);
                return;
            }

            var parsed;
            try {
                parsed = JSON.parse(body);
            } catch (e) {
                result.reject(e);
            }

            if(!parsed.feed || !parsed.feed.entry) {
                result.reject('invalid format of youtube data');
                return;
            }

            var videos = parsed.feed.entry.map(function(element) {
                return {
                    id: element.id.$t,
                    link: element.link[0].href
                }
            });

            result.resolve(videos);
        });
        return result.promise;
    }
767759
function youtube(str) {
	// shortcode
	var shortcode = /youtube:\/\/|https?:\/\/youtu\.be\//g;

	if (shortcode.test(str)) {
		var shortcodeid = str.split(shortcode)[1];
		return stripParameters(shortcodeid);
	}

	// /v/ or /vi/
	var inlinev = /\/v\/|\/vi\//g;

	if (inlinev.test(str)) {
		var inlineid = str.split(inlinev)[1];
		return stripParameters(inlineid);
	}

	// v= or vi=
	var parameterv = /v=|vi=/g;

	if (parameterv.test(str)) {
		var arr = str.split(parameterv);
		return arr[1].split('&')[0];
	}

	// v= or vi=
	var parameterwebp = /\/an_webp\//g;

	if (parameterwebp.test(str)) {
		var webp = str.split(parameterwebp)[1];
		return stripParameters(webp);
	}

	// embed
	var embedreg = /\/embed\//g;

	if (embedreg.test(str)) {
		var embedid = str.split(embedreg)[1];
		return stripParameters(embedid);
	}

	// user
	var userreg = /\/user\/(?!.*videos)/g;

	if (userreg.test(str)) {
		var elements = str.split('/');
		return stripParameters(elements.pop());
	}

	// attribution_link
	var attrreg = /\/attribution_link\?.*v%3D([^%&]*)(%26|&|$)/;

	if (attrreg.test(str)) {
		return str.match(attrreg)[1];
	}
}
61142
function (username, channel) {
        var userChannels = this.getUserNotifications(username);

        // if the user doesn't already have an entry add one
        if (userChannels === null) {
            userChannels = [];

            // update the user to add them to the latest videos list
            this.latestVideos.getLatestVideos(username);

            this.notifications.push({
                username: username,
                channels: userChannels
            });
        }

        // dont allow duplicate channel names
        if (userChannels.indexOf(channel) !== -1) {
            return false;
        }

        // add the channel to the user and save data
        userChannels.push(channel);
        this.saveNotifications();
        return true;
    }
711087
public function getChannelFromURL($youtube_url)
    {
        if (strpos($youtube_url, 'youtube.com') === false) {
            throw new \Exception('The supplied URL does not look like a Youtube URL');
        }

        $path = static::_parse_url_path($youtube_url);
        if (strpos($path, '/channel') === 0) {
            $segments = explode('/', $path);
            $channelId = $segments[count($segments) - 1];
            $channel = $this->getChannelById($channelId);
        } elseif (strpos($path, '/user') === 0) {
            $segments = explode('/', $path);
            $username = $segments[count($segments) - 1];
            $channel = $this->getChannelByName($username);
        } else {
            throw new \Exception('The supplied URL does not look like a Youtube Channel URL');
        }

        return $channel;
    }
1091490
def video_with_http_info(id, factory_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug "Calling API: FlipApi.video ..."
      end
      # verify the required parameter 'id' is set
      if @api_client.config.client_side_validation && id.nil?
        fail ArgumentError, "Missing the required parameter 'id' when calling FlipApi.video"
      end
      # verify the required parameter 'factory_id' is set
      if @api_client.config.client_side_validation && factory_id.nil?
        fail ArgumentError, "Missing the required parameter 'factory_id' when calling FlipApi.video"
      end
      # resource path
      local_var_path = "/videos/{id}.json".sub('{' + 'id' + '}', id.to_s)

      # query parameters
      query_params = {}
      query_params[:'factory_id'] = factory_id

      # header parameters
      header_params = {}
      # HTTP header 'Accept' (if needed)
      header_params['Accept'] = @api_client.select_header_accept(['application/json'])
      # HTTP header 'Content-Type'
      header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = nil
      auth_names = ['api_key']
      data, status_code, headers = @api_client.call_api(:GET, local_var_path,
        :header_params => header_params,
        :query_params => query_params,
        :form_params => form_params,
        :body => post_body,
        :auth_names => auth_names,
        :return_type => 'Video')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: FlipApi#video\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end