Skip to content

Instantly share code, notes, and snippets.

View kodopik's full-sized avatar

Anton Konoplev kodopik

View GitHub Profile
@jrtaylor-com
jrtaylor-com / youtubeDurationToSeconds
Created May 1, 2015 21:57
Parse Youtube v3 API Duration to seconds with Javascript
function youtubeDurationToSeconds(duration) {
var hours = 0;
var minutes = 0;
var seconds = 0;
// Remove PT from string ref: https://developers.google.com/youtube/v3/docs/videos#contentDetails.duration
duration = duration.replace('PT','');
// If the string contains hours parse it and remove it from our duration string
if (duration.indexOf('H') > -1) {