media-runner 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0234ad2c2f19583b5a0c98f95d4d52f61bfe1422
4
- data.tar.gz: e79f9f0015b1357e9c946d27a9988b6a376888f5
3
+ metadata.gz: 640e7450dd33ff8a2508ab3fe70d9879dc5de2b2
4
+ data.tar.gz: d8463dd431264db98e872ed5edbca742163adb6a
5
5
  SHA512:
6
- metadata.gz: f7f77c4ad1226eec9d3bb7371c3840d1a7facacba784f9b8879ce6af1e93f520772403d178bc4e5f64b38cec69062a73831dee69d5e0a0f537e146ecff0dbca7
7
- data.tar.gz: 6abc7ca7618017af2b60923fcfed70ef4703b6ba8176ac8c7b28cb132f0fb3296e9edfbdcffc6d38410f0845c4e763234a27819faf93760025404e4793c9a0df
6
+ metadata.gz: df1c86c99af01f13017a542331667ea884afea4bb7af0d2e2ec0f2ed797b27220bccedee35ba8fcc378e12938c0a6a5c347cffce40e2d8fb6ee6e3e6e757f903
7
+ data.tar.gz: a87674196ef3e944788432d5983c42a707e0c250e6f172b82b2675ab569c78b6b1c04d4dca5f2bda3b3df74010136ed732b5666e1f586091d6e9e15e97a38c4f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Media::Runner
2
2
 
3
- MediaRunner is a simple command line interface for OSX that helps you run your series conveniently in VLC media player.
3
+ MediaRunner is a simple command line interface for OSX that helps you run your series and movies conveniently in VLC media player.
4
4
 
5
5
  ## Installation
6
6
 
@@ -10,7 +10,9 @@ gem install media-runner
10
10
 
11
11
  ## Usage
12
12
 
13
- Be sure that you have your series stored like this `/Users/#{whoami}/Movies/series/SERIESNAME/EPISODENAME`.
13
+ Be sure that you have your series stored like this `/Users/#{whoami}/Movies/series/SERIESNAME/EPISODENAME`, and your movies like this `/Users/#{whoami}/Movies/movies/MOVIENAME`.
14
+
15
+ ### Run series
14
16
 
15
17
  Lets say you have `/Users/#{whoami}/Movies/series/gameofthrones/101.mp4`, then you can run it like this:
16
18
 
@@ -18,9 +20,17 @@ Lets say you have `/Users/#{whoami}/Movies/series/gameofthrones/101.mp4`, then y
18
20
  media-runner series gameofthrones 101
19
21
  ```
20
22
 
23
+ ### Run movie
24
+
25
+ Lets say you have `/Users/#{whoami}/Movies/movie/thegreatgatsby.mp4`, then you can run it like this:
26
+
27
+ ```
28
+ media-runner movie thegreatgatsby
29
+ ```
30
+
21
31
  ## Development
22
32
 
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, you can run `bin/check` to run the tests and the code linters. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
34
 
25
35
  To install this gem onto your local machine, run `bundle exec rake install`.
26
36
 
data/lib/media/runner.rb CHANGED
@@ -2,15 +2,17 @@
2
2
 
3
3
  require 'media/runner/version'
4
4
  require 'rubygems'
5
+ require 'media/runner/printer'
6
+ require 'media/runner/episode'
7
+ require 'media/runner/movie'
5
8
  require 'media/runner/app/args_sanitizer'
6
9
  require 'media/runner/app/file_check'
7
10
  require 'media/runner/app/media_paths'
8
11
  require 'media/runner/app/vlc_check'
9
- require 'media/runner/printer'
10
12
 
11
13
  module Media
12
14
  class Run
13
- include ArgsSanitizer, FileCheck, VlcCheck, MediaPaths
15
+ include ArgsSanitizer
14
16
 
15
17
  def start
16
18
  require 'commander/import'
@@ -23,26 +25,21 @@ module Media
23
25
  c.description = 'You can pass the an episode number and a series and run it with VLC.'
24
26
  c.example 'Run episode 1 of season 1 of Game of Thrones', 'media-runner series gameofthrones 101'
25
27
  c.action do |args|
