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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcf8e3ca0c85e58376370e26b2e50581937cfd9d
4
- data.tar.gz: 93deb60a64ca1e1e88814fcde838791f8e78a8d0
3
+ metadata.gz: 1ac09c4c4941161ab8b8441830515777a84db4c9
4
+ data.tar.gz: f22be28bdfe58fdb9f6e1c17addc2f3890ac6194
5
5
  SHA512:
6
- metadata.gz: 1815ee0465d8a3a862b9b1a6681bbb5b158ede606b34dad80d5d628db7818a6901575f01fc7c5cedbc5a3f78e5dd0d104df56eaf4312697f9be47df0a9bd3915
7
- data.tar.gz: 552546495531e8542b60fc2452461029135a152bafa2d8d7182d982c1fff2cf2dfcac6970b521cbf23d911bb6d5d661822f984a56866170e7efeb73578769a65
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
- Mvtk.copy(source, destination)
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
@@ -13,6 +13,8 @@ module Mvtk
13
13
  mvtk.option("target","/home/data/Videos/Films")
14
14
  mvtk.option("windows_name","true")
15
15
  mvtk.option("min_movie_time","60")
16
+ mvtk.option("year_in_filename","false")
17
+ mvtk.option("move_files","false")
16
18
  end
17
19
  end
18
20
  doc.save(conffilepath)
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("/")[2].strip
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
@@ -1,3 +1,3 @@
1
1
  module Mvtk
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-03-16 00:00:00.000000000 Z
11
+ date: 2016-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: iniparse