youtube_parser 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e7896f15e739e7d88e6de6acf67f07bc543897deffebe0c4e723a3746d84e32
4
- data.tar.gz: bff5544c0e250bd76c9265f74eaee6d743423c7748030415d0983175b3c263ab
3
+ metadata.gz: f79ddcdfbe0953a3571e1e27abdec5ea0993d5f0426f5d7393a518966bdd7b9b
4
+ data.tar.gz: 6ab6fe4c91a6affb19ab86dd07508fb8f230380cd62306012bbcd95e37f55537
5
5
  SHA512:
6
- metadata.gz: 7b6ae178f21036ff1f620982349975cd88973aa51443a59caf8efa81a0da5a4b1bbd135f00c383f0e3c672a1edd63c74d12219c346f364066bbc952f8f59a525
7
- data.tar.gz: 2b30490336766753b5b18aa7f0bdc5f61eea7ac6dd13c97777466c2ec5f2f25c8df3bde616152243811882b8c2c656625a50c68989cb80f51c41ff1a2939428e
6
+ metadata.gz: 4b82d6e48e9c73fb02129aee92874becfe3203269ee47942ed92814c5db3f54ffb29c20613916d6e631baf2def4a592ae5a4b34baea200a14d2253ab141bcded
7
+ data.tar.gz: f676707c34aa5d7c1b7347c1bce676dd117a72eb7cd278de05ecf00953202b31387b4b5b6d04e27287d62a416ace34e7ca65cc378396fa93e792755477280473
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- youtube_parser (0.1.8)
4
+ youtube_parser (0.1.9)
5
5
  activesupport
6
6
  faraday
7
7
  oj
data/README.md CHANGED
@@ -47,6 +47,18 @@ end
47
47
  YoutubeParser::Search::Channels.new(options).info
48
48
  ```
49
49
 
50
+ To parse channel related channels:
51
+ ```ruby
52
+ require 'youtube_parser'
53
+
54
+ user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 '\
55
+ '(KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
56
+ options = { search_query: 'search query',
57
+ user_agent: user_agent }
58
+
59
+ YoutubeParser::Channels::ChannelsSection.new(options).info
60
+ ```
61
+
50
62
  ## Contributing
51
63
 
52
64
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/youtube_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -16,6 +16,7 @@ require 'youtube_parser/base_parser'
16
16
  require 'youtube_parser/channel'
17
17
  require 'youtube_parser/channels/about_section'
18
18
  require 'youtube_parser/channels/videos_section'
19
+ require 'youtube_parser/channels/channels_section'
19
20
  require 'youtube_parser/search/channels'
20
21
 
21
22
  module YoutubeParser
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module YoutubeParser
4
+ module Channels
5
+ class ChannelsSection < BaseParser
6
+ options :channel_url
7
+
8
+ def info
9
+ @info ||= channel_urls.map do |url|
10
+ channel_url = "#{client.class::BASE_URL}#{url}"
11
+ opts = { channel_url: channel_url, client: client }
12
+
13
+ YoutubeParser::Channel.new(opts).info
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def channel_urls
20
+ channels.map { |c| c.dig(*keys.channels_section_urls) }.compact
21
+ end
22
+
23
+ def channels
24
+ tabs = json.dig(*keys.section_tabs) || []
25
+ tabs.map { |t| t.dig(*keys.channels_section) }.compact.first || []
26
+ end
27
+
28
+ def json
29
+ @json ||= client.get("#{options.channel_url}/channels")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -34,4 +34,8 @@ channels_contents: ['itemSectionRenderer', 'contents']
34
34
  channel_renderer: ['channelRenderer']
35
35
  continuations: ['continuations']
36
36
  renderer_continuations: ['itemSectionRenderer', 'continuations']
37
- continuation: ['nextContinuationData', 'continuation']
37
+ continuation: ['nextContinuationData', 'continuation']
38
+ channels_section: ['tabRenderer', 'content', 'sectionListRenderer', 'contents',
39
+ 0, 'itemSectionRenderer', 'contents', 0, 'gridRenderer', 'items']
40
+ channels_section_urls: ['gridChannelRenderer', 'navigationEndpoint',
41
+ 'commandMetadata', 'webCommandMetadata', 'url']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YoutubeParser
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - o.vykhor
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-05 00:00:00.000000000 Z
11
+ date: 2020-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -145,6 +145,7 @@ files:
145
145
  - lib/youtube_parser/base_parser.rb
146
146
  - lib/youtube_parser/channel.rb
147
147
  - lib/youtube_parser/channels/about_section.rb
148
+ - lib/youtube_parser/channels/channels_section.rb
148
149
  - lib/youtube_parser/channels/videos_section.rb
149
150
  - lib/youtube_parser/client.rb
150
151
  - lib/youtube_parser/config/keys.yml