zorki 0.2.2 → 0.2.3

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: 0fa3c3b7f010024623a447e581f06d1aa5586726eee06b0e3bc04533dd86d6af
4
- data.tar.gz: b9dfb531fd1207c3ece23e12132ff1d3cb57f3177eacaa1af0e4fea95d06041f
3
+ metadata.gz: dc52913230d63a501d9d7fba1ebb80f11cd5f47031711d0cb287da2a6b16fc93
4
+ data.tar.gz: 0c4aec5fcdf10a82265e9f2c405021ced45dd2c76e1e5b4ed9b8cbd275d680cf
5
5
  SHA512:
6
- metadata.gz: 7c4eb7c2937b6c66529a23fc6fdbf0822ba102289a4327f8aaa5fa298692fc4a284476c5e0e4b916dd6fdc8f68618a6af5de8a2a75adec9782390bbc946a2148
7
- data.tar.gz: caed78e1ef882b10d216973443fa48f75d9f090ca31c718e5dd4395f9306a36f67a8ecb056143b9ba677bb97e605ed586f11c1db00c5542425d7f6c0960c3808
6
+ metadata.gz: 80036f9121369b7684ef6ba739be20c83b305c53c4959f7af8918a573f0af1755a4793a8f8c089b1040618bf8c6c15229948de8d7383c10dc5b67cb63bd6a7bc
7
+ data.tar.gz: b3cb6f9e5846df66990294c78f8aa925e5205e413a7ef463affa9a165c98cb5cb8a24e6110b3d90486425549899d87bff8ce3872384a57cbca0baf634f2005d8
@@ -165,12 +165,14 @@ module Zorki
165
165
  images << Zorki.retrieve_media(object["display_resources"].last["src"])
166
166
  end
167
167
  end
168
+
169
+ user = User.from_post_data(object["owner"])
168
170
  end
169
171
 
170
172
  screenshot_file = take_screenshot()
171
173
 
172
174
  # This has to run last since it switches pages
173
- user = User.lookup([username]).first
175
+ user = User.lookup([username]).first if defined?(user).nil?
174
176
 
175
177
  {
176
178
  images: images,
data/lib/zorki/user.rb CHANGED
@@ -12,6 +12,52 @@ module Zorki
12
12
  self.scrape(usernames)
13
13
  end
14
14
 
15
+ def self.from_post_data(data)
16
+ # "owner"=>
17
+ # {"id"=>"4303258197",
18
+ # "username"=>"petesouza",
19
+ # "is_verified"=>true,
20
+ # "profile_pic_url"=>
21
+ # "https://scontent-lax3-1.cdninstagram.com/v/t51.2885-19/433045134_436644512119229_523706897615373693_n.jpg?stp=dst-jpg_s150x150&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=1&_nc_ohc=N0A8l8Th9soQ7kNvgH0cKQQ&_nc_gid=29538825d3464a6f9b05bad4506fc1f9&edm=ANTKIIoBAAAA&ccb=7-5&oh=00_AYCIj0oEKb48mFW3Ag4tMW3nJitOdAe91hdIrIM_1nlwEw&oe=67163EE4&_nc_sid=d885a2",
22
+ # "blocked_by_viewer"=>false,
23
+ # "restricted_by_viewer"=>nil,
24
+ # "followed_by_viewer"=>false,
25
+ # "full_name"=>"Pete Souza",
26
+ # "has_blocked_viewer"=>false,
27
+ # "is_embeds_disabled"=>true,
28
+ # "is_private"=>false,
29
+ # "is_unpublished"=>false,
30
+ # "requested_by_viewer"=>false,
31
+ # "pass_tiering_recommendation"=>true,
32
+ # "edge_owner_to_timeline_media"=>{"count"=>3596},
33
+ # "edge_followed_by"=>{"count"=>3166659}},
34
+
35
+ new_user_hash = {
36
+ name: data["full_name"],
37
+ username: data["username"],
38
+ number_of_posts: data["edge_owner_to_timeline_media"]["count"],
39
+ number_of_followers: data["edge_followed_by"]["count"],
40
+ number_of_following: nil,
41
+ verified: data["is_verified"],
42
+ profile: nil,
43
+ profile_link: "https://www.instagram.com/#{data["username"]}",
44
+ profile_image: Zorki.retrieve_media(data["profile_pic_url"]),
45
+ profile_image_url: data["profile_pic_url"]
46
+ }
47
+
48
+ # Now we try and populate the profile
49
+ begin
50
+ scraped_user_hash = Zorki::UserScraper.new.parse(data["username"])
51
+ new_user_hash[number_of_following: scraped_user_hash[:number_of_following]]
52
+ new_user_hash[profile: scraped_user_hash[:profile]]
53
+ rescue StandardError
54
+ puts "#{new_user_hash[:name]}: User created, but cannot fill in the extra data"
55
+ # If this didn't work we'll eat the error in the interest of completing successfully.
56
+ end
57
+
58
+ User.new(new_user_hash)
59
+ end
60
+
15
61
  attr_reader :name,
16
62
  :username,
17
63
  :number_of_posts,
data/lib/zorki/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zorki
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zorki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Guess