scrape_creators 0.3.0 → 0.4.0
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/scrape_creators/client.rb +19 -14
- data/lib/scrape_creators/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 41069945ebf877cbd439c8bfbb318ba0114d4e9df6275aabacef16867417a7b4
|
|
4
|
+
data.tar.gz: 24d8743a67a698cfc97f974015a8ff30ab33254b8dd155e96f1d4b0283e9d9c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fdab6ab8877d97093743a3e52d3daa17bf33ac1c4b3a461b6ea85957e83bff213b9e27adbaa878b36e9af15858f014334aceda898beae6cb9d498d15e56e2d1f
|
|
7
|
+
data.tar.gz: ddeaf8dc9f781648485b348a3ccaeb660a2dfe47a611e37a6c0cd9283fae66179a91521c11be731faf698b8cf22683cf5a8b8b3862b198d1c148f20641011bda
|
|
@@ -10,6 +10,7 @@ module ScrapeCreators
|
|
|
10
10
|
class Client
|
|
11
11
|
TIKTOK = 'tiktok'
|
|
12
12
|
INSTAGRAM = 'instagram'
|
|
13
|
+
YOUTUBE = 'youtube'
|
|
13
14
|
|
|
14
15
|
attr_reader :config, :api_key
|
|
15
16
|
|
|
@@ -19,59 +20,63 @@ module ScrapeCreators
|
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def posts_url_for(source:)
|
|
22
|
-
case source
|
|
23
|
+
case source.to_s
|
|
23
24
|
when TIKTOK then '/v3/tiktok/profile/videos'
|
|
24
25
|
when INSTAGRAM then '/v2/instagram/user/posts'
|
|
26
|
+
when YOUTUBE then '/v1/youtube/channel/shorts'
|
|
25
27
|
else '/404'
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def post_url_for(source:)
|
|
30
|
-
case source
|
|
32
|
+
case source.to_s
|
|
31
33
|
when TIKTOK then '/v2/tiktok/video'
|
|
32
34
|
when INSTAGRAM then '/v1/instagram/post'
|
|
35
|
+
when YOUTUBE then '/v1/youtube/video'
|
|
33
36
|
else '/404'
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
def comments_url_for(source:)
|
|
38
|
-
case source
|
|
41
|
+
case source.to_s
|
|
39
42
|
when TIKTOK then '/v1/tiktok/video/comments'
|
|
40
43
|
when INSTAGRAM then '/v2/instagram/post/comments'
|
|
44
|
+
when YOUTUBE then '/v1/youtube/video/comments'
|
|
41
45
|
else '/404'
|
|
42
46
|
end
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
def posts_key_for(source:)
|
|
46
|
-
case source
|
|
50
|
+
case source.to_s
|
|
47
51
|
when TIKTOK then 'aweme_list'
|
|
48
52
|
when INSTAGRAM then 'items'
|
|
53
|
+
when YOUTUBE then 'shorts'
|
|
49
54
|
else 'items'
|
|
50
55
|
end
|
|
51
56
|
end
|
|
52
57
|
|
|
53
58
|
def posts(handle, options = {})
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
posts_url = posts_url_for(source:)
|
|
59
|
+
source = (options[:source] || 'instagram').to_s
|
|
60
|
+
params = { handle: handle }.merge(options.reject { |k, _| k.to_s == 'source' })
|
|
61
|
+
posts_url = posts_url_for(source: source)
|
|
57
62
|
res = get(posts_url, params)
|
|
58
|
-
key = posts_key_for(source:)
|
|
63
|
+
key = posts_key_for(source: source)
|
|
59
64
|
res.is_a?(Hash) ? (res[key] || []) : []
|
|
60
65
|
end
|
|
61
66
|
|
|
62
67
|
def post(url_or_code, options = {})
|
|
68
|
+
source = (options[:source] || 'instagram').to_s
|
|
63
69
|
url = normalize_url(url_or_code)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
params = { url: url }.merge(options)
|
|
70
|
+
post_url = post_url_for(source: source)
|
|
71
|
+
params = { url: url }.merge(options.reject { |k, _| k.to_s == 'source' })
|
|
67
72
|
get(post_url, params)
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
def comments(url_or_code, options = {})
|
|
76
|
+
source = (options[:source] || 'instagram').to_s
|
|
71
77
|
url = normalize_url(url_or_code)
|
|
72
|
-
params = { url: url }.merge(options)
|
|
73
|
-
|
|
74
|
-
comments_url = comments_url_for(source:)
|
|
78
|
+
params = { url: url }.merge(options.reject { |k, _| k.to_s == 'source' })
|
|
79
|
+
comments_url = comments_url_for(source: source)
|
|
75
80
|
res = get(comments_url, params)
|
|
76
81
|
res.is_a?(Hash) ? (res["comments"] || []) : []
|
|
77
82
|
end
|