showfix 1.0.0
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.
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/CONTRIBUTING.md +13 -0
- data/Gemfile +3 -0
- data/LICENSE +19 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/bin/showfix +6 -0
- data/lib/showfix/cleaner.rb +83 -0
- data/lib/showfix/cli.rb +76 -0
- data/lib/showfix/episode.rb +74 -0
- data/lib/showfix/parser.rb +44 -0
- data/lib/showfix/version.rb +3 -0
- data/lib/showfix.rb +8 -0
- data/showfix.gemspec +31 -0
- data/spec/cleaner_spec.rb +33 -0
- data/spec/episode_spec.rb +42 -0
- data/spec/parser_spec.rb +64 -0
- data/spec/spec_helper.rb +21 -0
- metadata +151 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributing to Showfix
|
2
|
+
|
3
|
+
## Issues
|
4
|
+
|
5
|
+
Found a bug in Showfix? Open an issue on [GitHub Issues](https://github.com/webdestroya/showfix/issues).
|
6
|
+
|
7
|
+
## Pull requests
|
8
|
+
|
9
|
+
Ready to submit a pull request? Great! Contributions are most welcome. To get your contributions accepted, make sure:
|
10
|
+
|
11
|
+
* All the tests pass. Run `rspec`.
|
12
|
+
* No code quality warnings are generated by [RuboCop](https://github.com/bbatsov/rubocop). Run `rubocop`.
|
13
|
+
* Any new code paths you've added are covered by tests.
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Mitch Dempsey
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Showfix
|
2
|
+
|
3
|
+
|
4
|
+
[][gem]
|
5
|
+
[][travis]
|
6
|
+
[][gemnasium]
|
7
|
+
[][codeclimate]
|
8
|
+
[][coveralls]
|
9
|
+
|
10
|
+
[gem]: https://rubygems.org/gems/showfix
|
11
|
+
[travis]: https://travis-ci.org/webdestroya/showfix
|
12
|
+
[gemnasium]: https://gemnasium.com/webdestroya/showfix
|
13
|
+
[codeclimate]: https://codeclimate.com/github/webdestroya/showfix
|
14
|
+
[coveralls]: https://coveralls.io/r/webdestroya/showfix
|
15
|
+
|
16
|
+
## Description
|
17
|
+
|
18
|
+
This gem allows you to easily rename TV episode files. Useful for mass-renaming mismatched show titles.
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
```sh
|
24
|
+
$ gem install showfix
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
*TODO*
|
30
|
+
|
31
|
+
## Roadmap
|
32
|
+
|
33
|
+
* Support for multi-episode files (S01E20-E21)
|
34
|
+
* Ability to manually enter season/episode numbers for show files that are not numbered at all
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
See the [contribution guide](https://github.com/webdestroya/showfix/blob/master/CONTRIBUTING.md).
|
39
|
+
|
40
|
+
## Thanks
|
41
|
+
|
42
|
+
Special thanks to [Philipp Böhm](https://github.com/pboehm) for making [serienrenamer](https://github.com/pboehm/serienrenamer)
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/Rakefile
ADDED
data/bin/showfix
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module Showfix
|
2
|
+
class Cleaner
|
3
|
+
|
4
|
+
# http://en.wikipedia.org/wiki/Pirated_movie_release_types
|
5
|
+
|
6
|
+
AUDIO_FLAGS = %w(DD51 AC3 Dubbed DD20 Synced AAC DTS MP3).freeze
|
7
|
+
VIDEO_FLAGS = %w(1080p 720p XviD x264 h264 HDTV euHD PDTV HD Divx5).freeze
|
8
|
+
|
9
|
+
SOURCE_FLAGS = %w(
|
10
|
+
DVDRip HDTVRip HDRip SATRip BDRip iTunesHD WEBRiP BLURAYRiP BluRay
|
11
|
+
iTunesHDRip RiP WEB DL PublicHD CAMRip WP TC Telecine CAM TS PDVD
|
12
|
+
Telesync PPV PPVRip SCR SCREENER DVDSCR DDC R5 HDDVD DVDRips
|
13
|
+
).freeze
|
14
|
+
|
15
|
+
AUTHOR_FLAGS = %w(
|
16
|
+
inspired AMBiTiOUS SiGHT RiP iNTERNAL CRoW c0nFuSed UTOPiA scum EXPiRED
|
17
|
+
CRiSP ZZGtv ARCHiV Prim3time Nfo Repack SiMPTY DELiCiOUS UNDELiCiOUS
|
18
|
+
fBi CiD RedSeven OiNK dxva FraMeSToR CtrlHD LOL drngr PARADOX RELOADED
|
19
|
+
DIMENSION anoXmous YIFY KILLERS HiDt Z3R0K BiTT ViSiON KiNGDOM SPARKS
|
20
|
+
MVGroup JIVE RKSTR ESiR
|
21
|
+
).freeze
|
22
|
+
|
23
|
+
FLAGS = [AUDIO_FLAGS, VIDEO_FLAGS, SOURCE_FLAGS, AUTHOR_FLAGS].flatten.freeze
|
24
|
+
|
25
|
+
def initialize(options={})
|
26
|
+
@options = {
|
27
|
+
flags: true,
|
28
|
+
year: true
|
29
|
+
}.merge(options)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Perform some cleanup on the filename
|
33
|
+
def clean(string)
|
34
|
+
|
35
|
+
string = self.unix_friendly(string)
|
36
|
+
|
37
|
+
# Clean trailing/leading periods
|
38
|
+
string = self.trim(string)
|
39
|
+
|
40
|
+
if @options[:flags]
|
41
|
+
string = self.remove_flags(string)
|
42
|
+
end
|
43
|
+
|
44
|
+
if @options[:year]
|
45
|
+
string = self.strip_year(string)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Clean trailing/leading periods
|
49
|
+
string = self.trim(string)
|
50
|
+
|
51
|
+
string
|
52
|
+
end
|
53
|
+
|
54
|
+
def trim(string)
|
55
|
+
string.strip.gsub(/\A\.+|\.+\Z/, '')
|
56
|
+
end
|
57
|
+
|
58
|
+
# Make unix friendly
|
59
|
+
def unix_friendly(string)
|
60
|
+
string.gsub(/\s+-\s+/, '.')
|
61
|
+
.gsub(/[- \(\)]+/, '.')
|
62
|
+
.gsub(/'/,'')
|
63
|
+
.gsub(/[\[\]]+/,'')
|
64
|
+
.gsub(/&/,'.and.')
|
65
|
+
.gsub(/\.{2,}/,'.')
|
66
|
+
end
|
67
|
+
|
68
|
+
def remove_flags(string)
|
69
|
+
flags = FLAGS.join('|')
|
70
|
+
|
71
|
+
string.gsub(/(\W(#{flags})){2,}/i, '')
|
72
|
+
.gsub(/((#{flags})\W){2,}/i, '')
|
73
|
+
.gsub(/^((#{flags})\W?){2,}$/i, '')
|
74
|
+
.gsub(/\W(#{flags}){1,}$/i, '')
|
75
|
+
end
|
76
|
+
|
77
|
+
def strip_year(string)
|
78
|
+
string.gsub(/^(?:19|20)\d{2}\D/, '\1')
|
79
|
+
string.gsub(/(?:19|20)\d{2}$/, '\1')
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
data/lib/showfix/cli.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'showfix'
|
3
|
+
|
4
|
+
module Showfix
|
5
|
+
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "rename", "Rename TV show files in a directory"
|
9
|
+
method_option "directory", type: :string, banner: 'PATH', aliases: "-d",
|
10
|
+
default: ".",
|
11
|
+
desc: "Specify the directory to work in. If not specified, use the current directory."
|
12
|
+
method_option "season", type: :numeric, aliases: "-s",
|
13
|
+
banner: '1', desc: "The season/series number"
|
14
|
+
method_option "pretend", type: :boolean, lazy_default: true, default: false,
|
15
|
+
aliases: "-p", desc: "Do not rename files, only show outcome"
|
16
|
+
method_option 'strip-year', type: :boolean, lazy_default: true, default: false,
|
17
|
+
desc: 'Strip years from file names', aliases: '-y'
|
18
|
+
method_option 'clean', type: :boolean, lazy_default: true, default: true,
|
19
|
+
desc: "Strip encoding and resolution flags from filenames", aliases: '-c'
|
20
|
+
def rename
|
21
|
+
|
22
|
+
path = File.absolute_path(options['directory'])
|
23
|
+
|
24
|
+
if options['directory'] != "."
|
25
|
+
say "Scanning directory: #{path}"
|
26
|
+
say ""
|
27
|
+
end
|
28
|
+
|
29
|
+
episode_opts = {}
|
30
|
+
|
31
|
+
Dir["#{path}/*"].each do |file|
|
32
|
+
basename = File.basename(file)
|
33
|
+
episode = Showfix::Episode.new(basename, episode_opts)
|
34
|
+
|
35
|
+
if episode.acceptable_file?
|
36
|
+
|
37
|
+
unless episode.has_episode_info?
|
38
|
+
say "INPUT"
|
39
|
+
end
|
40
|
+
|
41
|
+
say "#{basename} => "
|
42
|
+
|
43
|
+
# If they fixed it
|
44
|
+
if episode.has_episode_info?
|
45
|
+
say "#{episode.to_formatted_s}"
|
46
|
+
|
47
|
+
unless options['pretend']
|
48
|
+
rename_file(file, episode.to_formatted_s)
|
49
|
+
end
|
50
|
+
|
51
|
+
else
|
52
|
+
say "SKIPPED"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def rename_file(source_path, dest_file)
|
62
|
+
raise IOError, 'source file not found' unless File.file?(source_path)
|
63
|
+
|
64
|
+
dest_path = File.join(File.dirname(source_path), dest_file)
|
65
|
+
|
66
|
+
raise IOError, 'destination already exists' if File.file?(dest_path)
|
67
|
+
|
68
|
+
begin
|
69
|
+
File.rename(source_path, dest_path)
|
70
|
+
rescue SystemCallError
|
71
|
+
puts "Unable to rename file #{File.basename(source_path)}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'showfix'
|
2
|
+
|
3
|
+
module Showfix
|
4
|
+
class Episode
|
5
|
+
|
6
|
+
# Video files, and some subtitles
|
7
|
+
VALID_EXTENSIONS = %w(avi mkv mp4 mpg mpeg mov m4v srt)
|
8
|
+
|
9
|
+
attr_accessor :season, :series, :episode, :title
|
10
|
+
attr_reader :filename, :options, :extension, :file_no_ext
|
11
|
+
|
12
|
+
def initialize(filename, options={})
|
13
|
+
|
14
|
+
raise ArgumentError, 'no filename' unless filename
|
15
|
+
|
16
|
+
@filename = filename
|
17
|
+
@options = {
|
18
|
+
season: nil
|
19
|
+
}.merge(options)
|
20
|
+
|
21
|
+
@cleaner = Cleaner.new(@options)
|
22
|
+
@parser = Parser.new(@options)
|
23
|
+
|
24
|
+
@season ||= options[:season] # if they passed in a default season
|
25
|
+
|
26
|
+
@file_no_ext = @filename.chomp(File.extname(@filename))
|
27
|
+
@extension = File.extname(@filename).gsub(/\./, '').downcase
|
28
|
+
|
29
|
+
self.update_episode_info
|
30
|
+
end
|
31
|
+
|
32
|
+
def skip?
|
33
|
+
!acceptable_file? || !has_episode_info?
|
34
|
+
end
|
35
|
+
|
36
|
+
def has_episode_info?
|
37
|
+
!@season.nil? && !@episode.nil? && @season.is_a?(Fixnum) && @episode.is_a?(Fixnum)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Determines if this is a file we should work with
|
41
|
+
def acceptable_file?
|
42
|
+
VALID_EXTENSIONS.include?(self.extension)
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def to_formatted_s
|
47
|
+
|
48
|
+
f_series = ""
|
49
|
+
if @series && @series.strip.size > 0
|
50
|
+
f_series = "#{@series.strip}."
|
51
|
+
end
|
52
|
+
|
53
|
+
f_title = ""
|
54
|
+
if @title && @title.strip.size > 0
|
55
|
+
f_title = ".#{@title.strip}"
|
56
|
+
end
|
57
|
+
|
58
|
+
"%sS%.2dE%.2d%s.%s" % [f_series, @season, @episode, f_title, @extension]
|
59
|
+
end
|
60
|
+
|
61
|
+
# Extract info from the filename, and update fields as necessary
|
62
|
+
def update_episode_info
|
63
|
+
info = @parser.parse(@file_no_ext)
|
64
|
+
|
65
|
+
if info
|
66
|
+
keys = info.names
|
67
|
+
@series ||= @cleaner.clean(info[:series]) if keys.include?('series')
|
68
|
+
@season ||= info[:season].to_i if keys.include?('season')
|
69
|
+
@episode ||= info[:episode].to_i if keys.include?('episode')
|
70
|
+
@title ||= @cleaner.clean(info[:title]) if keys.include?('title')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Showfix
|
2
|
+
class Parser
|
3
|
+
|
4
|
+
# matchData pre_match / post_match for getting data after the matched part
|
5
|
+
PATTERNS = [
|
6
|
+
# Show.Season.01.Episode.01.Title
|
7
|
+
/^(?<series>.*)(?:\.)?Season(?:\.)?(?<season>\d+)(?:\.)?Episode(?<episode>\d+)(?:\.)?(?<title>.*)$/i,
|
8
|
+
# Show.S01E01.Title ; Show.S01.E01.Title ; Show S01 E01 Title
|
9
|
+
/^(?<series>.*)(?:\.|\s+)?S(?<season>\d+)(?:\.|\s+)?E(?<episode>\d+)(?:\.|\s+)?(?<title>.*)$/i,
|
10
|
+
# 1x1; 12x12
|
11
|
+
/^(?<series>.*)(?:\.)?(?<season>\d+)x(?<episode>\d+)(?:\.)?(?<title>.*)$/,
|
12
|
+
# Show 01 - Title
|
13
|
+
/^(?<series>.*)\s+(?<episode>\d{1,2})\s+-\s+(?<title>.+)$/,
|
14
|
+
# [Show] 01 Episode
|
15
|
+
/(?<series>.*)\s*(?<episode>\d{1,2})\s+(?<title>.+)$/,
|
16
|
+
# 101; 1212
|
17
|
+
/^(?<series>.*\D)(?<season>\d+)(?<episode>\d{2})(?<title>\W*.*)$/,
|
18
|
+
|
19
|
+
# TERRIBLE ONES ------------------------------------------------
|
20
|
+
|
21
|
+
# ^101$
|
22
|
+
/^(?<season>\d+)(?<episode>\d{2})$/
|
23
|
+
|
24
|
+
].freeze
|
25
|
+
|
26
|
+
def initialize(options={})
|
27
|
+
@options = {}.merge(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Parse a given string and look for matches
|
31
|
+
def parse(string)
|
32
|
+
|
33
|
+
matches = PATTERNS.map do |pattern|
|
34
|
+
pattern.match(string)
|
35
|
+
end.compact
|
36
|
+
|
37
|
+
if matches.size > 0
|
38
|
+
matches.first
|
39
|
+
else
|
40
|
+
nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/showfix.rb
ADDED
data/showfix.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "showfix/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "showfix"
|
8
|
+
spec.version = Showfix::VERSION
|
9
|
+
spec.authors = ["Mitch Dempsey"]
|
10
|
+
spec.email = ["mrdempsey@gmail.com"]
|
11
|
+
spec.description = %q{A gem to easily rename TV show files.}
|
12
|
+
spec.summary = %q{A gem to easily rename TV show files.}
|
13
|
+
spec.homepage = "https://github.com/webdestroya/showfix"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.required_ruby_version = ">= 1.9.3"
|
22
|
+
|
23
|
+
spec.add_runtime_dependency "bundler", ">= 1.3"
|
24
|
+
spec.add_runtime_dependency "thor", ">= 0.18.1"
|
25
|
+
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec", ">= 3.0.0.beta1"
|
28
|
+
spec.add_development_dependency "simplecov"
|
29
|
+
spec.add_development_dependency "coveralls"
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Showfix::Cleaner do
|
4
|
+
|
5
|
+
let(:cleaner) { Showfix::Cleaner.new }
|
6
|
+
|
7
|
+
describe '#clean' do
|
8
|
+
it 'when'
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#unix_friendly' do
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#remove_flags' do
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#strip_year' do
|
20
|
+
it { expect(cleaner.strip_year("Castle.2009")).to eq("Castle.") }
|
21
|
+
it { expect(cleaner.strip_year("Castle.2009.Blah")).to eq("Castle.2009.Blah") }
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#trim' do
|
25
|
+
it { expect(cleaner.trim(".Something.")).to eq("Something") }
|
26
|
+
it { expect(cleaner.trim("..Something..")).to eq("Something") }
|
27
|
+
it { expect(cleaner.trim("Something")).to eq("Something") }
|
28
|
+
it { expect(cleaner.trim(" Something")).to eq("Something") }
|
29
|
+
it { expect(cleaner.trim(" Something ")).to eq("Something") }
|
30
|
+
it { expect(cleaner.trim("Something ")).to eq("Something") }
|
31
|
+
it { expect(cleaner.trim(".Something ")).to eq("Something") }
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
|
4
|
+
describe Showfix::Episode do
|
5
|
+
|
6
|
+
describe '#skip?' do
|
7
|
+
it { expect(Showfix::Episode.new("Something.avi").skip?).to be(true) }
|
8
|
+
it { expect(Showfix::Episode.new("Something.txt").skip?).to be(true) }
|
9
|
+
it { expect(Showfix::Episode.new("S01E01.txt").skip?).to be(true) }
|
10
|
+
|
11
|
+
it { expect(Showfix::Episode.new("S01E01.avi").skip?).to be(false) }
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#acceptable_file?" do
|
15
|
+
it 'allows correct filetypes' do
|
16
|
+
%w(avi mkv mp4 mpg mpeg mov m4v srt).each do |ext|
|
17
|
+
expect(Showfix::Episode.new("something.#{ext}").acceptable_file?).to be(true)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'blocks incorrect filetypes' do
|
22
|
+
%w(nfo sfx rar txt url).each do |ext|
|
23
|
+
expect(Showfix::Episode.new("something.#{ext}").acceptable_file?).to be(false)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#has_episode_info?' do
|
29
|
+
let(:valid) { Showfix::Episode.new("Series.S01E01.Title.mkv") }
|
30
|
+
let(:invalid) { Showfix::Episode.new("Series.Title.mkv") }
|
31
|
+
it { expect(valid.has_episode_info?).to be(true) }
|
32
|
+
it { expect(invalid.has_episode_info?).to be(false) }
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
describe '#to_formatted_s' do
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#rename'
|
41
|
+
|
42
|
+
end
|
data/spec/parser_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper.rb'
|
2
|
+
|
3
|
+
describe Showfix::Parser do
|
4
|
+
let(:parser) { Showfix::Parser.new }
|
5
|
+
|
6
|
+
describe '#parse' do
|
7
|
+
|
8
|
+
it 'matches season and episode' do
|
9
|
+
[
|
10
|
+
"The Adventures of Brisco County Jr - 1x03 - No Man's Land (DVDRip)",
|
11
|
+
"1x03 Redux-1",
|
12
|
+
"Friends.s01.e03.1994.BDRip.1080p.Ukr.Eng.AC3.Hurtom.TNU.Tenax555",
|
13
|
+
"ER.S01E03.Going.Home.720p.WEB-DL.AAC.2.0.h.264-TjHD",
|
14
|
+
"1966-09-22 - TOS S01 E03 - Mudds Women",
|
15
|
+
"Dexter.S01E03.2006.Bluray.1080p.DTS.x264.dxva-FraMeSToR",
|
16
|
+
"Doctor.Who.2005.S01E03.The.Unquiet.Dead",
|
17
|
+
"Columbo.S01E03.1971.Death.Lends.a.Hand.720p.BluRay",
|
18
|
+
"Law.&.Order 1x03 The Reapers Helper",
|
19
|
+
"Law & Order - 1x03 - Reapers Helper [PDTV-drngr]",
|
20
|
+
"Law & Order - s01e03 - Refuge 2",
|
21
|
+
"LawandOrder.CI.2001.1x03.DVDRip.MP3-MrD",
|
22
|
+
"Law.and.Order.LA.S01E03.HDTV.XviD-LOL",
|
23
|
+
"law.and.order.svu.103.dvdrip",
|
24
|
+
"law.and.order.svu.103-caph",
|
25
|
+
"The Universe S01E03 The End of the Earth.1080p.BluRay.x264-CtrlHD",
|
26
|
+
"Stargate SG-1 [1x03] Emancipation",
|
27
|
+
"The.Office.US.S01.E03.Title.720p.WEB-DL",
|
28
|
+
"S01E03",
|
29
|
+
"103",
|
30
|
+
"1x03",
|
31
|
+
"0103",
|
32
|
+
].each do |file|
|
33
|
+
match = parser.parse(file)
|
34
|
+
expect(match).to_not be_nil
|
35
|
+
|
36
|
+
expect(match[:season]).to match(/^0?1$/)
|
37
|
+
expect(match[:episode]).to match(/^0?3$/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'matches series name'
|
42
|
+
|
43
|
+
it 'matches title'
|
44
|
+
|
45
|
+
it 'matches series and title'
|
46
|
+
|
47
|
+
it 'matches all info'
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
# Law.and.Order.S20E21-E22.HDTV.XviD-NoTV.avi
|
52
|
+
# Stargate SG-1 [8x01-02] New Order Part 1 and Part 2.avi
|
53
|
+
# Stargate SG-1 [7x21-22] Lost City Part 1 and Part 2.avi
|
54
|
+
|
55
|
+
# law.and.order.1702.hdtv-lol.avi
|
56
|
+
# law.and.order.svu.901-caph.avi
|
57
|
+
# law.and.order.svu.906-caph.[VTV].avi
|
58
|
+
# law.and.order.svu.0910-yestv.avi
|
59
|
+
# law.and.order.svu.813.Loophole.avi
|
60
|
+
# 615.Hooked.avi
|
61
|
+
# s06e01.mkv
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
require "coveralls"
|
3
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
4
|
+
SimpleCov::Formatter::HTMLFormatter,
|
5
|
+
Coveralls::SimpleCov::Formatter
|
6
|
+
]
|
7
|
+
SimpleCov.start { add_filter "/spec/" }
|
8
|
+
|
9
|
+
require "pry"
|
10
|
+
require "showfix"
|
11
|
+
require "showfix/cli"
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
config.mock_with :rspec do |mocks_config|
|
15
|
+
mocks_config.verify_doubled_constant_names = true
|
16
|
+
# Enable config option this when a new rspec-mocks beta including this patch is released:
|
17
|
+
# https://github.com/rspec/rspec-mocks/pull/466
|
18
|
+
#
|
19
|
+
# mocks_config.verify_partial_doubles = true
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: showfix
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mitch Dempsey
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &2153642240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2153642240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thor
|
27
|
+
requirement: &2153640440 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.18.1
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2153640440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &2153639380 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2153639380
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &2153637980 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0.beta1
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2153637980
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
requirement: &2153636460 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2153636460
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: &2153651980 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2153651980
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: pry
|
82
|
+
requirement: &2153649840 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2153649840
|
91
|
+
description: A gem to easily rename TV show files.
|
92
|
+
email:
|
93
|
+
- mrdempsey@gmail.com
|
94
|
+
executables:
|
95
|
+
- showfix
|
96
|
+
extensions: []
|
97
|
+
extra_rdoc_files: []
|
98
|
+
files:
|
99
|
+
- .gitignore
|
100
|
+
- .rspec
|
101
|
+
- .travis.yml
|
102
|
+
- CONTRIBUTING.md
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- bin/showfix
|
108
|
+
- lib/showfix.rb
|
109
|
+
- lib/showfix/cleaner.rb
|
110
|
+
- lib/showfix/cli.rb
|
111
|
+
- lib/showfix/episode.rb
|
112
|
+
- lib/showfix/parser.rb
|
113
|
+
- lib/showfix/version.rb
|
114
|
+
- showfix.gemspec
|
115
|
+
- spec/cleaner_spec.rb
|
116
|
+
- spec/episode_spec.rb
|
117
|
+
- spec/parser_spec.rb
|
118
|
+
- spec/spec_helper.rb
|
119
|
+
homepage: https://github.com/webdestroya/showfix
|
120
|
+
licenses:
|
121
|
+
- MIT
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.9.3
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
segments:
|
139
|
+
- 0
|
140
|
+
hash: -3802511965446294085
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 1.8.15
|
144
|
+
signing_key:
|
145
|
+
specification_version: 3
|
146
|
+
summary: A gem to easily rename TV show files.
|
147
|
+
test_files:
|
148
|
+
- spec/cleaner_spec.rb
|
149
|
+
- spec/episode_spec.rb
|
150
|
+
- spec/parser_spec.rb
|
151
|
+
- spec/spec_helper.rb
|