class MultimediaParadise::AudioTagReader
Constants
- N_PAD
#¶ ↑
N_PAD
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( commandline_arguments = nil, run_already = true ) { || ... }
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 34 def initialize( commandline_arguments = nil, run_already = true ) reset set_commandline_arguments( commandline_arguments ) # ======================================================================= # # === Handle blocks next # ======================================================================= # if block_given? yielded = yield case yielded # ===================================================================== # # === :do_not_report_anything # ===================================================================== # when :do_not_report_anything, :be_quiet, :be_silent @may_we_report = false end end run if run_already end
Public Instance Methods
album?()
click to toggle source
#¶ ↑
album?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 216 def album? @album end
Also aliased as: album
artist?()
click to toggle source
#¶ ↑
artist?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 188 def artist? @artist end
Also aliased as: artist
band?()
click to toggle source
#¶ ↑
band?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 230 def band? @band end
Also aliased as: band
bpm?()
click to toggle source
#¶ ↑
bpm?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 209 def bpm? @bpm end
Also aliased as: bpm
comment?()
click to toggle source
#¶ ↑
comment?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 251 def comment? @comment end
Also aliased as: comment
date?()
click to toggle source
#¶ ↑
date?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 195 def date? @date end
Also aliased as: date
disc?()
click to toggle source
#¶ ↑
disc?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 202 def disc? @disc end
Also aliased as: disc
do_determine_the_length_of_the_song( this_file = main_file? )
click to toggle source
#¶ ↑
do_determine_the_length_of_the_song
¶ ↑
The first argument should be the name of the .mp3 file at hand.
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 404 def do_determine_the_length_of_the_song( this_file = main_file? ) # ======================================================================= # # The way for the mp3-library goes like this: # @length_in_seconds = @properties.length_in_seconds # => 335 (song length) # But this was buggy for me, so we query ffmpeg instead. The code above # is retained, though, in the event that we may want to re-instate it # one day. (Noted this down at 26.10.2021) # ======================================================================= # @length_in_seconds = ::MultimediaParadise.length_of?(this_file) end
genre?()
click to toggle source
#¶ ↑
genre?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 237 def genre? @genre end
Also aliased as: genre
length_in_seconds?()
click to toggle source
performer?()
click to toggle source
#¶ ↑
performer?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 244 def performer? @performer end
Also aliased as: performer
report_album(i = @album)
click to toggle source
report_artist(i = @artist)
click to toggle source
report_comment(i = @comment)
click to toggle source
report_everything()
click to toggle source
#¶ ↑
report_everything
¶ ↑
This method will report as much as possible about the song at hand.
“track” would also be a tag that could be shown. Personally I don’t really need it, though.
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 333 def report_everything report_title report_artist report_album report_year report_genre report_comment report_length_in_seconds end
Also aliased as: report
report_genre(i = @genre)
click to toggle source
report_length_in_seconds( i = @length_in_seconds )
click to toggle source
report_title(i = @title)
click to toggle source
report_year(i = @year)
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::Base#reset
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 63 def reset super() # ======================================================================= # # === @performer # ======================================================================= # @performer = nil # ======================================================================= # # === @band # ======================================================================= # @band = nil # ======================================================================= # # === @bpm # ======================================================================= # @bpm = nil # ======================================================================= # # === @date # ======================================================================= # @date = nil # ======================================================================= # # === @disc # ======================================================================= # @disc = nil # ======================================================================= # # === @may_we_report # # Whether to output anything to the user on the commandline or not, # by default. # ======================================================================= # @may_we_report = true end
right_colour(i)
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 471 def run try_to_require_the_tablib_gem # ======================================================================= # # We will assume that the first argument given is the file we want to # work on. # ======================================================================= # this_file = first_argument?.to_s.dup set_this_file(this_file) work_on_this_file(@this_file) end
save()
click to toggle source
set_album(i)
click to toggle source
#¶ ↑
set_album
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 272 def set_album(i) @album = i.to_s end
Also aliased as: album=
set_artist(i)
click to toggle source
#¶ ↑
set_artist
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 279 def set_artist(i) @artist = i.to_s end
Also aliased as: artist=
set_comment(i)
click to toggle source
#¶ ↑
set_comment
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 286 def set_comment(i) @comment = i.to_s end
Also aliased as: comment=
set_genre(i)
click to toggle source
#¶ ↑
set_genre
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 307 def set_genre(i) @genre = i.to_s end
Also aliased as: genre=
set_new_album(i)
click to toggle source
set_new_year(i)
click to toggle source
set_this_file(i)
click to toggle source
set_title(i)
click to toggle source
#¶ ↑
set_title
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 265 def set_title(i) @title = i.to_s end
Also aliased as: title=
set_track(i)
click to toggle source
#¶ ↑
set_track
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 293 def set_track(i) @track = i.to_i # This must be an Integer. end
Also aliased as: track=
set_year(i)
click to toggle source
#¶ ↑
set_year
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 300 def set_year(i) @year = i.to_i # This must be an Integer. end
Also aliased as: year=
tag?()
click to toggle source
#¶ ↑
tag?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 174 def tag? @tag end
Also aliased as: tag
this_file?()
click to toggle source
#¶ ↑
this_file?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 388 def this_file? @this_file end
Also aliased as: main_file?
title?()
click to toggle source
#¶ ↑
title?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 181 def title? @title end
Also aliased as: title
track?()
click to toggle source
#¶ ↑
track?¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 258 def track? @track end
Also aliased as: track
try_to_require_the_tablib_gem()
click to toggle source
#¶ ↑
try_to_require_the_tablib_gem
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 420 def try_to_require_the_tablib_gem begin # ===================================================================== # # Require the taglib-ruby gem. # # See: https://rubygems.org/gems/taglib-ruby # ===================================================================== # require 'taglib' rescue LoadError; end end
update!( this_file = @this_file, title = @title, artist = @artist, genre = @genre, comment = @comment, track = @track )
click to toggle source
#¶ ↑
update!¶ ↑
This method can be used to update the tags.
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 436 def update!( this_file = @this_file, title = @title, artist = @artist, genre = @genre, comment = @comment, track = @track ) TagLib::FileRef.open(this_file) { |fileref| # of class TagLib::FileRef. unless fileref.null? @tag = fileref.tag # Keep a reference to it here. set_new_album(@album) # Use the old reference. set_new_year(@year) # Use the old reference, via @year. @tag.title = title.to_s @tag.artist = artist.to_s @tag.genre = genre.to_s @tag.comment = comment.to_s if track @tag.track = track.to_i # This must be an integer. end fileref.save end } end
work_on_this_file( this_file = @this_file )
click to toggle source
#¶ ↑
work_on_this_file
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/audio_tag_reader/audio_tag_reader.rb, line 346 def work_on_this_file( this_file = @this_file ) unless Object.const_defined? :TagLib text = <<-EOF Please install TagLib first via: gem install taglib EOF e text return text end # ======================================================================= # # Load up the file via TagLib first. # ======================================================================= # TagLib::FileRef.open(this_file) { |fileref| # of class TagLib::FileRef. unless fileref.null? @tag = fileref.tag # Keep a reference to it here. @title = @tag.title # => "Wake Up" @artist = @tag.artist # => "DJ Punk" @album = @tag.album # => "Funeral" @year = @tag.year # => 2004 @genre = @tag.genre # => "Indie Rock" @comment = @tag.comment @track = @tag.track # @band = @tag.band # Does not exist. @performer = @tag.performer if @tag.respond_to? :performer @properties = fileref.audio_properties do_determine_the_length_of_the_song(this_file) if @may_we_report e report_everything e end end } # File is automatically closed at block end. end