flickru 0.0.8 → 0.0.9

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/README CHANGED
@@ -3,11 +3,12 @@ Command-line tool that automatises photo/video uploads to Flickr.
3
3
  Entering 'flickru <directory>' in your command line, any photos under 'directory' (and subdirs)
4
4
  are uploaded to your Flickr account (interactively entered at the first time you start flickru).
5
5
 
6
- Photos are identified by case-insensitive extensions: GIF, JPEG, JPG, and PNG.
6
+ Photos are identified by case-insensitive extensions: GIF, JPEG, JPG, PNG, and TIFF.
7
7
  Videos are identified by case-insensitive extensions: AVI, MPEG, and MPG.
8
8
 
9
9
  The following Flickr metadata for photos (as well as videos) is set:
10
- (1) date-taken from the file (last) modification time
10
+ (1) date-taken from the file (last) modification time if no JPEG/TIFF
11
+ Exif metadata (Flickr directly sets photo date-taken by querying Exif)
11
12
  (2) private, visible by friends & family, hidden for public searches
12
13
  (3) safety level to safe
13
14
  (4) permission for friends & family to add comments to the photo and it's notes
data/bin/flickru CHANGED
@@ -5,18 +5,21 @@
5
5
  require 'flickru'
6
6
  require 'flickru/version'
7
7
 
8
- photo_dir = File.expand_path ARGV[0]
9
-
10
8
  if ARGV[0] == "-h" or ARGV[0] == "--help"
11
9
  Flickru.usage
12
10
  exit
13
11
  elsif ARGV[0] == "-v" or ARGV[0] == "--version"
14
12
  puts Flickru::VERSION
15
13
  exit
16
- elsif ARGV.length > 1
14
+ elsif ARGV.length != 1
17
15
  Flickru.usage
18
- Flickru.die __LINE__, "wrong number of arguments: #{ARGV[1,ARGV.length]}"
19
- elsif photo_dir.nil? or photo_dir.empty?
16
+ Flickru.die __LINE__, "wrong number of arguments" +
17
+ if ARGV.length != 0 then ": " + ARGV[1,ARGV.length].to_s
18
+ else "" end
19
+ end
20
+
21
+ photo_dir = File.expand_path ARGV[0]
22
+ if photo_dir.nil? or photo_dir.empty?
20
23
  Flickru.usage
21
24
  Flickru.die __LINE__, "missing photo directory"
22
25
  end
data/lib/flickru/file.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # ruby
2
- require 'escape'
3
2
  require 'find'
3
+ # gems
4
+ require 'escape'
5
+ require 'exifr'
4
6
 
5
7
  class File
6
8
 
@@ -44,6 +46,20 @@ class File
44
46
  end
45
47
  end
46
48
 
49
+ def File.date_taken file
50
+ attempt = 1
51
+ begin
52
+ case attempt
53
+ when 1 then EXIFR::JPEG.new(file).date_time_original.strftime "%y-%m-%d %H:%M:%S"
54
+ when 2 then EXIFR::TIFF.new(file).date_time_original.strftime "%y-%m-%d %H:%M:%S"
55
+ else nil
56
+ end
57
+ rescue
58
+ attempt += 1
59
+ retry
60
+ end
61
+ end
62
+
47
63
  def File.human_readable_size file_size
48
64
  if file_size < 1000
49
65
  file_size.to_s + " bytes"
@@ -58,7 +74,7 @@ class File
58
74
 
59
75
  private
60
76
 
61
- IMAGE_EXTENSIONS = [".gif", ".jpg", ".jpeg", ".png"] # lowercase
77
+ IMAGE_EXTENSIONS = [".gif", ".jpg", ".jpeg", ".png", ".tiff"] # lowercase
62
78
  VIDEO_EXTENSIONS = [".mpeg", ".mpg", ".avi"] # lowercase
63
79
 
64
80
  end
@@ -49,7 +49,9 @@ module Flickr
49
49
  description = "This " + description + "\nDownload original file to play full video."
50
50
  end
51
51
 
52
- date = File.mtime(photo).strftime("%y-%m-%d %H:%M:%S")
52
+ date = File.date_taken photo
53
+ if date.nil? then date = File.mtime(photo).strftime "%y-%m-%d %H:%M:%S" end
54
+
53
55
  loc = Location.new photo
