liangzan-contacts 1.2.14 → 1.2.15

Sign up to get free protection for your applications and to get access to all the features.
data/lib/contacts.rb CHANGED
@@ -12,3 +12,6 @@ require 'aol'
12
12
  require 'mailru'
13
13
  require 'gmx'
14
14
  require 'web_de'
15
+ require 'seznam'
16
+ require 'onelt'
17
+ require 'inbox_lt'
@@ -0,0 +1,89 @@
1
+ class Contacts
2
+ class InboxLt < Base
3
+ URL = "http://www.inbox.lt/?language=lt"
4
+ LOGIN_URL = "https://login.inbox.lt/redirect.php"
5
+ ADDRESS_BOOK_URL = "http://mail.inbox.lt/horde/turba/?char=&sort=name&page=%d"
6
+ PROTOCOL_ERROR = "inbox.lt has changed its protocols"
7
+
8
+ attr_accessor :cookies
9
+
10
+ def real_connect
11
+ data, resp, self.cookies, forward = get(URL, "")
12
+
13
+ doc = Nokogiri(data)
14
+
15
+ salt_el = doc.at('input[name=salt]')
16
+
17
+ if salt_el.nil?
18
+ raise ConnectionError, PROTOCOL_ERROR
19
+ end
20
+
21
+ salt = salt_el['value']
22
+
23
+ postdata = "language=lt&passhash=&salt=%s&redirect_url=%s&redirect_vars=imapuser,usessl&imapuser=%s&pass=%s&usessl=1" % [
24
+ CGI.escape(salt),
25
+ CGI.escape('http://www.inbox.lt/index.php?actionID=imp_login'),
26
+ CGI.escape(username),
27
+ CGI.escape(password)
28
+ ]
29
+
30
+ data, resp, self.cookies, forward = post(LOGIN_URL, postdata, "")
31
+
32
+ if forward.nil? || !forward.match("logged_in=1")
33
+ raise AuthenticationError, "Username and password do not match"
34
+ end
35
+
36
+ until forward.nil?
37
+ data, resp, self.cookies, forward = get(forward, self.cookies)
38
+ end
39
+ end
40
+
41
+ def contacts
42
+ @contacts = []
43
+ page = 0
44
+
45
+ until page.nil?
46
+ url = ADDRESS_BOOK_URL % page
47
+
48
+ data, resp, self.cookies, forward = get(url, self.cookies)
49
+
50
+ doc = Nokogiri(data)
51
+
52
+ (doc/"form#contactsForm table table[1] tr").each do |tr|
53
+ name_td = tr.at('td[2]')
54
+ email_td = tr.at('td[3]')
55
+
56
+ next if name_td.nil? || email_td.nil?
57
+
58
+ name = name_td.text.strip
59
+ email = email_td.text.strip
60
+
61
+ next unless email.match('@')
62
+
63
+ @contacts << [ name, email ]
64
+ end
65
+
66
+ page+= 1
67
+ page = nil unless data.match("&page=#{page}")
68
+ end
69
+
70
+ @contacts
71
+ end
72
+
73
+ def skip_gzip?
74
+ false
75
+ end
76
+
77
+ private
78
+
79
+ def username
80
+ @login.split('@').first
81
+ end
82
+
83
+ def domain
84
+ @login.split('@').last
85
+ end
86
+ end
87
+
88
+ TYPES[:inbox_lt] = InboxLt
89
+ end
@@ -0,0 +1,89 @@
1
+ class Contacts
2
+ class Onelt < Base
3
+ LOGIN_URL = "http://w33.one.lt/logonSubsite.do?subsite=pastas"
4
+ EMAIL_URL = "http://email.one.lt/"
5
+ ADDRESS_BOOK_URL = "http://email.one.lt/index.html?screen=RedirectServer&pane=contacts"
6
+ PROTOCOL_ERROR = "One.lt has changed its protocols, please upgrade this library first. If that does not work, report this error at http://rubyforge.org/forum/?group_id=2693"
7
+
8
+ attr_accessor :cookies
9
+
10
+ def real_connect
11
+ data, resp, self.cookies, forward = get(LOGIN_URL)
12
+
13
+ postdata = "username=%s&password=%s&subsite=pastas" % [
14
+ CGI.escape(username),
15
+ CGI.escape(password)
16
+ ]
17
+
18
+ data, resp, self.cookies, forward, old_url = post(LOGIN_URL, postdata, self.cookies)
19
+
20
+ if data.index("f-login")
21
+ raise AuthenticationError, "Username and password do not match"
22
+ elsif !forward.nil? && forward.match('brutecheck')
23
+ raise AuthenticationError, "Got captcha"
24
+ elsif forward.nil? || !forward.match('tkn')
25
+ raise ConnectionError, PROTOCOL_ERROR
26
+ end
27
+
28
+ forward+= '&subsite=pastas' unless forward.match('subsite=pastas')
29
+ #p forward
30
+
31
+ # http://w32.one.lt/logonSubsite.do?subsite=pastas&tkn=3229
32
+ data, resp, self.cookies, forward, old_url = get(forward, self.cookies, LOGIN_URL) + [forward]
33
+
34
+ # http://pastas.one.lt/?tkn=979
35
+ data, resp, self.cookies, forward, old_url = get(forward, self.cookies, old_url) + [forward]
36
+
37
+ # http://email.one.lt/?action=LoginUser
38
+ data, resp, self.cookies, forward, old_url = get(forward, self.cookies, old_url) + [forward]
39
+ end
40
+
41
+ def contacts
42
+ data, resp, self.cookies, forward = get(ADDRESS_BOOK_URL, self.cookies)
43
+
44
+ doc = Nokogiri(data)
45
+ int = nil
46
+
47
+ (doc/"input[name=int]").each do |input|
48
+ int = input['value']
49
+ end
50
+
51
+ postdata = "action=LoginUser&pane=contacts&int=#{int}"
52
+ data, resp, self.cookies, forward = post(EMAIL_URL, postdata, self.cookies)
53
+
54
+ contacts = []
55
+ page = 1
56
+
57
+ until page.nil?
58
+ url = "http://email.one.lt/index.html?pane=contacts&page-number=%d" % page
59
+
60
+ data, resp, self.cookies, forward = get(url, self.cookies)
61
+
62
+ doc = Nokogiri(data)
63
+
64
+ (doc/'form[name=contacts_items]//table[2]//tr[class=whiteBg]').each do |tr|
65
+ name = tr.at('td[2]').text.strip
66
+ email = tr.at('td[4]').text.strip
67
+
68
+ next if email.empty?
69
+
70
+ contacts << [ name, email ]
71
+ end
72
+
73
+ page+= 1
74
+ page = nil unless data.match("&page-number=#{page}")
75
+ end
76
+
77
+ contacts
78
+ end
79
+
80
+ private
81
+
82
+ def username
83
+ login.split('@').first
84
+ end
85
+
86
+ end
87
+
88
+ TYPES[:onelt] = Onelt
89
+ end
@@ -0,0 +1,78 @@
1
+ class Contacts
2
+ class Seznam < Base
3
+ LOGIN_URL = "https://login.szn.cz/loginProcess"
4
+ ADDRESS_BOOK_URL = "http://email.seznam.cz/abookCsvExport?sessionId=&charset=utf-8&eof=windows&export=nameLast&export=nameFirst&export=nick&export=email"
5
+
6
+ attr_accessor :cookies
7
+
8
+ def real_connect
9
+ postdata = "disableSSL=0&domain=%s&forceRelogin=0&forceSSL=0&lang=cz&loginType=seznam&returnURL=%s&serviceId=email&username=%s&password=%s" % [
10
+ CGI.escape(domain),
11
+ CGI.escape('http://email.seznam.cz/ticket'),
12
+ CGI.escape(username),
13
+ CGI.escape(password)
14
+ ]
15
+
16
+ data, resp, self.cookies, forward = post(LOGIN_URL, postdata, "")
17
+
18
+ if !forward.nil? && forward.match("badLogin")
19
+ raise AuthenticationError, "Username and password do not match"
20
+ end
21
+
22
+ doc = Nokogiri(data)
23
+
24
+ a = doc.at('body>a')
25
+ forward = a['href'].to_s
26
+
27
+ data, resp, self.cookies, forward = get(forward, self.cookies)
28
+
29
+ doc = Nokogiri(data)
30
+
31
+ a = doc.at('body>a')
32
+ forward = a['href'].to_s
33
+
34
+ data, resp, self.cookies, forward = get(forward, self.cookies)
35
+
36
+ doc = Nokogiri(data)
37
+
38
+ a = doc.at('body>a')
39
+ forward = a['href'].to_s
40
+
41
+ data, resp, self.cookies, forward = get(forward, self.cookies)
42
+ end
43
+
44
+ def contacts
45
+ url = ADDRESS_BOOK_URL
46
+ @contacts = []
47
+
48
+ data, resp, self.cookies, forward = get(url, self.cookies)
49
+
50
+ CSV.parse(data, { :col_sep => ';' }) do |row|
51
+ last_name, first_name, unknown, email = row
52
+
53
+ name = "#{first_name} #{last_name}".strip
54
+ email.strip!
55
+
56
+ @contacts << [name, email] unless email.empty?
57
+ end
58
+
59
+ @contacts
60
+ end
61
+
62
+ def skip_gzip?
63
+ false
64
+ end
65
+
66
+ private
67
+
68
+ def username
69
+ @login.split('@').first
70
+ end
71
+
72
+ def domain
73
+ @login.split('@').last
74
+ end
75
+ end
76
+
77
+ TYPES[:seznam] = Seznam
78
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liangzan-contacts
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.14
4
+ version: 1.2.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,11 +13,11 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-03-16 00:00:00.000000000Z
16
+ date: 2012-03-19 00:00:00.000000000Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
20
- requirement: &16259460 !ruby/object:Gem::Requirement
20
+ requirement: &14950380 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ~>
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: 1.6.5
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *16259460
28
+ version_requirements: *14950380
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: gdata_19
31
- requirement: &16258000 !ruby/object:Gem::Requirement
31
+ requirement: &14949380 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ~>
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: 1.1.3
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *16258000
39
+ version_requirements: *14949380
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: nokogiri
42
- requirement: &16257180 !ruby/object:Gem::Requirement
42
+ requirement: &14948500 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ~>
@@ -47,19 +47,23 @@ dependencies:
47
47
  version: 1.5.0
48
48
  type: :runtime
49
49
  prerelease: false
50
- version_requirements: *16257180
50
+ version_requirements: *14948500
51
51
  description: A universal interface to grab contact list information from Yahoo, AOL,
52
- Gmail, Hotmail, Plaxo, GMX, Web.de. Now supporting Ruby 1.9.
52
+ Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.it, sezname.cz. Now supporting Ruby
53
+ 1.9.
53
54
  email: zan@liangzan.net
54
55
  executables: []
55
56
  extensions: []
56
57
  extra_rdoc_files: []
57
58
  files:
59
+ - lib/contacts/inbox_lt.rb
58
60
  - lib/contacts/base.rb
59
61
  - lib/contacts/web_de.rb
60
62
  - lib/contacts/gmail.rb
61
63
  - lib/contacts/plaxo.rb
64
+ - lib/contacts/onelt.rb
62
65
  - lib/contacts/yahoo.rb
66
+ - lib/contacts/seznam.rb
63
67
  - lib/contacts/hotmail.rb
64
68
  - lib/contacts/mailru.rb
65
69
  - lib/contacts/aol.rb
@@ -93,5 +97,6 @@ rubyforge_project:
93
97
  rubygems_version: 1.8.10
94
98
  signing_key:
95
99
  specification_version: 3
96
- summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo, GMX and Web.de
100
+ summary: grab contacts from Yahoo, AOL, Gmail, Hotmail, Plaxo, GMX.net, Web.de, inbox.it,
101
+ seznam.cz
97
102
  test_files: []