forki 0.2.16 → 0.2.18
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/lib/forki/scrapers/post_scraper.rb +23 -9
- data/lib/forki/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 828be4f10ea4ff3496585984d78878a1492bfb13691e6772e754e31a8e0654e9
|
4
|
+
data.tar.gz: 35b0d1cba36a195e95e4d649a3808455cd2f51917a619c536b55b3413395b719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e34ae0dd4d57660c075bf1c6d8a690ca8a65adb771739556ba2c8031918ee32e2829ce7aa419ff5533640f602a92b2f7f1dc00d852768ff30cfdab42a48f9732
|
7
|
+
data.tar.gz: 8de5a58ece6ae090ebd1a638cbbe4cff3168a0f439476dfb7490d53b982e1cf4e12bf97d5a1f453134867a64f1442c95c4569ad2bde4be49f88fdde68da0b6b1
|
@@ -33,12 +33,12 @@ module Forki
|
|
33
33
|
|
34
34
|
if post_is_text_only
|
35
35
|
extract_text_post_data(graphql_objects)
|
36
|
+
elsif post_has_image && !post_has_video && !post_has_video_in_comment_stream
|
37
|
+
extract_image_post_data(graphql_objects)
|
36
38
|
elsif post_has_video
|
37
39
|
extract_video_post_data(graphql_strings)
|
38
40
|
elsif post_has_video_in_comment_stream
|
39
41
|
extract_video_comment_post_data(graphql_objects)
|
40
|
-
elsif post_has_image
|
41
|
-
extract_image_post_data(graphql_objects)
|
42
42
|
else
|
43
43
|
extract_image_post_data(graphql_objects)
|
44
44
|
end
|
@@ -64,7 +64,17 @@ module Forki
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def check_if_post_is_video(graphql_objects)
|
67
|
-
graphql_objects.any?
|
67
|
+
result = graphql_objects.any? do |graphql_object|
|
68
|
+
next unless graphql_object.dig("viewer", "news_feed").nil?
|
69
|
+
|
70
|
+
result = graphql_object.to_s.include?("videoDeliveryLegacyFields")
|
71
|
+
result = graphql_object.key?("is_live_streaming") && graphql_object["is_live_streaming"] == true if result == false
|
72
|
+
result = graphql_object.key?("video") if result == false
|
73
|
+
result = check_if_post_is_reel(graphql_object) if result == false
|
74
|
+
result
|
75
|
+
end
|
76
|
+
|
77
|
+
result
|
68
78
|
end
|
69
79
|
|
70
80
|
def check_if_post_is_reel(graphql_object)
|
@@ -84,6 +94,7 @@ module Forki
|
|
84
94
|
return true unless graphql_object.fetch("image", nil).nil? # so long as the associated values are not nil
|
85
95
|
return true unless graphql_object.fetch("currMedia", nil).nil?
|
86
96
|
return true unless graphql_object.fetch("photo_image", nil).nil?
|
97
|
+
return true unless graphql_object.fetch("large_share_image", nil).nil?
|
87
98
|
|
88
99
|
# This is a complicated form for `web.facebook.com` posts
|
89
100
|
if !graphql_object.dig("node", "comet_sections", "content", "story", "attachments").nil?
|
@@ -298,7 +309,7 @@ module Forki
|
|
298
309
|
|
299
310
|
share_count_object = feedback_object.fetch("share_count", {})
|
300
311
|
|
301
|
-
if story_node_object["comet_sections"]["content"]["story"]["comet_sections"].key? "message"
|
312
|
+
if story_node_object["comet_sections"]["content"]["story"]["comet_sections"].key?("message") && !story_node_object["comet_sections"]["content"]["story"]["comet_sections"]["message"].nil?
|
302
313
|
text = story_node_object["comet_sections"]["content"]["story"]["comet_sections"]["message"]["story"]["message"]["text"]
|
303
314
|
else
|
304
315
|
text = ""
|
@@ -329,11 +340,10 @@ module Forki
|
|
329
340
|
reshare_warning = feedback_object["comet_ufi_summary_and_actions_renderer"]["feedback"]["should_show_reshare_warning"]
|
330
341
|
end
|
331
342
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
end
|
343
|
+
video_object_url_subsearch = video_object
|
344
|
+
video_object_url_subsearch = video_object_url_subsearch["videoDeliveryLegacyFields"] if video_object_url_subsearch.has_key?("videoDeliveryLegacyFields")
|
345
|
+
# if video_object.key?("browser_native_hd_url") || video_object.key?("browser_native_sd_url")
|
346
|
+
video_url = video_object_url_subsearch["browser_native_hd_url"] || video_object_url_subsearch["browser_native_sd_url"]
|
337
347
|
|
338
348
|
post_details = {
|
339
349
|
id: video_object["id"],
|
@@ -442,6 +452,10 @@ module Forki
|
|
442
452
|
if image_url.nil?
|
443
453
|
image_url = attachments.first&.dig("styles", "attachment", "media", "large_share_image", "uri")
|
444
454
|
end
|
455
|
+
|
456
|
+
if image_url.nil?
|
457
|
+
image_url = attachments.first&.dig("styles", "attachment", "media", "image", "uri")
|
458
|
+
end
|
445
459
|
end
|
446
460
|
|
447
461
|
text = graphql_object["node"]["comet_sections"]["content"]["story"].dig("message", "text")
|
data/lib/forki/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|