flickru 0.0.13 → 0.0.14
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 +5 -3
- data/bin/geowiki +1 -1
- data/lib/flickru/location.rb +15 -15
- data/lib/flickru/version.rb +1 -1
- metadata +6 -4
data/README
CHANGED
@@ -23,9 +23,11 @@ flickru automatically sets the following Flickr metadata:
|
|
23
23
|
Before uploading photos, please, make sure that you have correctly named each
|
24
24
|
photos parent directory according to the name format 'TITLE[@LOCATION[#PRECISION]]',
|
25
25
|
where:
|
26
|
-
(1) TITLE is the desired title for the photos stored in the directory
|
27
|
-
|
28
|
-
|
26
|
+
(1) TITLE is the desired title for the photos stored in the directory. If no
|
27
|
+
LOCATION is given, flickru tries to extract the location from Wikipedia
|
28
|
+
page TITLE.
|
29
|
+
(2) LOCATION is the location of the photos, specified as:
|
30
|
+
(a) the Wikipedia page name (whitespaces allowed) of the location or
|
29
31
|
(b) its coordinates LATITUDE,LONGITUDE
|
30
32
|
(3) PRECISION is the Flickr geolocation precision. Flickru sets it to one of
|
31
33
|
the following case insentitive literals: 'street', 'city', 'region',
|
data/bin/geowiki
CHANGED
data/lib/flickru/location.rb
CHANGED
@@ -3,13 +3,13 @@ require 'rbconfig'
|
|
3
3
|
# gems
|
4
4
|
require 'colorize'
|
5
5
|
require 'escape'
|
6
|
+
require 'open-uri'
|
6
7
|
# flickru
|
7
8
|
require 'flickru/ruby'
|
8
9
|
require 'flickru/string'
|
9
10
|
|
10
11
|
class Location
|
11
12
|
|
12
|
-
GEOWIKI = File.expand_path(File.join File.dirname(__FILE__), '..', '..', 'bin', 'geowiki')
|
13
13
|
DEFAULT_ACCURACY = "street"
|
14
14
|
COORD_PATTERN = "-?[0-9]+\.?[0-9]*"
|
15
15
|
|
@@ -47,7 +47,7 @@ class Location
|
|
47
47
|
|
48
48
|
private
|
49
49
|
|
50
|
-
def
|
50
|
+
def Location.parse location
|
51
51
|
# TODO special characters MAY be escaped
|
52
52
|
idx_accuracy = location.index('#') ? location.index('#') : location.length
|
53
53
|
idx_place = location.index('@') ? location.index('@') : idx_accuracy
|
@@ -59,15 +59,10 @@ private
|
|
59
59
|
[name, place, accuracy]
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
62
|
+
def Location.locate place
|
63
63
|
the_place = place # needed for RuntimeError reporting
|
64
64
|
begin
|
65
|
-
|
66
|
-
when /mswin|mingw|cygwin/i then true
|
67
|
-
else false end
|
68
|
-
command = Escape.shell_command((is_win ? ['bash'] : []) + [GEOWIKI, place])
|
69
|
-
null = is_win ? 'NUL' : '/dev/null'
|
70
|
-
place = `#{command} 2> #{null}`[0..-2] \
|
65
|
+
place = Location.geowiki place \
|
71
66
|
if place !~ /^#{COORD_PATTERN}, *#{COORD_PATTERN}$/
|
72
67
|
if place =~ /^#{COORD_PATTERN}, *#{COORD_PATTERN}$/
|
73
68
|
# latitude, longitude
|
@@ -76,12 +71,7 @@ private
|
|
76
71
|
raise RuntimeError
|
77
72
|
end
|
78
73
|
rescue
|
79
|
-
|
80
|
-
if is_win
|
81
|
-
message += ", please, verify that command 'bash' (from, e.g., " +
|
82
|
-
"http://unxutils.sourceforge.net) is in your PATH"
|
83
|
-
end
|
84
|
-
raise RuntimeError, message
|
74
|
+
raise RuntimeError, "location #{the_place} not found"
|
85
75
|
end
|
86
76
|
end
|
87
77
|
|
@@ -106,4 +96,14 @@ private
|
|
106
96
|
else @accuracy
|
107
97
|
end
|
108
98
|
end
|
99
|
+
|
100
|
+
def Location.geowiki place
|
101
|
+
wiki = open("http://en.wikipedia.org/wiki/#{place}").read
|
102
|
+
geo = open(wiki.tr("\"", "\n").split("\n").grep(/geohack/)
|
103
|
+
.first.sub('&','&')).read \
|
104
|
+
.split("\n").grep(/<span class="geo"/).first
|
105
|
+
latitude = geo.sub(/^.*"Latitude">/, '').sub(/<\/span>, .*/, '')
|
106
|
+
longitude = geo.sub(/.*"Longitude">/, '').sub(/<\/span>.*$/, '')
|
107
|
+
latitude + ", " + longitude
|
108
|
+
end
|
109
109
|
end
|
data/lib/flickru/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: flickru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.14
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jesus Pardillo
|
@@ -137,9 +137,11 @@ description: |
|
|
137
137
|
Before uploading photos, please, make sure that you have correctly named each
|
138
138
|
photos parent directory according to the name format 'TITLE[@LOCATION[#PRECISION]]',
|
139
139
|
where:
|
140
|
-
(1) TITLE is the desired title for the photos stored in the directory
|
141
|
-
|
142
|
-
|
140
|
+
(1) TITLE is the desired title for the photos stored in the directory. If no
|
141
|
+
LOCATION is given, flickru tries to extract the location from Wikipedia
|
142
|
+
page TITLE.
|
143
|
+
(2) LOCATION is the location of the photos, specified as:
|
144
|
+
(a) the Wikipedia page name (whitespaces allowed) of the location or
|
143
145
|
(b) its coordinates LATITUDE,LONGITUDE
|
144
146
|
(3) PRECISION is the Flickr geolocation precision. Flickru sets it to one of
|
145
147
|
the following case insentitive literals: 'street', 'city', 'region',
|