Sha256: 56813dfa71204772c361d20caebf16790b8652bd5d42df2cd594dc39a4cd5508

Contents?: true

Size: 1.52 KB

Versions: 17

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'ehbrs/tools/core_ext'
require 'ehbrs_ruby_utils/videos/container'
require 'ultimate_lyrics/provider'

module Ehbrs
  module Tools
    class Runner
      class Music
        class Lyrics
          DEFAULT_PROVIDER = 'lyrics.com'

          runner_with :help, :output do
            arg_opt '-p', '--provider', 'Nome do provedor.', default: DEFAULT_PROVIDER
            pos_arg :file
          end

          def run
            start_banner
            show_results
          end

          def show_results
            if lyrics.found?
              success 'Lyrics found'
              run_output
            else
              fatal_error 'No lyric found'
            end
          end

          def start_banner
            infov 'File', file
            %w[artist album track title year].each do |attr|
              infov attr.humanize, container.tag_file.tag.send(attr)
            end
            infov 'Selected provider', provider
          end

          def container_uncached
            ::EhbrsRubyUtils::Videos::Container.from_file(file)
          end

          def file
            parsed.file.to_pathname
          end

          def lyrics_uncached
            container.lyrics_by_provider(provider)
          end

          def output_content
            lyrics.text
          end

          def provider_uncached
            ::UltimateLyrics::Provider.by_name(provider_name)
          end

          def provider_name
            parsed.provider
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ehbrs-tools-0.39.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.38.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.37.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.36.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.35.1 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.35.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.34.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.33.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.32.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.31.1 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.31.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.30.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.29.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.28.3 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.28.2 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.28.1 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.28.0 lib/ehbrs/tools/runner/music/lyrics.rb