Sha256: 167d48c6b5b90bd053e732aadad7793743da72acdd05f494d6360eef72ed7e46

Contents?: true

Size: 1.51 KB

Versions: 4

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

require 'ehbrs/tools/core_ext'
require 'ehbrs_ruby_utils/videos/file'
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::File.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

4 entries across 4 versions & 1 rubygems

Version Path
ehbrs-tools-0.43.1 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.43.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.42.0 lib/ehbrs/tools/runner/music/lyrics.rb
ehbrs-tools-0.39.1 lib/ehbrs/tools/runner/music/lyrics.rb