Skip to content

Instantly share code, notes, and snippets.

@karlosmid
Last active February 27, 2016 21:10
Show Gist options
  • Select an option

  • Save karlosmid/61700c227478492c5ae6 to your computer and use it in GitHub Desktop.

Select an option

Save karlosmid/61700c227478492c5ae6 to your computer and use it in GitHub Desktop.
Get youtube video subtitles
Then /^I see lessons with albanian subtitle$/ do
HOST = 'www.googleapis.com'
PATH = '/youtube/v3/captions'
PART = 'snippet'
on(YoutubePage).first_lesson_in_grid_element.when_visible(@app['PAGE_TIMEOUT']).click
youtube_video_id = @browser.element(:tag_name, 'iframe').attribute_value('data-video-id')
youtube_client = HTTPClient.new
response = JSON.parse youtube_client.get("https://#{HOST}#{PATH}?key=#{@app['GOOGLE_API_KEY']}&part=#{PART}&videoId=#{youtube_video_id}").body
pass = false
response['items'].each {|item|
if item['snippet']['language'] == 'sq'
pass = true
break
end
}
expect(pass).to be_truthy
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment