giannichiappetta-contacts 1.0.16 → 1.0.16.1
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/lib/contacts/hotmail.rb +29 -7
- metadata +1 -1
data/lib/contacts/hotmail.rb
CHANGED
|
@@ -66,6 +66,7 @@ class Contacts
|
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
@contacts = []
|
|
69
|
+
build_contacts = []
|
|
69
70
|
go = true
|
|
70
71
|
index = 0
|
|
71
72
|
|
|
@@ -75,18 +76,39 @@ class Contacts
|
|
|
75
76
|
http = open_http(url)
|
|
76
77
|
resp, data = http.get(get_contact_list_url(index), "Cookie" => @cookies)
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
email_match_text_beginning = Regexp.escape("http://m.mail.live.com/?rru=compose&to=")
|
|
80
|
+
email_match_text_end = Regexp.escape("&")
|
|
81
|
+
|
|
82
|
+
raw_html = resp.body.grep(/(?:e|dn)lk[0-9]+/)
|
|
83
|
+
raw_html.delete_at 0
|
|
84
|
+
raw_html.inject do |memo, row|
|
|
85
|
+
c_info = row.match(/(e|dn)lk([0-9])+/)
|
|
86
|
+
|
|
87
|
+
# Same contact, or different?
|
|
88
|
+
build_contacts << [] if memo != c_info[2]
|
|
89
|
+
|
|
90
|
+
# Grab info
|
|
91
|
+
case c_info[1]
|
|
92
|
+
when "e" # Email
|
|
93
|
+
build_contacts.last[1] = row.match(/#{email_match_text_beginning}(.*)#{email_match_text_end}/)[1]
|
|
94
|
+
when "dn" # Name
|
|
95
|
+
build_contacts.last[0] = row.match(/<a[^>]*>(.+)<\/a>/)[1]
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Set memo to contact id
|
|
99
|
+
c_info[2]
|
|
100
|
+
end
|
|
81
101
|
|
|
82
102
|
go = resp.body.include?("Next page")
|
|
83
103
|
index += 1
|
|
84
104
|
end
|
|
85
105
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
106
|
+
build_contacts.each do |contact|
|
|
107
|
+
unless contact[1].nil?
|
|
108
|
+
# Only return contacts with email addresses
|
|
109
|
+
contact[1] = CGI::unescape(contact[1])
|
|
110
|
+
@contacts << contact
|
|
111
|
+
end
|
|
90
112
|
end
|
|
91
113
|
return @contacts
|
|
92
114
|
end
|