-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrasla.rb
60 lines (54 loc) · 1.54 KB
/
trasla.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'slack'
require "exifr"
require "open-uri"
require "json"
TOKEN=ARGV[0]
Slack.configure do |config|
config.token = TOKEN
end
usrs = Slack.users_list
user ={}
usrs["members"].each{|u|
user[u["id"]]=u["name"]
}
icon={}
usrs["members"].each{|u|
icon[u["id"]]=u["profile"]["image_48"]
}
get = Slack.files_list(page: 1)
num = get["paging"]["pages"].to_i
gpshistory = []
num.times do |pagenum|
get = Slack.files_list(page: pagenum+1) unless pagenum==0
files = get["files"]
files.each{|f|
if f["url_download"].to_s[-3,3] == "jpg"
puts (pagenum+1).to_s + ":" + user[f["user"]]
open(f["url_download"]) do |data|
begin
@exif = EXIFR::JPEG.new(data)
unless @exif.gps.nil?
gps = {}
gps["src"]=f["url_download"]
gps["user"]=user[f["user"]]
gps["date"][email protected]_time_original unless @exif.exif.date_time_original.nil?
gps["latitude"][email protected]
gps["longitude"][email protected]
gps["icon"]=icon[f["user"]]
gpshistory.push(gps)
# puts gps.to_json
puts user[f["user"]]
puts @exif.exif.date_time_original unless @exif.exif.date_time_original.nil?
puts @exif.gps.latitude
puts @exif.gps.longitude
open("gpshistory.json", 'w') do |io|
JSON.dump(gpshistory, io)
end
end
rescue
end
end
end
#`wget #{f["url_download"]} -P files` if f["url_download"].to_s[-3,3] == "jpg"
}
end