media-runner 1.0.0 → 1.0.2
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 +4 -4
- data/.rubocop.yml +6 -1
- data/.travis.yml +18 -0
- data/README.md +2 -2
- data/bin/check +15 -0
- data/bin/setup +12 -5
- data/exe/media-runner +0 -0
- data/lib/media/runner.rb +8 -8
- data/lib/media/runner/app/args_sanitizer.rb +4 -2
- data/lib/media/runner/app/file_check.rb +3 -7
- data/lib/media/runner/app/media_paths.rb +11 -7
- data/lib/media/runner/app/vlc_check.rb +6 -9
- data/lib/media/runner/printer.rb +7 -0
- data/lib/media/runner/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0234ad2c2f19583b5a0c98f95d4d52f61bfe1422
|
4
|
+
data.tar.gz: e79f9f0015b1357e9c946d27a9988b6a376888f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7f77c4ad1226eec9d3bb7371c3840d1a7facacba784f9b8879ce6af1e93f520772403d178bc4e5f64b38cec69062a73831dee69d5e0a0f537e146ecff0dbca7
|
7
|
+
data.tar.gz: 6abc7ca7618017af2b60923fcfed70ef4703b6ba8176ac8c7b28cb132f0fb3296e9edfbdcffc6d38410f0845c4e763234a27819faf93760025404e4793c9a0df
|
data/.rubocop.yml
CHANGED
@@ -4,6 +4,12 @@ AllCops:
|
|
4
4
|
Metrics/LineLength:
|
5
5
|
Max: 120
|
6
6
|
|
7
|
+
Metrics/AbcSize:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Enabled: false
|
12
|
+
|
7
13
|
Style/Documentation:
|
8
14
|
Enabled: false
|
9
15
|
|
@@ -21,4 +27,3 @@ AllCops:
|
|
21
27
|
- '*.gemspec'
|
22
28
|
Exclude:
|
23
29
|
- 'bin/**/*'
|
24
|
-
- 'lib/renuo/cli.rb'
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
addons:
|
2
|
+
apt:
|
3
|
+
packages:
|
4
|
+
- zsh
|
5
|
+
language: ruby
|
6
|
+
cache:
|
7
|
+
bundler: true
|
8
|
+
apt: true
|
9
|
+
before_install:
|
10
|
+
- export TZ=Europe/Zurich
|
11
|
+
before_script:
|
12
|
+
- export DISPLAY=:99.0
|
13
|
+
- sh -e /etc/init.d/xvfb start
|
14
|
+
script: bin/setup
|
15
|
+
notifications:
|
16
|
+
email:
|
17
|
+
on_success: never
|
18
|
+
on_failure: never
|
data/README.md
CHANGED
@@ -22,11 +22,11 @@ media-runner series gameofthrones 101
|
|
22
22
|
|
23
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.
|
24
24
|
|
25
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
25
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
26
26
|
|
27
27
|
## Contributing
|
28
28
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/nicolaseckhart/
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nicolaseckhart/media-runner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
30
30
|
|
31
31
|
## License
|
32
32
|
|
data/bin/check
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
source ~/.zshrc
|
4
|
+
|
5
|
+
bundle exec rubocop -c .rubocop.yml
|
6
|
+
if [ ! $? -eq 0 ]; then
|
7
|
+
echo 'rubocop detected issues!'
|
8
|
+
exit 1
|
9
|
+
fi
|
10
|
+
|
11
|
+
bundle exec rake spec
|
12
|
+
if [ ! $? -eq 0 ]; then
|
13
|
+
echo 'rspec did not run successfully, commit aborted'
|
14
|
+
exit 1
|
15
|
+
fi
|
data/bin/setup
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
5
3
|
|
6
|
-
|
4
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
5
|
+
|
6
|
+
Dir.chdir APP_ROOT do
|
7
|
+
puts '== Installing dependencies =='
|
8
|
+
system 'gem install bundler --conservative'
|
9
|
+
system 'bundle check || bundle install --jobs=3 --retry=3'
|
10
|
+
|
11
|
+
puts "\n== Running checks =="
|
12
|
+
system 'bundle exec rake spec'
|
13
|
+
end
|
data/exe/media-runner
CHANGED
File without changes
|
data/lib/media/runner.rb
CHANGED
@@ -6,13 +6,11 @@ require 'media/runner/app/args_sanitizer'
|
|
6
6
|
require 'media/runner/app/file_check'
|
7
7
|
require 'media/runner/app/media_paths'
|
8
8
|
require 'media/runner/app/vlc_check'
|
9
|
+
require 'media/runner/printer'
|
9
10
|
|
10
11
|
module Media
|
11
12
|
class Run
|
12
|
-
include ArgsSanitizer
|
13
|
-
include FileCheck
|
14
|
-
include VlcCheck
|
15
|
-
include MediaPaths
|
13
|
+
include ArgsSanitizer, FileCheck, VlcCheck, MediaPaths
|
16
14
|
|
17
15
|
def start
|
18
16
|
require 'commander/import'
|
@@ -28,20 +26,22 @@ module Media
|
|
28
26
|
media = sanitize_args(args)
|
29
27
|
|
30
28
|
unless series_exists?(media[:series])
|
31
|
-
|
29
|
+
Media::Printer.output ["#{series_path(media[:series])} doesn't exist. Did you type the series name \
|
30
|
+
correctly?"]
|
32
31
|
exit 1
|
33
32
|
end
|
34
33
|
|
35
34
|
unless episode_exists?(media[:series], media[:episode])
|
36
|
-
|
35
|
+
Media::Printer.output ["Episode #{media[:episode]} was not found in #{media[:series]}."]
|
37
36
|
exit 1
|
38
37
|
end
|
39
38
|
|
40
39
|
format = episode_format(media[:series], media[:episode])
|
41
40
|
vlc_installed?
|
42
41
|
|
43
|
-
|
44
|
-
`zsh -c "
|
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
45
|
exit 0
|
46
46
|
end
|
47
47
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'media/runner/printer'
|
2
|
+
|
1
3
|
module ArgsSanitizer
|
2
4
|
def sanitize_args(args)
|
3
5
|
if args.count != 2
|
4
|
-
|
5
|
-
|
6
|
+
Media::Printer.output ['Wrong number of arguments.',
|
7
|
+
'Correct usage: media-runner series SERIES_FOLDER_NAME EPISODE_NUMBER']
|
6
8
|
exit 1
|
7
9
|
else
|
8
10
|
{ series: args[0], episode: args[1] }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'media/runner/app/media_paths'
|
2
2
|
|
3
3
|
module FileCheck
|
4
|
-
|
4
|
+
extend MediaPaths
|
5
5
|
|
6
6
|
def series_exists?(series)
|
7
7
|
if File.directory? series_path(series)
|
@@ -13,18 +13,14 @@ module FileCheck
|
|
13
13
|
|
14
14
|
def episode_exists?(series, episode)
|
15
15
|
[:mkv, :mp4, :avi].each do |format|
|
16
|
-
if File.file? episode_path(series, episode, format)
|
17
|
-
return true
|
18
|
-
end
|
16
|
+
return true if File.file? episode_path(series, episode, format)
|
19
17
|
end
|
20
18
|
false
|
21
19
|
end
|
22
20
|
|
23
21
|
def episode_format(series, episode)
|
24
22
|
[:mkv, :mp4, :avi].each do |format|
|
25
|
-
if File.file? episode_path(series, episode, format)
|
26
|
-
return "#{format}"
|
27
|
-
end
|
23
|
+
return format.to_s if File.file? episode_path(series, episode, format)
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -1,10 +1,6 @@
|
|
1
|
-
require 'media/runner/app/vlc_check'
|
2
|
-
|
3
1
|
module MediaPaths
|
4
|
-
|
5
|
-
|
6
|
-
SERIES_BASE = "/Users/#{whoami}/Movies/series"
|
7
|
-
MOVIES_BASE = "/Users/#{whoami}/Movies/movies"
|
2
|
+
SERIES_BASE = "#{Dir.home}/Movies/series".freeze
|
3
|
+
MOVIES_BASE = "#{Dir.home}/Movies/movies".freeze
|
8
4
|
|
9
5
|
def movie_path(movie)
|
10
6
|
nil unless movie
|
@@ -17,7 +13,15 @@ module MediaPaths
|
|
17
13
|
end
|
18
14
|
|
19
15
|
def episode_path(series, episode, format)
|
20
|
-
nil unless series
|
16
|
+
nil unless series && episode && format
|
21
17
|
"#{series_path(series)}/#{episode}.#{format}"
|
22
18
|
end
|
19
|
+
|
20
|
+
def series_base
|
21
|
+
SERIES_BASE
|
22
|
+
end
|
23
|
+
|
24
|
+
def movies_base
|
25
|
+
MOVIES_BASE
|
26
|
+
end
|
23
27
|
end
|
@@ -1,17 +1,14 @@
|
|
1
|
+
require 'media/runner/printer'
|
2
|
+
|
1
3
|
module VlcCheck
|
2
4
|
def vlc_installed?
|
3
|
-
unless File.file? "
|
4
|
-
install_vlc
|
5
|
-
end
|
5
|
+
install_vlc unless File.file? "#{Dir.home}/Applications/VLC.app/Contents/MacOS/VLC"
|
6
6
|
end
|
7
7
|
|
8
8
|
def install_vlc
|
9
|
-
|
10
|
-
|
9
|
+
Media::Printer.output ['VLC media player is not installed on your system. Make sure you have homebrew and \
|
10
|
+
brew-cask installed, and then run the following command:',
|
11
|
+
'brew cask install vlc']
|
11
12
|
exit 1
|
12
13
|
end
|
13
|
-
|
14
|
-
def whoami
|
15
|
-
`whoami`.gsub(/\n/, '')
|
16
|
-
end
|
17
14
|
end
|
data/lib/media/runner/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.2
|
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-
|
11
|
+
date: 2016-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -107,11 +107,13 @@ files:
|
|
107
107
|
- ".rspec"
|
108
108
|
- ".rubocop.yml"
|
109
109
|
- ".ruby-version"
|
110
|
+
- ".travis.yml"
|
110
111
|
- CODE_OF_CONDUCT.md
|
111
112
|
- Gemfile
|
112
113
|
- LICENSE.txt
|
113
114
|
- README.md
|
114
115
|
- Rakefile
|
116
|
+
- bin/check
|
115
117
|
- bin/console
|
116
118
|
- bin/setup
|
117
119
|
- exe/media-runner
|
@@ -120,6 +122,7 @@ files:
|
|
120
122
|
- lib/media/runner/app/file_check.rb
|
121
123
|
- lib/media/runner/app/media_paths.rb
|
122
124
|
- lib/media/runner/app/vlc_check.rb
|
125
|
+
- lib/media/runner/printer.rb
|
123
126
|
- lib/media/runner/version.rb
|
124
127
|
- media-runner.gemspec
|
125
128
|
homepage: https://www.github.com/nicolaseckhart/media_runner
|