insta 0.2.7 → 0.2.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2d1b5be3b57015671ed6f7ac8188d670c6b145d11105d3384fd5813abfd3735
4
- data.tar.gz: 3262cd9ea438dd575c362e0081c5d2505cdb01f2d1d37d181576b36a13a33e58
3
+ metadata.gz: b07de8bff823379e8c5fb024fe5fc7031ddb716dc17d7b25c415da4d532ed175
4
+ data.tar.gz: 7a0ce471f26ebc75b0d912f2cbfc955b49aa473aac90b6f420058d56140af8a7
5
5
  SHA512:
6
- metadata.gz: 27400d75b7681cc19668727b4617fab94b22dc35591b7fea0fe0c0926d588c5a5e47726cc5979a1a61043e8beb8b0c2a25d1a30e4ab2d55d72e9129088c69795
7
- data.tar.gz: ee8f296dcf6b08acf82338250cdcf4c3a35781805223900d38587e16d786ad9bbd02d508a113e6c3eb85cf87b2922f54d01c6decd00b6659d7b0984995cb8963
6
+ metadata.gz: f61fc6c96f446b11fe57bf462621dfbf5cbe5af26cf4d4847c8f282310188429694809c30851fe6a4f08e3d720a12dcaa1b36361416e541ff376438ad8a9b9f7
7
+ data.tar.gz: cf0a4f61c2617d1a3501e1ccb8082cca119eaf2c059fa9cbea08e61b563a2bae0d540a92700bcba01d259dd1ef398b0729e2d02f4223cea03399f3b9dedfca3c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- insta (0.2.7)
4
+ insta (0.2.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = 'Welcome to Insta(pre-alpha) gem! This Gem is hard fork from vicoerv/instagram-private-api and the implement from huttarichard/instagram-private-api'
13
13
  spec.description = spec.summary
14
- spec.homepage = 'http://renangarcia.me'
14
+ spec.homepage = 'https://github.com/renan-garcia/insta'
15
15
  spec.license = 'MIT'
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
@@ -61,6 +61,39 @@ module Insta
61
61
  }
62
62
  end
63
63
 
64
+ def self.by_id(user, profile_id, data)
65
+ rank_token = Insta::API.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
66
+ endpoint = "https://i.instagram.com/api/v1/users/#{profile_id}/info/"
67
+ proxies = Insta::ProxyManager.new data[:proxies] unless data[:proxies].nil?
68
+ param = format('?is_typehead=true&rank_token=%s', rank_token)
69
+ result = Insta::API.http(
70
+ url: endpoint + param,
71
+ method: 'GET',
72
+ user: user,
73
+ proxy: proxies&.next
74
+ )
75
+
76
+ response = JSON.parse result.body, symbolize_names: true
77
+
78
+ return nil unless response[:user].any?
79
+ {
80
+ profile_id: response[:user][:id],
81
+ external_url: response[:user][:external_url],
82
+ followers: response[:user][:follower_count],
83
+ following: response[:user][:following_count],
84
+ full_name: response[:user][:full_name],
85
+ avatar_url: response[:user][:hd_profile_pic_url_info][:url],
86
+ avatar_url_hd: response[:user][:hd_profile_pic_url_info][:url],
87
+ username: response[:user][:username],
88
+ biography: response[:user][:biography],
89
+ verified: response[:user][:is_verified],
90
+ medias_count: response[:user][:media_count],
91
+ is_private: response[:user][:is_private],
92
+ phone: response[:user][:contact_phone_number],
93
+ email: response[:user][:public_email]
94
+ }
95
+ end
96
+
64
97
  def self.search_for_user(user, username, data)
65
98
  rank_token = Insta::API.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
66
99
  endpoint = 'https://i.instagram.com/api/v1/users/search/'
@@ -7,6 +7,8 @@ require 'insta/user'
7
7
  require 'insta/account'
8
8
  require 'insta/feed'
9
9
  require 'insta/configuration'
10
+ require 'insta/location'
11
+ require 'insta/tag'
10
12
 
11
13
  module Insta
12
14
  module API
@@ -0,0 +1,18 @@
1
+ module Insta
2
+ module Location
3
+ def self.by_id(user, location_id, data)
4
+ user_id = (!data[:id].nil? ? data[:id] : user.data[:id])
5
+ rank_token = Insta::API.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
6
+ endpoint = %Q[https://www.instagram.com/graphql/query/?query_id=17865274345132052&variables={"id":"#{location_id}","first":42,"after":"#{data.dig(:end_cursor)}"}]
7
+ proxies = Insta::ProxyManager.new data[:proxies] unless data[:proxies].nil?
8
+ result = Insta::API.http(
9
+ url: endpoint,
10
+ method: 'GET',
11
+ user: user,
12
+ proxy: proxies&.next
13
+ )
14
+
15
+ JSON.parse result.body
16
+ end
17
+ end
18
+ end
@@ -8,7 +8,7 @@ module Insta
8
8
  def initialize(proxies = [])
9
9
  proxies.each do |proxy|
10
10
  proxy[:id] = SecureRandom.uuid
11
- proxy[:last_use] = nil
11
+ proxy[:last_use] = Time.now
12
12
  end
13
13
  @proxies = proxies
14
14
  end
@@ -0,0 +1,18 @@
1
+ module Insta
2
+ module Tag
3
+ def self.find(user, tag, data)
4
+ user_id = (!data[:id].nil? ? data[:id] : user.data[:id])
5
+ rank_token = Insta::API.generate_rank_token user.session.scan(/ds_user_id=([\d]+);/)[0][0]
6
+ endpoint = %Q[https://www.instagram.com/graphql/query/?query_id=17875800862117404&variables={"tag_name":"#{tag}","first":42,"after":"#{data.dig(:end_cursor)}"}]
7
+ proxies = Insta::ProxyManager.new data[:proxies] unless data[:proxies].nil?
8
+ result = Insta::API.http(
9
+ url: endpoint,
10
+ method: 'GET',
11
+ user: user,
12
+ proxy: proxies&.next
13
+ )
14
+
15
+ JSON.parse result.body
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Insta
2
- VERSION = '0.2.7'.freeze
2
+ VERSION = '0.2.9'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renan Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-20 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,10 +81,12 @@ files:
81
81
  - lib/insta/constants.rb
82
82
  - lib/insta/device.rb
83
83
  - lib/insta/feed.rb
84
+ - lib/insta/location.rb
84
85
  - lib/insta/proxy_manager.rb
86
+ - lib/insta/tag.rb
85
87
  - lib/insta/user.rb
86
88
  - lib/insta/version.rb
87
- homepage: http://renangarcia.me
89
+ homepage: https://github.com/renan-garcia/insta
88
90
  licenses:
89
91
  - MIT
90
92
  metadata: