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.
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
- end
16
-
17
- inject_variables(params)
18
- end
19
-
20
- def inject_variables(params)
21
- params.each { |key, value| instance_variable_set(:"@#{key}", value) }
22
- end
23
-
24
- def search_for_user(username)
25
- account.search_for_user(self, username)
26
- end
27
-
28
- def search_for_user_graphql(username)
29
- account.search_for_graphql(self, username)
30
- end
31
-
32
- def followers(limit = Float::INFINITY, data = {})
33
- IgApi::Feed.user_followers(self, data, limit)
34
- end
35
-
36
- def user_followers_graphql(limit = Float::INFINITY, data = {})
37
- IgApi::Feed.user_followers_graphql(self, data, limit)
38
- end
39
-
40
- def relationship
41
- unless instance_variable_defined? :@relationship
42
- @relationship = Relationship.new self
43
- end
44
-
45
- @relationship
46
- end
47
-
48
- def account
49
- @account = IgApi::Account.new if @account.nil?
50
-
51
- @account
52
- end
53
-
54
- def feed
55
- @feed = IgApi::Feed.new if @feed.nil?
56
-
57
- @feed.using(self)
58
- end
59
-
60
- def thread
61
- @thread = IgApi::Thread.new unless defined? @thread
62
-
63
- @thread.using self
64
- end
65
-
66
- def md5
67
- Digest::MD5.hexdigest @username
68
- end
69
-
70
- def md5int
71
- (md5.to_i(32) / 10e32).round
72
- end
73
-
74
- def api
75
- (18 + (md5int % 5)).to_s
76
- end
77
-
78
- # @return [string]
79
- def release
80
- %w[4.0.4 4.3.1 4.4.4 5.1.1 6.0.1][md5int % 5]
81
- end
82
-
83
- def dpi
84
- %w[801 577 576 538 515 424 401 373][md5int % 8]
85
- end
86
-
87
- def resolution
88
- %w[3840x2160 1440x2560 2560x1440 1440x2560
89
- 2560x1440 1080x1920 1080x1920 1080x1920][md5int % 8]
90
- end
91
-
92
- def info
93
- line = Device.devices[md5int % Device.devices.count]
94
- {
95
- manufacturer: line[0],
96
- device: line[1],
97
- model: line[2]
98
- }
99
- end
100
-
101
- def useragent_hash
102
- agent = [api + '/' + release, dpi + 'dpi',
103
- resolution, info[:manufacturer],
104
- info[:model], info[:device], @language]
105
-
106
- {
107
- agent: agent.join('; '),
108
- version: Constants::PRIVATE_KEY[:APP_VERSION]
109
- }
110
- end
111
-
112
- def useragent
113
- format('Instagram %s Android(%s)', useragent_hash[:version], useragent_hash[:agent].rstrip)
114
- end
115
-
116
- def device_id
117
- 'android-' + md5[0..15]
118
- end
119
- end
120
- end
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
@@ -1,3 +1,3 @@
1
- module IgApi
2
- VERSION = "0.0.15"
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.15
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-26 00:00:00.000000000 Z
11
+ date: 2018-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler