Created
March 15, 2013 05:48
-
-
Save Fauntleroy/5167736 to your computer and use it in GitHub Desktop.
Convert the YouTube v3 API's insane duration to something reasonable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var convertYouTubeDuration = function( yt_duration ){ | |
var time_extractor = /([0-9]*)M([0-9]*)S$/; | |
var extracted = time_extractor.exec( yt_duration ); | |
var minutes = parseInt( extracted[1], 10 ); | |
var seconds = parseInt( extracted[2], 10 ); | |
var duration = ( minutes * 60 ) + seconds; | |
return duration; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Really nice, thank you