Sha256: 7ff225854cded1f066aeacf887eb0e4a05541f028df4696b7ae40cbb08b11aeb

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

#!/usr/bin/env ruby

require 'media/runner/version'
require 'rubygems'
require 'media/runner/app/args_sanitizer'
require 'media/runner/app/file_check'
require 'media/runner/app/media_paths'
require 'media/runner/app/vlc_check'
require 'media/runner/printer'

module Media
  class Run
    include ArgsSanitizer, FileCheck, VlcCheck, MediaPaths

    def start
      require 'commander/import'
      program :version, Media::Runner::VERSION
      program :description, 'Media Runner'

      command :series do |c|
        c.syntax = 'media-runner series [options]'
        c.summary = 'run an episode of a certain series'
        c.description = 'You can pass the an episode number and a series and run it with VLC.'
        c.example 'Run episode 1 of season 1 of Game of Thrones', 'media-runner series gameofthrones 101'
        c.action do |args|
          media = sanitize_args(args)

          unless series_exists?(media[:series])
            Media::Printer.output ["#{series_path(media[:series])} doesn't exist. Did you type the series name \
                                   correctly?"]
            exit 1
          end

          unless episode_exists?(media[:series], media[:episode])
            Media::Printer.output ["Episode #{media[:episode]} was not found in #{media[:series]}."]
            exit 1
          end

          format = episode_format(media[:series], media[:episode])
          vlc_installed?

          Media::Printer.output ["Playing episode #{media[:episode]} from #{media[:series]}. ENJOY!"]
          `zsh -c "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC --fullscreen \
           #{episode_path(media[:series], media[:episode], format)} > /dev/null 2>&1 &!"`
          exit 0
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
media-runner-1.0.2 lib/media/runner.rb