SplashYou.rb
def grab_videos(vid_num = 10) # Default is 10 videos total
  batch         = '?page[size]=' + @page_size.to_s
  headers       = @params['headers']
  while @vids.length < vid_num
    puts 'Grabbing video batch #' + @page_counter.to_s
    page        = '&page[num]=' + @page_counter.to_s
    sub_api_url = @params['base_url'] + batch + page + '&fields=reach,title,youtube_url'

    getty = Planetoftheapis.new(headers: headers, meth: 'Get', params: {}, url: sub_api_url).api_call
    check_api_response(getty)
    something_went_wrong if @vids['error'] == true
    getty['response']['_embedded']['media-items'].each do |vid|
      # skip invalid urls and ignore playlists for now
      next unless vid['youtube_url'] =~ /\Ahttps:\/\/www.youtube.com\/watch\?v=/
      check_video(vid)
    end
    @page_counter = @page_counter + 1
  end
  return @vids
end
# Make api calls for requested number of videos
Make api calls for requested number of videos
Make api calls for requested number of videos
def grab_videos(vid_num = 10) 
  batch         = '?page[size]=' + @page_size.to_s
  headers       = @params['headers']
  while @vids.length < vid_num
    puts 'Grabbing video batch #' + @page_counter.to_s
    page        = '&page[num]=' + @page_counter.to_s
    sub_api_url = @params['base_url'] + batch + page + '&fields=reach,title,youtube_url'
    getty = Planetoftheapis.new(headers: headers, meth: 'Get', params: {}, url: sub_api_url).api_call
    check_api_response(getty)
    something_went_wrong if @vids['error'] == true
    getty['response']['_embedded']['media-items'].each do |vid|
      next unless vid['youtube_url'] =~ /\Ahttps:\/\/www.youtube.com\/watch\?v=/
      check_video(vid)
    end
    @page_counter = @page_counter + 1
  end
  return @vids
end
def grab_videos ( vid_num = 10 ) batch = '?page[size]=' + @page_size . to_s headers = @params [ 'headers' ] while @vids . length < vid_num puts 'Grabbing video batch #' + @page_counter . to_s page = '&page[num]=' + @page_counter . to_s sub_api_url = @params [ 'base_url' ] + batch + page + '&fields=reach,title,youtube_url' getty = Planetoftheapis . new ( headers : headers , meth : 'Get' , params : { } , url : sub_api_url ) . api_call check_api_response ( getty ) something_went_wrong if @vids [ 'error' ] == true getty [ 'response' ] [ '_embedded' ] [ 'media-items' ] . each do | vid | next unless vid [ 'youtube_url' ] =~ / \A https: \/ \/ www.youtube.com \/ watch \? v= / check_video ( vid ) end @page_counter = @page_counter + 1 end return @vids end
Make api calls for requested number of videos
Make api calls for requested number of videos
# Default is 10 videos total # skip invalid urls and ignore playlists for now
vid_num