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 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
@@ -1,31 +1,65 @@
1
1
  require 'clamp'
2
- require 'fleakr'
2
+ require 'flickraw'
3
3
  require 'pathname'
4
4
  require 'splat'
5
5
 
6
6
  module FlickrSync
7
7
  class Cli < Clamp::Command
8
- option "--optimistic", :flag, "assume there are no duplicates"
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
- preferences[:api_key] ||= prompt.answer 'What is your Flickr API key'
16
- preferences[:shared_secret] ||= prompt.answer 'What is your Flickr Shared Secret'
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
- Fleakr.api_key = preferences[:api_key]
21
- Fleakr.shared_secret = preferences[:shared_secret]
22
- Fleakr.auth_token = preferences[:auth_token]
23
- user = Fleakr.user preferences[:username]
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
- unless optimistic?
39
- results = Fleakr.search :user_id => user.id, :text => path.basename.to_s.split('.').first
40
- skip_upload = false
41
- unless results.empty?
42
- ids = results.map {|r| r.id }.join ','
43
- puts "Found #{results.size} results on flickr: #{ids}"
44
- results.each {|r| r.small.url.to_launcher }
45
- file.to_launcher
46
- if prompt.ask('Had the photo already been uploaded', true)
47
- skip_upload = true
48
- if results.size > 1
49
- File.open(duplicates_path, 'a') {|f| f.puts "#{file},#{ids}"} if prompt.ask('Are these all duplicates', true)
50
- end
51
- end
52
- end
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 "skipping upload"
89
+ puts 'skipping upload'
56
90
  else
57
- puts "uploading photo"
58
- Fleakr.upload file, :viewable_by => :family, :hide? => true
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
@@ -1,4 +1,4 @@
1
- require File.expand_path '../../spec_helper.rb', __FILE__
1
+ require_relative '../spec_helper.rb'
2
2
 
3
3
  describe FlickrSync::Prompt do
4
4
  before do
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'rspec'
3
2
 
4
3
  $LOAD_PATH << File.dirname(__FILE__)+'/../lib'
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
- prerelease:
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
- date: 2011-06-05 00:00:00 +10:00
14
- default_executable:
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
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
22
17
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "0"
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
- requirement: &id002 !ruby/object:Gem::Requirement
31
- none: false
32
- requirements:
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: "0"
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
- requirement: &id003 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
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: "0"
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
- requirement: &id004 !ruby/object:Gem::Requirement
53
- none: false
54
- requirements:
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: "0.8"
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
- requirement: &id005 !ruby/object:Gem::Requirement
64
- none: false
65
- requirements:
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
66
  - - ~>
67
- - !ruby/object:Gem::Version
68
- version: "0"
69
- type: :development
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
- prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
75
- none: false
76
- requirements:
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
77
73
  - - ~>
78
- - !ruby/object:Gem::Version
79
- version: "2"
74
+ - !ruby/object:Gem::Version
75
+ version: '2'
80
76
  type: :development
81
- version_requirements: *id006
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
- none: false
118
- requirements:
119
- - - ">="
120
- - !ruby/object:Gem::Version
121
- version: "0"
122
- required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
- requirements:
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: 1.5.2
122
+ rubygems_version: 2.0.3
132
123
  signing_key:
133
- specification_version: 3
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
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- begin
2
- require 'gemesis/rake'
3
- rescue Exception
4
- puts "gemesis related tasks will only be available if you 'gem install gemesis'"
5
- end
6
-
7
- desc 'execute specifications'
8
- task :test do
9
- sh 'rspec spec'
10
- end