class MultimediaParadise::CreateM3uPlaylist
Constants
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
new( dataset = nil, store_here = 'default_playlist.m3u', run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
The first argument must include our dataset.
#¶ ↑
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 37 def initialize( dataset = nil, store_here = 'default_playlist.m3u', run_already = true ) reset set_dataset( dataset ) set_store_where( store_here ) run if run_already end
Public Instance Methods
consider_sanitizing_dataset()
click to toggle source
#¶ ↑
consider_sanitizing_dataset
¶ ↑
#¶ ↑
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 97 def consider_sanitizing_dataset _ = @dataset if (_.is_a?(String) or _.is_a?(Array)) and _.empty? _ = Dir['**/**'].select {|file| is_audio_song?(file) }.map {|file| # =================================================================== # # Keep the full pathname always. # =================================================================== # unless file.include? '/' file = rds("#{Dir.pwd}/#{file}") end file } set_dataset(_) end end
dataset?()
click to toggle source
obtain_songs_from_the_default_directory( use_this_directory = directory_to_the_local_songs? )
click to toggle source
#¶ ↑
obtain_songs_from_the_default_directory
¶ ↑
This method will obtain all audio songs from the local directory containing all songs.
#¶ ↑
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 76 def obtain_songs_from_the_default_directory( use_this_directory = directory_to_the_local_songs? ) filter_for_audio_files( Dir["#{use_this_directory}*"] ) end
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
Calls superclass method
MultimediaParadise::AudioBase#reset
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 55 def reset super() # ======================================================================= # # === @namespace # ======================================================================= # @namespace = NAMESPACE # ======================================================================= # # === @debug # # If the next variable is set to true then we will show more information, # aka debug-related information. # ======================================================================= # @debug = false end
run()
click to toggle source
set_dataset( i = obtain_songs_from_the_default_directory )
click to toggle source
#¶ ↑
set_dataset
¶ ↑
The @dataset will essentially keep track of our songs.
#¶ ↑
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 134 def set_dataset( i = obtain_songs_from_the_default_directory ) case i # ======================================================================= # # === :default_playlist # ======================================================================= # when :default_playlist, :default i = obtain_songs_from_the_default_directory end if i.is_a? Array if i.empty? # =================================================================== # # Try to populate the entry in the event that it is empty: # =================================================================== # i = obtain_songs_from_the_default_directory end # ===================================================================== # # If we have an Array, we will always sort alphabetically. # ===================================================================== # i.sort_by! {|file| File.basename(file) } i = i.join(N) # ======================================================================= # # Handle Hash-input next. Hashes are a bit more complicated than Arrays # here since we have to pick a relevant key. # ======================================================================= # elsif i.is_a? Hash values = i.values if values.first.is_a?(Hash) and values.first.has_key?('url') # =================================================================== # # This could be a complex Hash. # =================================================================== # i = values.map {|hash| hash['url'] } end end if debug? opnn; ecrimson('Debugging information: We will show the '\ 'dataset that will be used.') e pp i e end @dataset = i end
set_store_where(i)
click to toggle source
store_file_into( into = name_of_the_file? )
click to toggle source
#¶ ↑
store_file_into
¶ ↑
This method will create the .m3u file at hand.
#¶ ↑
# File lib/multimedia_paradise/audio/create_m3u_playlist.rb, line 189 def store_file_into( into = name_of_the_file? ) what = dataset? if @be_verbose if what.is_a? Hash n_entries = what.keys.size elsif what.is_a? Array n_entries = what.size else n_entries = what.count(N) end into = File.absolute_path(into) opnn; e "Will store into `#{sfile(into)}` "\ "(#{n_entries} entries)." end if what.is_a? Hash # ===================================================================== # # If we input a Hash then we will only use the values of # said Hash. # ===================================================================== # what = what.values.join(N) elsif what.is_a? Array what = what.join(N) end write_what_into(what, into) end