flickr_sync 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/flickr_sync/cli.rb +66 -32
- data/spec/flickr_sync/prompt_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +76 -86
- data/.gemtest +0 -0
- data/Rakefile +0 -10
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a27ae0e883433e74bb16e86f4b8e02cad824d7f
|
4
|
+
data.tar.gz: de9141a993500a639739c08e6f78098e627e7433
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8e93baa497ab0d82604f90a5c2b86e44f20966c1dfd9e95a05d6b78ea44a522da59a2dbdd97e5a2f45e0cbe0bce394d69c8383d1d775029aa3788f3d4116a145
|
7
|
+
data.tar.gz: ea9b911ef7111cbaff0522eda9c23de2dc96c68aa1d82fd8539024cf2b1063a930fac1660622b772452a75ab6cb1bd75d3a9414a827fbe6d5ccc2c0aba7a033d
|
data/lib/flickr_sync/cli.rb
CHANGED
@@ -1,31 +1,65 @@
|
|
1
1
|
require 'clamp'
|
2
|
-
require '
|
2
|
+
require 'flickraw'
|
3
3
|
require 'pathname'
|
4
4
|
require 'splat'
|
5
5
|
|
6
6
|
module FlickrSync
|
7
7
|
class Cli < Clamp::Command
|
8
|
-
|
8
|
+
attr_reader :preferences
|
9
|
+
|
10
|
+
# option "--optimistic", :flag, "assume there are no duplicates"
|
9
11
|
parameter "DIRECTORY_PATH", "the folder containing images"
|
10
12
|
|
13
|
+
def api_key
|
14
|
+
preferences[:api_key] ||= prompt.answer 'What is your Flickr API key'
|
15
|
+
end
|
16
|
+
|
17
|
+
def shared_secret
|
18
|
+
preferences[:shared_secret] ||= prompt.answer 'What is your Flickr Shared Secret'
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_authenticated?
|
22
|
+
preferences[:access_token]
|
23
|
+
end
|
24
|
+
|
25
|
+
def store_authentication token
|
26
|
+
preferences[:username] = token['username']
|
27
|
+
preferences[:access_token] = token['oauth_token']
|
28
|
+
preferences[:access_secret] = token['oauth_token_secret']
|
29
|
+
end
|
30
|
+
|
31
|
+
def access_token
|
32
|
+
preferences[:access_token]
|
33
|
+
end
|
34
|
+
|
35
|
+
def access_secret
|
36
|
+
preferences[:access_secret]
|
37
|
+
end
|
38
|
+
|
11
39
|
def execute
|
12
|
-
preferences = FlickrSync::Preferences.new
|
40
|
+
@preferences = FlickrSync::Preferences.new
|
13
41
|
prompt = FlickrSync::Prompt.new STDIN, STDOUT
|
14
42
|
|
15
|
-
|
16
|
-
|
17
|
-
preferences[:auth_token] ||= prompt.answer 'What is your Flickr Auth'
|
18
|
-
preferences[:username] ||= prompt.answer 'What is your Flickr username'
|
43
|
+
FlickRaw.api_key = api_key
|
44
|
+
FlickRaw.shared_secret = shared_secret
|
19
45
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
46
|
+
unless has_authenticated?
|
47
|
+
token = flickr.get_request_token
|
48
|
+
auth_url = flickr.get_authorize_url(token['oauth_token'], :perms => 'delete')
|
49
|
+
auth_url.to_launcher
|
50
|
+
verify = prompt.answer 'What was the number'
|
51
|
+
store_authentication flickr.get_access_token token['oauth_token'], token['oauth_token_secret'], verify
|
52
|
+
end
|
53
|
+
|
54
|
+
flickr.access_token = access_token
|
55
|
+
flickr.access_secret = access_secret
|
56
|
+
|
57
|
+
flickr.test.login
|
24
58
|
|
25
59
|
written_path = File.join directory_path, 'written.txt'
|
26
60
|
duplicates_path = File.join directory_path, 'duplicates.txt'
|
27
61
|
|
28
|
-
allfiles = `find #{directory_path}/*`.split("\n").select {|p| ['.jpg', '.gif'].include? File.extname(p).downcase}
|
62
|
+
allfiles = `find #{directory_path}/*`.split("\n").select {|p| ['.jpg', '.gif', '.m4v'].include? File.extname(p).downcase}
|
29
63
|
puts "Found #{allfiles.count} image files"
|
30
64
|
writtenfiles = load_list written_path
|
31
65
|
puts "Found #{writtenfiles.count} previously sent files"
|
@@ -35,27 +69,27 @@ module FlickrSync
|
|
35
69
|
newfiles.each_with_index do |file, index|
|
36
70
|
path = Pathname.new file
|
37
71
|
puts "#{path} (#{index+1}/#{newfiles.count})"
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
72
|
+
skip_upload = false
|
73
|
+
# unless optimistic?
|
74
|
+
# results = Fleakr.search :user_id => user.id, :text => path.basename.to_s.split('.').first
|
75
|
+
# unless results.empty?
|
76
|
+
# ids = results.map {|r| r.id }.join ','
|
77
|
+
# puts "Found #{results.size} results on flickr: #{ids}"
|
78
|
+
# results.each {|r| r.small.url.to_launcher }
|
79
|
+
# file.to_launcher
|
80
|
+
# if prompt.ask('Had the photo already been uploaded', true)
|
81
|
+
# skip_upload = true
|
82
|
+
# if results.size > 1
|
83
|
+
# File.open(duplicates_path, 'a') {|f| f.puts "#{file},#{ids}"} if prompt.ask('Are these all duplicates', true)
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
# end
|
87
|
+
# end
|
54
88
|
if skip_upload
|
55
|
-
puts
|
89
|
+
puts 'skipping upload'
|
56
90
|
else
|
57
|
-
puts
|
58
|
-
|
91
|
+
puts 'uploading photo'
|
92
|
+
flickr.upload_photo file, is_public: 0, is_family: 1, hidden: 2
|
59
93
|
end
|
60
94
|
File.open(written_path, 'a') {|f| f.puts file }
|
61
95
|
end
|
@@ -68,7 +102,7 @@ private
|
|
68
102
|
while line = file.gets
|
69
103
|
lines << line.chomp
|
70
104
|
end
|
71
|
-
end
|
105
|
+
end
|
72
106
|
lines
|
73
107
|
end
|
74
108
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,97 +1,95 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: flickr_sync
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Mark Ryall
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
17
14
|
name: clamp
|
18
|
-
|
19
|
-
|
20
|
-
none: false
|
21
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
22
17
|
- - ~>
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
25
20
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: fleakr
|
29
21
|
prerelease: false
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: flickraw
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
33
31
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
36
34
|
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: splat
|
40
35
|
prerelease: false
|
41
|
-
|
42
|
-
|
43
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: splat
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
44
45
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
47
48
|
type: :runtime
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: rake
|
51
49
|
prerelease: false
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
55
59
|
- - ~>
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
58
62
|
type: :development
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: gemesis
|
62
63
|
prerelease: false
|
63
|
-
|
64
|
-
|
65
|
-
requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
66
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
72
70
|
name: rspec
|
73
|
-
|
74
|
-
|
75
|
-
none: false
|
76
|
-
requirements:
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
77
73
|
- - ~>
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2'
|
80
76
|
type: :development
|
81
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2'
|
82
83
|
description: |
|
83
84
|
Flickr is a very effective way to backup lots of images but the upload tools are all pretty awful.
|
84
|
-
|
85
|
-
Hopefully this is marginally less painful
|
86
85
|
|
86
|
+
Hopefully this is marginally less painful
|
87
87
|
email: mark@ryall.name
|
88
|
-
executables:
|
88
|
+
executables:
|
89
89
|
- flickr_sync
|
90
90
|
extensions: []
|
91
|
-
|
92
91
|
extra_rdoc_files: []
|
93
|
-
|
94
|
-
files:
|
92
|
+
files:
|
95
93
|
- lib/flickr_sync/cli.rb
|
96
94
|
- lib/flickr_sync/preferences.rb
|
97
95
|
- lib/flickr_sync/prompt.rb
|
@@ -102,35 +100,27 @@ files:
|
|
102
100
|
- README.rdoc
|
103
101
|
- MIT-LICENSE
|
104
102
|
- HISTORY.rdoc
|
105
|
-
- Rakefile
|
106
|
-
- .gemtest
|
107
|
-
has_rdoc: true
|
108
103
|
homepage: http://github.com/markryall/flickr_sync
|
109
104
|
licenses: []
|
110
|
-
|
105
|
+
metadata: {}
|
111
106
|
post_install_message:
|
112
107
|
rdoc_options: []
|
113
|
-
|
114
|
-
require_paths:
|
108
|
+
require_paths:
|
115
109
|
- lib
|
116
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: "0"
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
128
120
|
requirements: []
|
129
|
-
|
130
121
|
rubyforge_project:
|
131
|
-
rubygems_version:
|
122
|
+
rubygems_version: 2.0.3
|
132
123
|
signing_key:
|
133
|
-
specification_version:
|
124
|
+
specification_version: 4
|
134
125
|
summary: command line utility to synch a folder with flickr
|
135
126
|
test_files: []
|
136
|
-
|
data/.gemtest
DELETED
File without changes
|