myimdb 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bin/myimdb-catalogue +18 -20
  3. data/myimdb.gemspec +1 -1
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.9
1
+ 0.3.10
data/bin/myimdb-catalogue CHANGED
@@ -9,14 +9,6 @@ class Platform
9
9
  def windows?
10
10
  RUBY_PLATFORM =~ /mswin|windows|mingw/i
11
11
  end
12
-
13
- def xp?
14
- ENV["ALLUSERSPROFILE"] =~ /Documents and Settings/
15
- end
16
-
17
- def vista_or_later?
18
- !xp?
19
- end
20
12
 
21
13
  def mac?
22
14
  RUBY_PLATFORM =~ /darwin/i
@@ -54,6 +46,10 @@ OptionParser.new do |opts|
54
46
  options[:recursive] = true
55
47
  end
56
48
 
49
+ opts.on("-a", "--apply-icon", "Finds first jpg or png in the folder and converts it to movie icon") do
50
+ options[:'apply-icon'] = true
51
+ end
52
+
57
53
  if Platform.windows?
58
54
  opts.on("-p", "--rebuild-permissions", "Rebuilds permissions (useful if the icons have been changed manually)") do
59
55
  options[:'rebuild-permissions'] = true
@@ -93,14 +89,6 @@ def icon_file_name
93
89
  end
94
90
  end
95
91
 
96
- def icon_size
97
- if Platform.windows?
98
- Platform.vista_or_later? ? '256x256' : '128x128'
99
- else
100
- '512x512'
101
- end
102
- end
103
-
104
92
  def filtered_movie_name(name)
105
93
  name.gsub(/\[.*?\]/,'').strip
106
94
  end
@@ -125,7 +113,7 @@ def repair_permissions_for(target_dir)
125
113
  end
126
114
 
127
115
  def convert_to_icon(image_file_path, icon_file_path)
128
- `convert "#{image_file_path}" -thumbnail #{icon_size} -gravity center -crop #{icon_size}+0+0! -background transparent -flatten "#{icon_file_path}"`
116
+ `convert "#{image_file_path}" -thumbnail 256x256 -gravity center -crop 256x256+0+0! -background transparent -flatten "#{icon_file_path}"`
129
117
  end
130
118
 
131
119
  def save_image(target_dir, name, image_index=0)
@@ -139,14 +127,14 @@ def save_image(target_dir, name, image_index=0)
139
127
  image_file.puts file.read
140
128
  end
141
129
  end
142
-
130
+
143
131
  convert_to_icon(image_file_path, File.join(target_dir, icon_file_name))
144
132
 
145
133
  if Platform.windows?
146
134
  repair_permissions_for(target_dir)
147
135
  end
148
136
 
149
- File.delete(image_file_path)
137
+ File.delete(image_file_path) if File.exists?(image_file_path)
150
138
  end
151
139
  end
152
140
 
@@ -200,9 +188,19 @@ file_paths.each do |path|
200
188
  end
201
189
 
202
190
  if options[:'rebuild-permissions']
203
- p "Repairing permissions for for: #{name}"
191
+ p "Repairing permissions for: #{name}"
204
192
  repair_permissions_for(path)
205
193
  end
194
+
195
+ if options[:'apply-icon']
196
+ source_file = Dir.entries(path).find{ |file| file =~ /\.jpg|\.png/ }
197
+ if source_file
198
+ p "Applying icon for: #{name}"
199
+ convert_to_icon(File.join(path, source_file), File.join(path, icon_file_name))
200
+ else
201
+ p "Source image file not found for: #{name}"
202
+ end
203
+ end
206
204
  rescue
207
205
  p "Unable to fetch details for: #{name}"
208
206
  end
data/myimdb.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{myimdb}
8
- s.version = "0.3.9"
8
+ s.version = "0.3.10"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gaurav"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myimdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9
4
+ version: 0.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaurav