Class: Insta::User

Inherits:
Object
  • Object
show all
Defined in:
lib/insta/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username, password, session = nil, data = nil, config = nil) ⇒ User

Returns a new instance of User.



17
18
19
20
21
22
23
24
# File 'lib/insta/user.rb', line 17

def initialize(username, password, session = nil, data = nil, config = nil)
  @username = username
  @password = password
  @language = 'en_US'
  @session = session
  @data = data
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



14
15
16
# File 'lib/insta/user.rb', line 14

def config
  @config
end

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/insta/user.rb', line 10

def data
  @data
end

#languageObject (readonly)

Returns the value of attribute language.



9
10
11
# File 'lib/insta/user.rb', line 9

def language
  @language
end

#passwordObject (readonly)

Returns the value of attribute password.



8
9
10
# File 'lib/insta/user.rb', line 8

def password
  @password
end

#sessionObject

Returns the value of attribute session.



12
13
14
# File 'lib/insta/user.rb', line 12

def session
  @session
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/insta/user.rb', line 7

def username
  @username
end

Instance Method Details

#apiObject



58
59
60
# File 'lib/insta/user.rb', line 58

def api
  (18 + (md5int % 5)).to_s
end

#device_idObject



99
100
101
# File 'lib/insta/user.rb', line 99

def device_id
  'android-' + md5[0..15]
end

#dpiObject



67
68
69
# File 'lib/insta/user.rb', line 67

def dpi
  %w[801 577 576 538 515 424 401 373][md5int % 8]
end

#infoObject



76
77
78
79
80
81
82
83
# File 'lib/insta/user.rb', line 76

def info
  line = Device.devices[md5int % Device.devices.count]
  {
    manufacturer: line[0],
    device: line[1],
    model: line[2]
  }
end

#md5Object



50
51
52
# File 'lib/insta/user.rb', line 50

def md5
  Digest::MD5.hexdigest @username
end

#md5intObject



54
55
56
# File 'lib/insta/user.rb', line 54

def md5int
  (md5.to_i(32) / 10e32).round
end

#releasestring

Returns:

  • (string)


63
64
65
# File 'lib/insta/user.rb', line 63

def release
  %w[4.0.4 4.3.1 4.4.4 5.1.1 6.0.1][md5int % 5]
end

#resolutionObject



71
72
73
74
# File 'lib/insta/user.rb', line 71

def resolution
  %w[3840x2160 1440x2560 2560x1440 1440x2560
     2560x1440 1080x1920 1080x1920 1080x1920][md5int % 8]
end

#search_for_user(username, data = {}) ⇒ Object



26
27
28
# File 'lib/insta/user.rb', line 26

def search_for_user (username, data = {})
  Insta::Account.search_for_user(self, username, data)
end

#search_for_user_graphql(username, data = {}) ⇒ Object



30
31
32
# File 'lib/insta/user.rb', line 30

def search_for_user_graphql (username, data = {})
  Insta::Account.search_for_user_graphql(self, username, data)
end

#user_followers(limit = Float::INFINITY, data = {}) ⇒ Object



42
43
44
# File 'lib/insta/user.rb', line 42

def user_followers(limit = Float::INFINITY, data = {})
  Insta::Feed.user_followers(self, data, limit)
end

#user_followers_graphql(limit = Float::INFINITY, data = {}) ⇒ Object



46
47
48
# File 'lib/insta/user.rb', line 46

def user_followers_graphql(limit = Float::INFINITY, data = {})
  Insta::Feed.user_followers_graphql(self, data, limit)
end

#user_media(data = {}) ⇒ Object



34
35
36
# File 'lib/insta/user.rb', line 34

def user_media(data = {})
  Insta::Feed.user_media(self, data)
end

#user_media_graphql(data = {}) ⇒ Object



38
39
40
# File 'lib/insta/user.rb', line 38

def user_media_graphql(data = {})
  Insta::Feed.user_media_graphql(self, data)
end

#useragentObject



95
96
97
# File 'lib/insta/user.rb', line 95

def useragent
  format('Instagram %s Android(%s)', useragent_hash[:version], useragent_hash[:agent].rstrip)
end

#useragent_hashObject



85
86
87
88
89
90
91
92
93
# File 'lib/insta/user.rb', line 85

def useragent_hash
  agent = [api + '/' + release, dpi + 'dpi',
           resolution, info[:manufacturer], info[:model], info[:device], @language]

  {
    agent: agent.join('; '),
    version: CONSTANTS::PRIVATE_KEY[:APP_VERSION]
  }
end