Sha256: bef61bf2908c1d560af2dd4e94a56af225f2dfb929319dad51d6b6c59c6bb97a

Contents?: true

Size: 739 Bytes

Versions: 2

Compression:

Stored size: 739 Bytes

Contents

require 'murlsh'

module Murlsh

  # Regenerate m3u file after a new audio url has been added.
  class AddPost50UpdateM3u < Plugin

    @hook = 'add_post'

    AudioContentTypes = %w{
      application/ogg
      audio/mpeg
      audio/ogg
      }

    OutputFile = 'm3u.m3u'

    def self.run(url, config)
      if AudioContentTypes.include?(url.content_type) or
        not File.exists?(OutputFile)

        Murlsh::openlock(OutputFile, 'w') do |f|
          f.write "# #{config['root_url']}\r\n\r\n"
          Murlsh::Url.all(:conditions =>
            ["content_type IN (?)", AudioContentTypes],
            :order => 'time DESC').each do |mu|
            f.write "#{mu.url}\r\n"
          end
        end
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
murlsh-1.4.1 plugins/add_post_50_update_m3u.rb
murlsh-1.4.0 plugins/add_post_50_update_m3u.rb