class Dropcaster::Item
Attributes
duration[R]
file_path[R]
file_size[R]
image_url[RW]
keywords[RW]
lyrics[R]
pub_date[R]
tag[R]
tag2[R]
url[RW]
uuid[R]
Public Class Methods
new(file_path, options=nil)
click to toggle source
# File lib/dropcaster/item.rb, line 15 def initialize(file_path, options=nil) Mp3Info.open(file_path) { |mp3info| @file_path = Pathname.new(File.expand_path(file_path)).relative_path_from(Pathname.new(Dir.pwd)).cleanpath @tag = mp3info.tag @tag2 = mp3info.tag2 @duration = mp3info.length if @tag2['ULT'] @lyrics = {} @tag2['ULT'].split(/\x00/).drop(1).each_slice(2) { |k, v| @lyrics[k] = v } end } @file_size = File.new(file_path).stat.size @uuid = Digest::SHA1.hexdigest(File.read(file_path)) if tag2.TRDA.blank? logger.info("#{file_path} has no pub date set, using the file's modification time") @pub_date = Time.parse(File.new(file_path).mtime.to_s) else @pub_date = Time.parse(tag2.TRDA) end end