54
56
  Printer.show "uploading as " +
55
57
  (loc.nil? ? "\"#{loc.name.black}\" (no location given)" : loc.to_s.black) +
@@ -75,7 +77,6 @@ module Flickr
75
77
  end
76
78
  flickr.photos.setTags :photo_id => id, :tags => ''
77
79
 
78
- # TODO date taken should be set only for photos/videos without non EXIF metadata
79
80
  flickr.photos.setDates :photo_id => id, :date_taken => date
80
81
  flickr.photos.setPerms :photo_id => id, :is_public => 0,
81
82
  :is_friend => 1, :is_family => 1, # again! (mandatory) :P
@@ -1,5 +1,5 @@
1
1
  module Flickru
2
2
  unless defined? VERSION
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
data/spec/flickru_spec.rb CHANGED
@@ -11,6 +11,10 @@ describe Flickru do
11
11
  Flickru.flickru "var/ts/tc_accents"
12
12
  end
13
13
 
14
+ it "setting date-taken metadata from Exif metadata if existing" do
15
+ Flickru.flickru "var/ts/tc_date_taken"
16
+ end
17
+
14
18
  it "different accuracies work case-insensitively" do
15
19
  Flickru.flickru "var/ts/tc_accuracies"
16
20
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: flickru
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.8
5
+ version: 0.0.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jesus Pardillo
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-01-03 00:00:00 Z
13
+ date: 2012-01-06 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: colorize
@@ -35,71 +35,83 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
38
- name: flickraw
38
+ name: exifr
39
39
  prerelease: false
40
40
  requirement: &id003 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 0.9.4
45
+ version: 1.1.1
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
49
- name: rubygems-update
49
+ name: flickraw
50
50
  prerelease: false
51
51
  requirement: &id004 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: 1.8.11
56
+ version: 0.9.4
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
60
- name: simplecov
60
+ name: rubygems-update
61
61
  prerelease: false
62
62
  requirement: &id005 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 0.5.4
67
+ version: 1.8.11
68
68
  type: :runtime
69
69
  version_requirements: *id005
70
70
  - !ruby/object:Gem::Dependency
71
- name: unicode_utils
71
+ name: simplecov
72
72
  prerelease: false
73
73
  requirement: &id006 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: 1.1.2
78
+ version: 0.5.4
79
79
  type: :runtime
80
80
  version_requirements: *id006
81
81
  - !ruby/object:Gem::Dependency
82
- name: rspec
82
+ name: unicode_utils
83
83
  prerelease: false
84
84
  requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 1.1.2
90
+ type: :runtime
91
+ version_requirements: *id007
92
+ - !ruby/object:Gem::Dependency
93
+ name: rspec
94
+ prerelease: false
95
+ requirement: &id008 !ruby/object:Gem::Requirement
85
96
  none: false
86
97
  requirements:
87
98
  - - ~>
88
99
  - !ruby/object:Gem::Version
89
100
  version: 2.7.0
90
101
  type: :development
91
- version_requirements: *id007
102
+ version_requirements: *id008
92
103
  description: |
93
104
  Command-line tool that automatises photo/video uploads to Flickr.
94
105
 
95
106
  Entering 'flickru <directory>' in your command line, any photos under 'directory' (and subdirs)
96
107
  are uploaded to your Flickr account (interactively entered at the first time you start flickru).
97
108
 
98
- Photos are identified by case-insensitive extensions: GIF, JPEG, JPG, and PNG.
109
+ Photos are identified by case-insensitive extensions: GIF, JPEG, JPG, PNG, and TIFF.
99
110
  Videos are identified by case-insensitive extensions: AVI, MPEG, and MPG.
100
111
 
101
112
  The following Flickr metadata for photos (as well as videos) is set:
102
- (1) date-taken from the file (last) modification time
113
+ (1) date-taken from the file (last) modification time if no JPEG/TIFF
114
+ Exif metadata (Flickr directly sets photo date-taken by querying Exif)
103
115
  (2) private, visible by friends & family, hidden for public searches
104
116
  (3) safety level to safe
105
117
  (4) permission for friends & family to add comments to the photo and it's notes