Created
September 20, 2011 20:04
-
-
Save firebelly/1230168 to your computer and use it in GitHub Desktop.
mp3 enclosure tag length attribute to minutes:seconds
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
# in => <enclosure url="http://url.com/feed/some_final_url.mp3" length="42102758" type="audio/mpeg"/> | |
time = ((item.enclosure.length/1024.0) / 16.0) | |
p [time.to_i/60 % 60, time.to_i % 60].map{|t| t.to_s.rjust(2, '0')}.join(':') | |
# out => "42:49" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment