ig_api 0.0.15 → 0.0.16
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.
- checksums.yaml +4 -4
- data/.rspec +3 -3
- data/.rubocop.yml +3 -3
- data/.travis.yml +5 -5
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +5 -5
- data/Gemfile.lock +38 -38
- data/LICENSE.txt +21 -21
- data/README.md +56 -56
- data/Rakefile +6 -6
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/ig_api.gemspec +38 -38
- data/lib/ig_api/account.rb +118 -115
- data/lib/ig_api/configuration.rb +4 -4
- data/lib/ig_api/constants.rb +22 -22
- data/lib/ig_api/device.rb +11851 -11851
- data/lib/ig_api/feed.rb +65 -77
- data/lib/ig_api/http.rb +119 -120
- data/lib/ig_api/thread.rb +56 -3
- data/lib/ig_api/user.rb +128 -120
- data/lib/ig_api/version.rb +3 -3
- data/lib/ig_api.rb +11 -11
- metadata +2 -2
data/lib/ig_api/user.rb
CHANGED
@@ -1,120 +1,128 @@
|
|
1
|
-
require 'ig_api/device'
|
2
|
-
require 'ig_api/constants'
|
3
|
-
|
4
|
-
module IgApi
|
5
|
-
class User
|
6
|
-
attr_reader :password, :language
|
7
|
-
attr_accessor :username, :config, :session, :data
|
8
|
-
|
9
|
-
def initialize(params = {})
|
10
|
-
@account = nil
|
11
|
-
@feed = nil
|
12
|
-
|
13
|
-
if params.key? :session
|
14
|
-
@username = params[:session].scan(/ds_user=(.*?);/)[0][0]
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
@
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
def
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
def
|
88
|
-
%w[
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
|
120
|
-
|
1
|
+
require 'ig_api/device'
|
2
|
+
require 'ig_api/constants'
|
3
|
+
|
4
|
+
module IgApi
|
5
|
+
class User
|
6
|
+
attr_reader :password, :language
|
7
|
+
attr_accessor :username, :config, :session, :data
|
8
|
+
|
9
|
+
def initialize(params = {})
|
10
|
+
@account = nil
|
11
|
+
@feed = nil
|
12
|
+
|
13
|
+
if params.key? :session
|
14
|
+
@username = params[:session].scan(/ds_user=(.*?);/)[0][0]
|
15
|
+
|
16
|
+
id = params[:session].scan(/ds_user_id=(\d+)/)[0][0]
|
17
|
+
|
18
|
+
if data.nil?
|
19
|
+
@data = { id: id }
|
20
|
+
else
|
21
|
+
@data[:id] = id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
inject_variables(params)
|
26
|
+
end
|
27
|
+
|
28
|
+
def inject_variables(params)
|
29
|
+
params.each { |key, value| instance_variable_set(:"@#{key}", value) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def search_for_user(username)
|
33
|
+
account.search_for_user(self, username)
|
34
|
+
end
|
35
|
+
|
36
|
+
def search_for_user_graphql(username)
|
37
|
+
account.search_for_graphql(self, username)
|
38
|
+
end
|
39
|
+
|
40
|
+
def followers(limit = Float::INFINITY, data = {})
|
41
|
+
IgApi::Feed.user_followers(self, data, limit)
|
42
|
+
end
|
43
|
+
|
44
|
+
def user_followers_graphql(limit = Float::INFINITY, data = {})
|
45
|
+
IgApi::Feed.user_followers_graphql(self, data, limit)
|
46
|
+
end
|
47
|
+
|
48
|
+
def relationship
|
49
|
+
unless instance_variable_defined? :@relationship
|
50
|
+
@relationship = Relationship.new self
|
51
|
+
end
|
52
|
+
|
53
|
+
@relationship
|
54
|
+
end
|
55
|
+
|
56
|
+
def account
|
57
|
+
@account = IgApi::Account.new if @account.nil?
|
58
|
+
|
59
|
+
@account
|
60
|
+
end
|
61
|
+
|
62
|
+
def feed
|
63
|
+
@feed = IgApi::Feed.new if @feed.nil?
|
64
|
+
|
65
|
+
@feed.using(self)
|
66
|
+
end
|
67
|
+
|
68
|
+
def thread
|
69
|
+
@thread = IgApi::Thread.new unless defined? @thread
|
70
|
+
|
71
|
+
@thread.using self
|
72
|
+
end
|
73
|
+
|
74
|
+
def md5
|
75
|
+
Digest::MD5.hexdigest @username
|
76
|
+
end
|
77
|
+
|
78
|
+
def md5int
|
79
|
+
(md5.to_i(32) / 10e32).round
|
80
|
+
end
|
81
|
+
|
82
|
+
def api
|
83
|
+
(18 + (md5int % 5)).to_s
|
84
|
+
end
|
85
|
+
|
86
|
+
# @return [string]
|
87
|
+
def release
|
88
|
+
%w[4.0.4 4.3.1 4.4.4 5.1.1 6.0.1][md5int % 5]
|
89
|
+
end
|
90
|
+
|
91
|
+
def dpi
|
92
|
+
%w[801 577 576 538 515 424 401 373][md5int % 8]
|
93
|
+
end
|
94
|
+
|
95
|
+
def resolution
|
96
|
+
%w[3840x2160 1440x2560 2560x1440 1440x2560
|
97
|
+
2560x1440 1080x1920 1080x1920 1080x1920][md5int % 8]
|
98
|
+
end
|
99
|
+
|
100
|
+
def info
|
101
|
+
line = Device.devices[md5int % Device.devices.count]
|
102
|
+
{
|
103
|
+
manufacturer: line[0],
|
104
|
+
device: line[1],
|
105
|
+
model: line[2]
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
def useragent_hash
|
110
|
+
agent = [api + '/' + release, dpi + 'dpi',
|
111
|
+
resolution, info[:manufacturer],
|
112
|
+
info[:model], info[:device], @language]
|
113
|
+
|
114
|
+
{
|
115
|
+
agent: agent.join('; '),
|
116
|
+
version: Constants::PRIVATE_KEY[:APP_VERSION]
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def useragent
|
121
|
+
format('Instagram %s Android(%s)', useragent_hash[:version], useragent_hash[:agent].rstrip)
|
122
|
+
end
|
123
|
+
|
124
|
+
def device_id
|
125
|
+
'android-' + md5[0..15]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
data/lib/ig_api/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module IgApi
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
1
|
+
module IgApi
|
2
|
+
VERSION = "0.0.16"
|
3
|
+
end
|
data/lib/ig_api.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ig_api/http'
|
4
|
-
require 'ig_api/user'
|
5
|
-
require 'ig_api/device'
|
6
|
-
require 'ig_api/thread'
|
7
|
-
require 'ig_api/constants'
|
8
|
-
require 'ig_api/relationship'
|
9
|
-
|
10
|
-
# Root module
|
11
|
-
module IgApi
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ig_api/http'
|
4
|
+
require 'ig_api/user'
|
5
|
+
require 'ig_api/device'
|
6
|
+
require 'ig_api/thread'
|
7
|
+
require 'ig_api/constants'
|
8
|
+
require 'ig_api/relationship'
|
9
|
+
|
10
|
+
# Root module
|
11
|
+
module IgApi
|
12
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ig_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vicoerv
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|