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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d1b0ec47242c7f1e3f0d551233d27f9e11be3874cc3b78a78181eaa40a21b84f
4
- data.tar.gz: 5a8827a29aa9b0ae06a890bc979d9e52e8a9f94ba2b717d38ebb305b7459fcad
3
+ metadata.gz: 41069945ebf877cbd439c8bfbb318ba0114d4e9df6275aabacef16867417a7b4
4
+ data.tar.gz: 24d8743a67a698cfc97f974015a8ff30ab33254b8dd155e96f1d4b0283e9d9c0
5
5
  SHA512:
6
- metadata.gz: '08f33db279a55d7b432d7cc29c0b7b1ebec5b8d5938bab8c00e13484871f4fcdfe7bba2989146f0253e4c3cfe1dc86dc8110ba732cfd05ac6a0e2b08184c9108'
7
- data.tar.gz: 92519f692c9d01b014c933f3a333a5494ebc86f0cc3ad0c98247b6799cb2d457220304cd11f71c7f8df3c5f277ee1ea66aaf75f05a025a27e080640ada04378e
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
- params = { handle: }.merge(options)
55
- source = options.dig(:source) || 'instagram'
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
- source = options.dig(:source) || 'instagram'
65
- post_url = post_url_for(source:)
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
- source = options.dig(:source) || 'instagram'
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ScrapeCreators
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrape_creators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - swlkr