flickr_airlift 0.0.2
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/bin/flickr_airlift +3 -0
- data/lib/flickr_airlift.rb +63 -0
- metadata +69 -0
data/bin/flickr_airlift
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'flickraw'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module FlickrAirlift
|
6
|
+
|
7
|
+
def self.download
|
8
|
+
begin
|
9
|
+
# Setup
|
10
|
+
FlickRaw.api_key = "d4d152785af1b0ea68a5a2d173c75707"
|
11
|
+
FlickRaw.shared_secret = "b9da0b4f99507dd0"
|
12
|
+
frob = flickr.auth.getFrob
|
13
|
+
auth_url = FlickRaw.auth_url :frob => frob, :perms => 'read'
|
14
|
+
|
15
|
+
# TODO: Use open if it's supported
|
16
|
+
puts " "
|
17
|
+
puts "Open this url in your process to complete the authication process:"
|
18
|
+
puts auth_url
|
19
|
+
puts "Press Enter when you are finished."
|
20
|
+
STDIN.getc
|
21
|
+
|
22
|
+
# Authentication
|
23
|
+
auth = flickr.auth.getToken :frob => frob
|
24
|
+
login = flickr.test.login
|
25
|
+
puts "You are now authenticated as #{login.username} with token #{auth.token}"
|
26
|
+
|
27
|
+
# Prompt
|
28
|
+
puts "Exactly who's photos would you like to archive?:"
|
29
|
+
scraped_user = STDIN.gets
|
30
|
+
scraped_user = scraped_user.strip
|
31
|
+
|
32
|
+
# Find
|
33
|
+
user_id = flickr.people.findByUsername(:username => scraped_user).id
|
34
|
+
photos = flickr.photos.search(:user_id => user_id)
|
35
|
+
photo_count = photos.total
|
36
|
+
page_count = photos.pages
|
37
|
+
|
38
|
+
# Downloading
|
39
|
+
puts "#{scraped_user} has #{photo_count} pictures"
|
40
|
+
puts "* Creating folder named '#{scraped_user}'"
|
41
|
+
Dir.mkdir(scraped_user) unless File.directory?(scraped_user)
|
42
|
+
|
43
|
+
(1..page_count.to_i).each do |page_number|
|
44
|
+
puts "* PAGE #{page_number} of #{page_count}"
|
45
|
+
flickr.photos.search(:user_id => user_id, :page => page_number).each_with_index do |photo, i|
|
46
|
+
photo_id = photo.id
|
47
|
+
info = flickr.photos.getInfo(:photo_id => photo_id)
|
48
|
+
download_url = flickr.photos.getSizes(:photo_id => photo_id).find{|size| size.label == "Original" || size.label == "Large" || size.label == "Medium"}.source
|
49
|
+
|
50
|
+
puts "** Downloading #{i+1}: #{photo.title} from #{download_url}"
|
51
|
+
File.open(File.join(scraped_user, "#{photo_id}.jpg"), 'w') do |file|
|
52
|
+
file.puts Net::HTTP.get_response(URI.parse(download_url)).body
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
rescue FlickRaw::FailedResponse => e
|
59
|
+
puts e.msg
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flickr_airlift
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Stephen Schor
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-28 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description:
|
23
|
+
email:
|
24
|
+
- beholdthepanda@gmail.com
|
25
|
+
executables:
|
26
|
+
- flickr_airlift
|
27
|
+
extensions: []
|
28
|
+
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- bin/flickr_airlift
|
33
|
+
- lib/flickr_airlift.rb
|
34
|
+
has_rdoc: true
|
35
|
+
homepage: https://github.com/nodanaonlyzuul/flickr_airlift
|
36
|
+
licenses: []
|
37
|
+
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
|
41
|
+
require_paths:
|
42
|
+
- lib
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
hash: 3
|
49
|
+
segments:
|
50
|
+
- 0
|
51
|
+
version: "0"
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project: nowarning
|
64
|
+
rubygems_version: 1.3.7
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: A Command-Line tool for scraping any user's original photos
|
68
|
+
test_files: []
|
69
|
+
|