photostat 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/photostat.rb +1 -1
- data/lib/photostat/plugins/02_flickr.rb +48 -5
- data/lib/photostat/plugins/03_query.rb +32 -0
- data/photostat.gemspec +2 -1
- metadata +30 -18
data/lib/photostat.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
module Photostat
|
2
2
|
class Flickr < Plugins::Base
|
3
3
|
include OSUtils
|
4
|
+
include FileUtils
|
4
5
|
|
5
6
|
help_text "Manages your Flickr account"
|
6
7
|
|
7
8
|
exposes :config, "Configures Flickr login"
|
8
9
|
exposes :sync, "Uploads local photos to Flickr, downloads Flickr tags / visibility info"
|
10
|
+
exposes :export, "Exports web page with thumbnails/links of your public Flickr photos"
|
9
11
|
|
10
12
|
def activate!
|
11
13
|
return if @activated
|
@@ -100,13 +102,17 @@ module Photostat
|
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
-
|
105
|
+
if fphoto.ispublic == 1
|
106
|
+
visibility = 'public'
|
107
|
+
elsif fphoto.isfamily == 1
|
108
|
+
visibility = 'protected'
|
109
|
+
else
|
110
|
+
visibility = 'private'
|
111
|
+
end
|
106
112
|
|
107
113
|
db[:photos].where(:md5 => md5).update(:has_flickr_upload => true, :visibility => visibility)
|
108
114
|
|
109
|
-
STDOUT.write("\r -
|
115
|
+
STDOUT.write("\r - reading flickr meta: #{count} of #{total}, with #{not_tagged} not tagged on flickr, #{not_local} not local")
|
110
116
|
STDOUT.flush
|
111
117
|
end
|
112
118
|
|
@@ -115,7 +121,44 @@ module Photostat
|
|
115
121
|
rs = flickr.photos.search(:user_id => "me", :extras => 'machine_tags', :per_page => 500, :page => page_idx)
|
116
122
|
end
|
117
123
|
|
118
|
-
puts("\r -
|
124
|
+
puts("\r - reading flickr meta: #{count} of #{total}, with #{not_tagged} not tagged on flickr, #{not_local} not local")
|
125
|
+
end
|
126
|
+
|
127
|
+
def export
|
128
|
+
opts = Trollop::options do
|
129
|
+
opt :path, "Local path to export web page to", :required => true, :type => :string, :short => "-p"
|
130
|
+
end
|
131
|
+
|
132
|
+
Trollop::die :path, "must have valid base directory" unless File.directory? File.dirname(opts[:path])
|
133
|
+
Trollop::die :path, "directory already exists" if File.directory? opts[:path]
|
134
|
+
|
135
|
+
activate!
|
136
|
+
update_md5_info_on_files!
|
137
|
+
|
138
|
+
cfg = Photostat.config
|
139
|
+
db = Photostat::DB.instance
|
140
|
+
Dir.mkdir opts[:path]
|
141
|
+
|
142
|
+
fh = File.open(File.join(opts[:path], 'index.html'), 'w')
|
143
|
+
|
144
|
+
rs = flickr.photos.search(:user_id => "me", :extras => 'machine_tags, tags, date_taken, date_upload', :per_page => 500, :privacy_filter => 1)
|
145
|
+
rs.each do |fphoto|
|
146
|
+
next unless fphoto.machine_tags =~ /checksum:md5=(\w+)/
|
147
|
+
|
148
|
+
md5 = $1
|
149
|
+
obj = db[:photos].where(:md5 => md5).first
|
150
|
+
|
151
|
+
fname = File.basename obj[:local_path]
|
152
|
+
src_path = File.join(cfg[:repository_path], obj[:local_path])
|
153
|
+
dst_path = File.join(opts[:path], fname)
|
154
|
+
|
155
|
+
cp src_path, dst_path
|
156
|
+
fh.write "<a href='http://www.flickr.com/photos/alex_ndc/#{fphoto.id}/in/photostream' target='_blank'>\n"
|
157
|
+
fh.write " <img src='#{fname}' />\n"
|
158
|
+
fh.write "</a>\n"
|
159
|
+
end
|
160
|
+
|
161
|
+
fh.close
|
119
162
|
end
|
120
163
|
|
121
164
|
def sync
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Photostat
|
2
|
+
class Query < Plugins::Base
|
3
|
+
include OSUtils
|
4
|
+
|
5
|
+
help_text "For querying the local repo database"
|
6
|
+
|
7
|
+
exposes :list, "Lists photos corresponding to the filtering criteria"
|
8
|
+
|
9
|
+
def list
|
10
|
+
opts = Trollop::options do
|
11
|
+
opt :visibility, "Specifies visibility of photos, choices are private, protected and public", :type => :string
|
12
|
+
opt :sort, "Specify sort field, one example being 'created_at'", :type => :string
|
13
|
+
opt :reverse, "Reverses output list", :type => :boolean
|
14
|
+
opt :absolute, "Output absolute path", :type => :boolean
|
15
|
+
end
|
16
|
+
|
17
|
+
config = Photostat.config
|
18
|
+
db = Photostat::DB.instance
|
19
|
+
|
20
|
+
rs = db[:photos]
|
21
|
+
rs = rs.where(:visibility => opts[:visibility]) if opts[:visibility]
|
22
|
+
rs = rs.order(opts[:sort].to_sym) if opts[:sort]
|
23
|
+
rs = rs.reverse if opts[:reverse]
|
24
|
+
|
25
|
+
rs.each do |obj|
|
26
|
+
path = obj[:local_path]
|
27
|
+
path = File.expand_path(File.join(config[:repository_path], path)) if opts[:absolute]
|
28
|
+
puts path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/photostat.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "photostat
|
3
|
+
require "photostat"
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "photostat"
|
@@ -27,4 +27,5 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_runtime_dependency "flickraw"
|
28
28
|
s.add_runtime_dependency "exifr"
|
29
29
|
s.add_runtime_dependency "json"
|
30
|
+
s.add_runtime_dependency "sequel"
|
30
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photostat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
12
|
+
date: 2011-10-31 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
|
-
requirement: &
|
16
|
+
requirement: &79120930 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *79120930
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &79120610 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *79120610
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &79120350 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *79120350
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: trollop
|
49
|
-
requirement: &
|
49
|
+
requirement: &79119920 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *79119920
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: escape
|
60
|
-
requirement: &
|
60
|
+
requirement: &79118850 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *79118850
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: flickraw
|
71
|
-
requirement: &
|
71
|
+
requirement: &79118400 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *79118400
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: exifr
|
82
|
-
requirement: &
|
82
|
+
requirement: &79117740 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *79117740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: json
|
93
|
-
requirement: &
|
93
|
+
requirement: &79117130 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,18 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :runtime
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *79117130
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: sequel
|
104
|
+
requirement: &79116740 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *79116740
|
102
113
|
description: Photostat is a collection of command-line utilities for managing photos
|
103
114
|
/ syncronizing with Flickr - first version doesnt do much, it just helps me organize
|
104
115
|
my files and upload them to Flickr
|
@@ -126,6 +137,7 @@ files:
|
|
126
137
|
- lib/photostat/plugins/00_base.rb
|
127
138
|
- lib/photostat/plugins/01_local.rb
|
128
139
|
- lib/photostat/plugins/02_flickr.rb
|
140
|
+
- lib/photostat/plugins/03_query.rb
|
129
141
|
- lib/photostat/utils/os.rb
|
130
142
|
- photostat.gemspec
|
131
143
|
homepage: http://github.com/alexandru/photostat
|