movie_organizer 0.1.10 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a28b7b48ec7f557670cc640b987534dba854888ecb6fa82652edb99af1999e61
4
- data.tar.gz: 6274d25406a319fb04e31c599b17941d5d9b860fa55752f38db5296e375f7913
3
+ metadata.gz: 3e79b66679e3034ba041b6a74648f9588579e177bb6aeeba31f6ea4dc55648ec
4
+ data.tar.gz: e01ff240650b55d4237431b30fb1988ffb640a129fa5261448ab0dd4fee6add7
5
5
  SHA512:
6
- metadata.gz: aa2d1fff8f2f40c78d3c661261cae8aa292b0f703ca46c75fafd302be6d81f7a1374eebb8a58b4c54162c64b2734168c9f889d7628ed05d9edca96bfd8dd100c
7
- data.tar.gz: 55b058b03139ae43e85e1c81b99ecaafaa546a54a0a880d92cce972457510af6e8fcd2b95bca8e860cf4b0dfb3c2a50b3642fa6c73eb2e0f77a8094bb1c8726f
6
+ metadata.gz: f52967cf08b3d97695c63960cea76713ac99d55154ffe8c9674153a9a5907ed1057e676fce98169ff76c4a84353ee1185bfb8a3d3f28779d0342135aa087cb10
7
+ data.tar.gz: 245370271ea233c8c3f43da77860534b5b6527dcd835238454fddcfcf45233f6cf9345b2e078b2b4603aeb421dc2fc7bb21bf89e14fd64cf33d4ddfb586700a6
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ *0.1.11* (March 27, 2018)
2
+
3
+ * Fix bug where it wouldn't always autoload net-scp.
4
+ * Search directory name if a movie filename has no year embedded in it.
5
+ * Allow TV Shows to be copied to remote servers using SCP.
6
+
1
7
  *0.1.10* (March 14, 2018)
2
8
 
3
9
  * Strip 'WebRip' from filenames
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'net/scp'
4
+
3
5
  module MovieOrganizer
4
6
  class FileCopier
5
7
  attr_accessor :filename, :target_file, :options
@@ -40,7 +40,8 @@ module MovieOrganizer
40
40
  return @movie unless @movie.nil?
41
41
  @movie = false
42
42
  Tmdb::Api.key(MovieOrganizer.tmdb_key)
43
- title = sanitize(File.basename(filename, ext)).gsub(/\d\d\d\d/, '').strip
43
+ # Remove the year and sanitize
44
+ title = sanitize(File.basename(filename, ext)).gsub(/[\s\.\-\_]\(?\d\d\d\d\)?/, '').strip
44
45
  matches = Tmdb::Movie.find(title)
45
46
  @movie = matches.any?
46
47
  @movie
@@ -48,6 +49,8 @@ module MovieOrganizer
48
49
 
49
50
  def year
50
51
  md = basename.match(/\((\d\d\d\d)\)|(19\d\d)|(20\d\d)/)
52
+ # try dirname if filename has no year
53
+ md = dirname.match(/\((\d\d\d\d)\)|(19\d\d)|(20\d\d)/) if md.nil?
51
54
  md ? md.captures.compact.first : nil
52
55
  end
53
56
 
@@ -61,6 +64,10 @@ module MovieOrganizer
61
64
  File.extname(filename)
62
65
  end
63
66
 
67
+ def dirname
68
+ File.dirname(filename)
69
+ end
70
+
64
71
  def verbose?
65
72
  options[:verbose]
66
73
  end
@@ -70,26 +77,34 @@ module MovieOrganizer
70
77
  end
71
78
 
72
79
  # rubocop:disable Metrics/AbcSize
80
+ # rubocop:disable Metrics/MethodLength
73
81
  def sanitize(str)
74
82
  cleanstr = str.gsub(/-\s*-/, '')
75
83
  cleanstr = cleanstr.gsub(/\[?1080p\]?/, '').strip
76
- cleanstr = cleanstr.gsub(/\[?720p\]?/, '').strip
84
+ cleanstr = cleanstr.gsub(/m?\[?720p\]?/, '').strip
77
85
  cleanstr = cleanstr.gsub(/\[[^\]]+\]/, '').strip
78
86
  cleanstr = cleanstr.gsub(/EXTENDED/, '').strip
79
87
  cleanstr = cleanstr.gsub(/YIFY/, '').strip
80
88
  cleanstr = cleanstr.gsub(/VPPV/, '').strip
81
89
  cleanstr = cleanstr.gsub(/BluRay/i, '').strip
82
90
  cleanstr = cleanstr.gsub(/BrRip/i, '').strip
91
+ cleanstr = cleanstr.gsub(/[\s\.]Br[\s\.]?/i, '').strip
92
+ cleanstr = cleanstr.gsub(/BdRip/i, '').strip
83
93
  cleanstr = cleanstr.gsub(/ECI/i, '').strip
84
94
  cleanstr = cleanstr.gsub(/HDTV/i, '').strip
85
95
  cleanstr = cleanstr.gsub(/WEBRip/i, '').strip
86
96
  cleanstr = cleanstr.gsub(/x264/, '').strip
