mvtk 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/exe/mvtk +5 -1
- data/lib/mvtk/config.rb +2 -0
- data/lib/mvtk/proceed.rb +27 -0
- data/lib/mvtk/search.rb +1 -1
- data/lib/mvtk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac09c4c4941161ab8b8441830515777a84db4c9
|
4
|
+
data.tar.gz: f22be28bdfe58fdb9f6e1c17addc2f3890ac6194
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb8859644cfc664fb1123842cf3e89d219603df4c59ce04213b43b2357bc3b808339411163f3ba00dbffe9fc038f27b57667f8eee0d8a2393e119786076ae2ad
|
7
|
+
data.tar.gz: 111448e55ffcc999cb8391a7c8bea0fd6148b0f5e0215dd09ce28605130939e8c2407c46bb6c032902a7985faa676e1b0a0f5efd8da26e156a910393a4fc12da
|
data/README.md
CHANGED
@@ -26,7 +26,8 @@ Edit **~/.config/mvtk.conf**
|
|
26
26
|
* *target* = directory to copy movie with right name
|
27
27
|
* *windows_name* = make created file and folder Microsoft Windows compatible (some characters replace witch _ )
|
28
28
|
* *min_movie_time* = Minimum number of minutes to determine if the video file is a movie or a tvshow
|
29
|
-
|
29
|
+
* *year_in_filename* = Allows you to have the year in the filename e.g. "Up (2009)/Up (2009).mkv"
|
30
|
+
* *move_files* = If set true , move instead copy files
|
30
31
|
|
31
32
|
|
32
33
|
## Usage
|
data/exe/mvtk
CHANGED
@@ -39,7 +39,11 @@ puts "Processing #{process_hash.length} file(s)"
|
|
39
39
|
counter = 0
|
40
40
|
process_hash.each do |source, destination|
|
41
41
|
puts ""
|
42
|
-
|
42
|
+
if $conf["move_files"]
|
43
|
+
Mvtk.move(source, destination)
|
44
|
+
else
|
45
|
+
Mvtk.copy(source, destination)
|
46
|
+
end
|
43
47
|
counter = counter + 1
|
44
48
|
remain = process_hash.length - counter
|
45
49
|
if remain != 0 then
|
data/lib/mvtk/config.rb
CHANGED
data/lib/mvtk/proceed.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'ruby-progressbar'
|
2
2
|
require 'filesize'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
module Mvtk
|
5
6
|
|
@@ -9,7 +10,11 @@ module Mvtk
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.fulldest(source, destination)
|
13
|
+
if destination.nil?
|
14
|
+
return nil
|
15
|
+
end
|
12
16
|
movie_file = "#{destination.split('/')[0][0..-8]}#{File.extname(source)}"
|
17
|
+
movie_file = "#{destination.split('/')[0]}#{File.extname(source)}" if $conf["year_in_filename"]
|
13
18
|
movie_file = self.winname(movie_file) if $conf["windows_name"]
|
14
19
|
movie_dir = destination.split('/')[0]
|
15
20
|
movie_dir = self.winname(movie_dir) if $conf["windows_name"]
|
@@ -49,6 +54,9 @@ module Mvtk
|
|
49
54
|
|
50
55
|
def self.copy(source, destination)
|
51
56
|
finalpath = self.fulldest(source, destination)
|
57
|
+
if finalpath.nil?
|
58
|
+
return
|
59
|
+
end
|
52
60
|
puts "Source => #{File::basename(source)}"
|
53
61
|
puts "Target => #{finalpath.sub($conf["target"]+"/","")}"
|
54
62
|
puts "Size => #{Filesize.from(File.size(source).to_s + "B").pretty}"
|
@@ -57,4 +65,23 @@ module Mvtk
|
|
57
65
|
FileUtils.mkdir_p File.dirname(finalpath) unless File.directory?(File.dirname(finalpath))
|
58
66
|
self.copy_progressbar(source, finalpath)
|
59
67
|
end
|
68
|
+
|
69
|
+
def self.move(source, destination)
|
70
|
+
finalpath = self.fulldest(source, destination)
|
71
|
+
if finalpath.nil?
|
72
|
+
return
|
73
|
+
end
|
74
|
+
finaldir = finalpath.split('/')[0..-2].join('/')
|
75
|
+
sourcedir = File.dirname(source)
|
76
|
+
|
77
|
+
FileUtils.mkdir_p finaldir
|
78
|
+
FileUtils.mv(source, finalpath)
|
79
|
+
|
80
|
+
todelete = Pathname.new(sourcedir).cleanpath
|
81
|
+
sourcefiles = Pathname.new($conf["source"]).cleanpath
|
82
|
+
|
83
|
+
unless todelete == sourcefiles
|
84
|
+
FileUtils.rm_rf(todelete)
|
85
|
+
end
|
86
|
+
end
|
60
87
|
end
|
data/lib/mvtk/search.rb
CHANGED
@@ -25,7 +25,7 @@ module Mvtk
|
|
25
25
|
searchresult = Nokogiri::HTML(open("https://www.themoviedb.org/search?query=#{URI.escape(moviename.tr(' ', '+'))}"), nil , 'UTF-8')
|
26
26
|
searchresult.css("div.info").take(10).each do |link|
|
27
27
|
msage = nil
|
28
|
-
myear = link.css('span.release_date').text.split("
|
28
|
+
myear = link.css('span.release_date').text.split("-")[0].strip
|
29
29
|
mtitle = "#{link.css('a').first.content} (#{myear})"
|
30
30
|
detailpage = Nokogiri::HTML(open("https://www.themoviedb.org#{link.css('a').first['href']}"))
|
31
31
|
msaga = detailpage.at('p:contains("Part of the")').css('a').text if detailpage.at('p:contains("Part of the")')
|
data/lib/mvtk/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mvtk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Celedhrim
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: iniparse
|