26
- media = sanitize_args(args)
27
-
28
- unless series_exists?(media[:series])
29
- Media::Printer.output ["#{series_path(media[:series])} doesn't exist. Did you type the series name \
30
- correctly?"]
31
- exit 1
32
- end
33
-
34
- unless episode_exists?(media[:series], media[:episode])
35
- Media::Printer.output ["Episode #{media[:episode]} was not found in #{media[:series]}."]
36
- exit 1
37
- end
38
-
39
- format = episode_format(media[:series], media[:episode])
40
- vlc_installed?
28
+ attributes = sanitize_series_args(args)
29
+ episode = Episode.new(attributes[:series], attributes[:title])
30
+ episode.run
31
+ end
32
+ end
41
33
 
42
- Media::Printer.output ["Playing episode #{media[:episode]} from #{media[:series]}. ENJOY!"]
43
- `zsh -c "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC --fullscreen \
44
- #{episode_path(media[:series], media[:episode], format)} > /dev/null 2>&1 &!"`
45
- exit 0
34
+ command :movie do |c|
35
+ c.syntax = 'media-runner movie MOVIENAME'
36
+ c.summary = 'run a movie'
37
+ c.description = 'You can pass the name of a movie and run it with VLC.'
38
+ c.example 'Run The Great Gatsby', 'media-runner movie thegreatgatsby'
39
+ c.action do |args|
40
+ attributes = sanitize_movie_args(args)
41
+ movie = Movie.new(attributes[:title])
42
+ movie.run
46
43
  end
47
44
  end
48
45
  end
@@ -1,13 +1,24 @@
1
- require 'media/runner/printer'
2
-
3
1
  module ArgsSanitizer
4
- def sanitize_args(args)
2
+ # Series
3
+
4
+ def sanitize_series_args(args)
5
5
  if args.count != 2
6
6
  Media::Printer.output ['Wrong number of arguments.',
7
7
  'Correct usage: media-runner series SERIES_FOLDER_NAME EPISODE_NUMBER']
8
8
  exit 1
9
9
  else
10
- { series: args[0], episode: args[1] }
10
+ { series: args[0], title: args[1] }
11
+ end
12
+ end
13
+
14
+ # Movies
15
+
16
+ def sanitize_movie_args(args)
17
+ if args.count != 1
18
+ Media::Printer.output ['Wrong number of arguments.', 'Correct usage: media-runner movie MOVIE_NAME']
19
+ exit 1
20
+ else
21
+ { title: args[0] }
11
22
  end
12
23
  end
13
24
  end
@@ -1,26 +1,29 @@
1
- require 'media/runner/app/media_paths'
2
-
3
1
  module FileCheck
4
- extend MediaPaths
2
+ # Series
5
3
 
6
- def series_exists?(series)
7
- if File.directory? series_path(series)
4
+ def series_exists?(episode)
5
+ if File.directory? series_path(episode)
8
6
  true
9
7
  else
10
8
  false
11
9
  end
12
10
  end
13
11
 
14
- def episode_exists?(series, episode)
12
+ def episode_exists?(episode)
15
13
  [:mkv, :mp4, :avi].each do |format|
16
- return true if File.file? episode_path(series, episode, format)
14
+ episode.format = format
15
+ return true if File.file? episode_path(episode)
17
16
  end
18
17
  false
19
18
  end
20
19
 
21
- def episode_format(series, episode)
20
+ # Movies
21
+
22
+ def movie_exists?(movie)
22
23
  [:mkv, :mp4, :avi].each do |format|
23
- return format.to_s if File.file? episode_path(series, episode, format)
24
+ movie.format = format
25
+ return true if File.file? movie_path(movie)
24
26
  end
27
+ false
25
28
  end
26
29
  end
@@ -2,25 +2,29 @@ module MediaPaths
2
2
  SERIES_BASE = "#{Dir.home}/Movies/series".freeze
3
3
  MOVIES_BASE = "#{Dir.home}/Movies/movies".freeze
4
4
 
5
- def movie_path(movie)
6
- nil unless movie
7
- "#{MOVIES_BASE}/#{movie}"
8
- end
5
+ # Series
9
6
 
10
- def series_path(series)
11
- nil unless series
12
- "#{SERIES_BASE}/#{series}"
7
+ def series_path(episode)
8
+ nil unless episode
9
+ "#{SERIES_BASE}/#{episode.series}"
13
10
  end
14
11
 
15
- def episode_path(series, episode, format)
16
- nil unless series && episode && format
17
- "#{series_path(series)}/#{episode}.#{format}"
12
+ def episode_path(episode)
13
+ nil unless episode
14
+ "#{series_path(episode)}/#{episode.title}.#{episode.format}"
18
15
  end
19
16
 
20
17
  def series_base
21
18
  SERIES_BASE
22
19
  end
23
20
 
21
+ # Movies
22
+
23
+ def movie_path(movie)
24
+ nil unless movie
25
+ "#{MOVIES_BASE}/#{movie.title}.#{movie.format}"
26
+ end
27
+
24
28
  def movies_base
25
29
  MOVIES_BASE
26
30
  end
@@ -1,5 +1,3 @@
1
- require 'media/runner/printer'
2
-
3
1
  module VlcCheck
4
2
  def vlc_installed?
5
3
  install_vlc unless File.file? "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC"
@@ -0,0 +1,36 @@
1
+ require 'media/runner/app/file_check'
2
+ require 'media/runner/app/media_paths'
3
+ require 'media/runner/app/vlc_check'
4
+
5
+ module Media
6
+ class Episode
7
+ include FileCheck, VlcCheck, MediaPaths
8
+
9
+ def initialize(series, title, format = nil)
10
+ @series = series
11
+ @title = title
12
+ @format = format
13
+ end
14
+
15
+ attr_accessor :series, :title, :format
16
+
17
+ def run
18
+ vlc_installed?
19
+
20
+ unless series_exists?(self)
21
+ Media::Printer.output ["#{series_path(self)} doesn't exist. Did you type the series name correctly?"]
22
+ exit 1
23
+ end
24
+
25
+ unless episode_exists?(self)
26
+ Media::Printer.output ["Episode #{title} was not found in #{series}."]
27
+ exit 1
28
+ end
29
+
30
+ Media::Printer.output ["Playing episode #{title} from #{series}. ENJOY!"]
31
+ `zsh -c "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC --fullscreen #{episode_path(self)} > /dev/null \
32
+ 2>&1 &!"`
33
+ exit 0
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,30 @@
1
+ require 'media/runner/app/file_check'
2
+ require 'media/runner/app/media_paths'
3
+ require 'media/runner/app/vlc_check'
4
+
5
+ module Media
6
+ class Movie
7
+ include FileCheck, VlcCheck, MediaPaths
8
+
9
+ def initialize(title, format = nil)
10
+ @title = title
11
+ @format = format
12
+ end
13
+
14
+ attr_accessor :title, :format
15
+
16
+ def run
17
+ vlc_installed?
18
+
19
+ unless movie_exists?(self)
20
+ Media::Printer.output ["#{movie_path(self)} doesn't exist. Did you type the movie name correctly?"]
21
+ exit 1
22
+ end
23
+
24
+ Media::Printer.output ["Playing movie #{title}. ENJOY!"]
25
+ `zsh -c "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC --fullscreen #{movie_path(self)} > /dev/null \
26
+ 2>&1 &!"`
27
+ exit 0
28
+ end
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  module Media
2
2
  module Runner
3
- VERSION = '1.0.2'.freeze
3
+ VERSION = '1.0.3'.freeze
4
4
  end
5
5
  end
data/media-runner.gemspec CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Nicolas Eckhart']
10
10
  spec.email = ['nicolas.eckhart@renuo.ch']
11
11
 
12
- spec.summary = 'Simple ruby based command line interface for running movies, music, etc.'
13
- spec.description = 'Simple ruby based command line interface for running movies, music, etc.'
12
+ spec.summary = 'Simple ruby based command line interface for running movies, series, music, etc.'
13
+ spec.description = 'Simple ruby based command line interface for running movies, series, music, etc.'
14
14
  spec.homepage = 'https://www.github.com/nicolaseckhart/media_runner'
15
15
  spec.license = 'MIT'
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: media-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Eckhart
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-02 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -94,7 +94,8 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
- description: Simple ruby based command line interface for running movies, music, etc.
97
+ description: Simple ruby based command line interface for running movies, series,
98
+ music, etc.
98
99
  email:
99
100
  - nicolas.eckhart@renuo.ch
100
101
  executables:
@@ -122,6 +123,8 @@ files:
122
123
  - lib/media/runner/app/file_check.rb
123
124
  - lib/media/runner/app/media_paths.rb
124
125
  - lib/media/runner/app/vlc_check.rb
126
+ - lib/media/runner/episode.rb
127
+ - lib/media/runner/movie.rb
125
128
  - lib/media/runner/printer.rb
126
129
  - lib/media/runner/version.rb
127
130
  - media-runner.gemspec
@@ -148,5 +151,6 @@ rubyforge_project:
148
151
  rubygems_version: 2.6.3
149
152
  signing_key:
150
153
  specification_version: 4
151
- summary: Simple ruby based command line interface for running movies, music, etc.
154
+ summary: Simple ruby based command line interface for running movies, series, music,
155
+ etc.
152
156
  test_files: []