97
+ cleanstr = cleanstr.gsub(/AAC/, '').strip
87
98
  cleanstr = cleanstr.gsub(/-lol/i, '').strip
99
+ cleanstr = cleanstr.gsub(/\+HI/i, '').strip
100
+ cleanstr = cleanstr.gsub(/muxed/i, '').strip
101
+ cleanstr = cleanstr.gsub(/\d\d\d+mb/i, '').strip
88
102
  # cleanstr = cleanstr.gsub(/[\.\s-]us[\.\s-]/i, ' ').strip
89
103
  cleanstr = cleanstr.gsub(/-\s*/, '').strip
90
104
  cleanstr = cleanstr.gsub(/\s\s+/, ' ').strip
91
105
  cleanstr.gsub(/[\.\+]/, ' ').strip
92
106
  end
107
+ # rubocop:enable Metrics/MethodLength
93
108
  # rubocop:enable Metrics/AbcSize
94
109
  end
95
110
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MovieOrganizer
2
4
  class TvShow < Media
3
5
  S_E_EXPRESSIONS = [
@@ -24,13 +26,9 @@ module MovieOrganizer
24
26
  "Season #{season.sub(/^0+/, '')}"
25
27
  )
26
28
  target_file = File.join(target_dir, processed_filename)
27
- logger.info(" target dir: [#{target_dir}]")
28
29
  logger.info(" target file: [#{target_file.green.bold}]")
29
- FileUtils.move(
30
- filename,
31
- target_file,
32
- force: true, noop: dry_run?
33
- )
30
+ fc = FileCopier.new(filename, target_file, options)
31
+ fc.copy
34
32
  rescue ArgumentError => err
35
33
  raise err unless err.message =~ /^same file:/
36
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MovieOrganizer
4
- VERSION = '0.1.10'.freeze
4
+ VERSION = '0.1.11'.freeze
5
5
  end
@@ -11,8 +11,9 @@ module MovieOrganizer
11
11
  name: 'Coco (2017).mp4'
12
12
  },
13
13
  'Beetlejuice' => {
14
- year: nil,
15
- name: 'Beetlejuice ().mp4'
14
+ directory: 'Beetlejuice (1995)',
15
+ year: '1995',
16
+ name: 'Beetlejuice (1995).mp4'
16
17
  },
17
18
  'Justice.League.2017.1080p.BluRay.x264-[YTS.AM]' => {
18
19
  year: '2017',
@@ -21,13 +22,40 @@ module MovieOrganizer
21
22
  'Jumanji.Welcome.To.The.Jungle.2017.1080p.WEBRip.x264-[YTS.AM]' => {
22
23
  year: '2017',
23
24
  name: 'Jumanji Welcome To The Jungle (2017).mp4'
25
+ },
26
+ 'The.Prestige.2006.m720p.x264' => {
27
+ year: '2006',
28
+ name: 'The Prestige (2006).mp4'
29
+ },
30
+ 'Gone.in.Sixty.Seconds.2000.720p.BrRip.x264.YIFY+HI' => {
31
+ year: '2000',
32
+ name: 'Gone in Sixty Seconds (2000).mp4'
33
+ },
34
+ 'Rain.Man.Br.YIFY' => {
35
+ directory: 'Rain Man (2000)',
36
+ year: '2000',
37
+ name: 'Rain Man (2000).mp4'
38
+ },
39
+ 'Stealth (2005) BDRip 720p x264-muxed' => {
40
+ year: '2005',
41
+ name: 'Stealth (2005).mp4'
42
+ },
43
+ 'The.Train.Robbers.1973.720p.BluRay.x264.YIFY' => {
44
+ year: '1973',
45
+ name: 'The Train Robbers (1973).mp4'
46
+ },
47
+ 'waterhorse720p.x264' => {
48
+ year: '2007',
49
+ directory: 'The Water Horse (2007)',
50
+ name: 'The Water Horse (2007)'
24
51
  }
25
52
  }
26
53
 
27
54
  movies.each_pair do |filename, data|
28
55
  context filename do
29
56
  before(:each) do
30
- @filepath = create_test_file(filename: filename, extension: 'mp4').first
57
+ dirname = MovieOrganizer.root.join('tmp', data.fetch(:directory, ''))
58
+ @filepath = create_test_file(filename: filename, extension: 'mp4', dirname: dirname).first
31
59
  @expected_filename = data[:name]
32
60
  @expected_year = data[:year]
33
61
  @movie = Movie.new(@filepath, default_options)
@@ -32,11 +32,13 @@ shared_context 'media_shared' do
32
32
  tvshow = options.fetch(:tvshow, true)
33
33
  count = options.fetch(:count, 1)
34
34
  filename = options.fetch(:filename, false)
35
+ dirname = options.fetch(:dirname, tmpdir)
35
36
  extension = options.fetch(:extension, 'mp4')
36
37
  files = []
37
38
 
38
39
  if filename
39
- files = [File.join(tmpdir, "#{filename}.#{extension}")]
40
+ files = [File.join(dirname, "#{filename}.#{extension}")]
41
+ FileUtils.mkdir_p(dirname)
40
42
  File.open(files.last, 'w') { |f| f.write("Fake Media File\n") }
41
43
  else
42
44
  count.times do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: movie_organizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Blackburn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler