Class: AudioInfo::FileName

Inherits:
Tipo
  • Object
show all
Defined in:
lib/audioinfo.rb

Direct Known Subclasses

Mpc, Shn

Constant Summary collapse

ESTRUCTURAS =

Define las estructuras de nombre de archivo que pueden ser parseadas

[
					"%a-%b-%n-%t",
					"%a-%y-%b/%n-%t",
					"%a-%y-%b/%c/%n-%t",
					"%a-%b/%c/%n-%t",
					"%a-%n-%t",
					"%a/%b\\(%y\\)/%n-%t",
					"%a/%y-%b/%n-%t",
					"%a/%y-%b/%n\\.%t",
					"%a/%y-%b/%t",
"%a-%b/%n-%t",
"%a-%b/%t",
"%a/%n-%t",
"%n-%t",
"%a-%t",
"%a/%t",
"%t"]

Constants inherited from Tipo

Tipo::TAGS

Instance Attribute Summary

Attributes inherited from Tipo

#album, #artist, #bits_per_sample, #bps, #channels, #sFile, #sample_rate, #size, #time, #title, #tracknumber, #year

Instance Method Summary collapse

Methods inherited from Tipo

#arreglarValor, #arreglarValoresEstandar, #incompleto?, #initialize, #kbps, #merge

Constructor Details

This class inherits a constructor from AudioInfo::Tipo

Instance Method Details

#parseObject



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/audioinfo.rb', line 245

def parse
hEquil={'%a'=>'artist','%y'=>'year','%b'=>'album','%n'=>'tracknumber', '%t'=>'title'}
x=0
sFile=@sFile.gsub("_"," ")
sSupport=SUPPORT.join('|')
ESTRUCTURAS.each {|sTexto|
	aSec=sTexto.scan(/%[abcnty]/)
	rx=Regexp.new(".*/"+sTexto.gsub(/%[a|b|t]/, '\s*?([^/]+?)\s*?').gsub("%y", '\s*?(\d{4,4})\s*?').gsub("%n", '\s*?(\d{1,2})\.?\s*?').gsub("%c",'CD[\s-]?(\d)') + "\.(#{sSupport})$")
	if match=rx.match(sFile)
		puts "Patron:"+sTexto if $DEBUG
		x=1
		aSec.each{|tag|
			valor=match[x].strip
			if tag!='%n' and tag!='%y' and tag!='%c' and valor=~/^\d+$/
			puts "#{sFile} : Valor num�rico donde no corresponde en #{tag}:[#{valor}] #{rx}"
			next 2
			end
			case tag
				when '%c'
					@album+="[CD "+valor+"]"
				when '%n'
					@tracknumber=valor.to_i
				when '%y'
					@year=valor.to_i
				else
				puts "#{sFile} : Posible error - Valor numérico donde no corresponde en #{tag}:#{valor}" if valor=~/^\d+$/
				send(hEquil[tag]+'=',arreglarValor(tag,valor))
			end
			x+=1
		}
		break;
	end # fin if
}
end