yt-annotations 1.4.0 → 1.4.1

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
  SHA1:
3
- metadata.gz: b11e5000de51c3368ae436830f73718c62ee3c79
4
- data.tar.gz: 9c423d7614330f65be5dc065c773929219612162
3
+ metadata.gz: 5af7335a71c02853df3dc551ac1644636fbfeb08
4
+ data.tar.gz: 972ddc78ffc07d534dc907218a3187bcb8bc0b89
5
5
  SHA512:
6
- metadata.gz: 6627dc40354ae491ee2db22b372f6ef5dd610a70112838066bdd12e2af703cc3338378d589dd7ccaa1bb7410930d00af60ddad392c9f73e7407c333a379022c8
7
- data.tar.gz: 267e86f1fbb728fa20d9059cf2cbdbd639d0045287261059160989f74eaf6c12781839a9f5365883221e5ade4258ca888557eafac2b33028e3212ee042cb6040
6
+ metadata.gz: ab38e436b2323ee00fbd2d9643c44138f9c4b3dabbb7f12ae787a2ab47002b44eafc19765519559954f49bdbe43b685939a5886f63239b248c76f3f7258efc48
7
+ data.tar.gz: 72cc855dea18be49d1a17db7662eecbd6874c5cb536936847d3a72900e4639fb569462e599dd06332fbce59b04824d1e1b3a0c19208314473391ad35a7748421
@@ -7,6 +7,10 @@ For more information about changelogs, check
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
9
 
10
+ ## 1.4.1 - 2017.03.31
11
+
12
+ * [BUGFIX] Change `EndScreen` according to its endpoint change on YouTube
13
+
10
14
  ## 1.4.0 - 2017.01.13
11
15
 
12
16
  * [FEATURE] Add End Screens
@@ -7,8 +7,8 @@ module Yt
7
7
  # @param [Hash] data the Hash representation of the XML data returned by
8
8
  # YouTube for each end screen of a video.
9
9
  def initialize(json = {})
10
- @text = json['title']
11
- @starts_at = json['startMs'] / 1000.0
10
+ @text = json['title']['runs'][0]['text']
11
+ @starts_at = json['startMs'].to_i / 1000.0
12
12
  @ends_at = ends_at_in json
13
13
  @link = to_link json
14
14
  end
@@ -16,25 +16,45 @@ module Yt
16
16
  private
17
17
 
18
18
  def ends_at_in(json)
19
- (json['startMs'] + json['durationMs']) / 1000.0
19
+ json['endMs'].to_i / 1000.0
20
20
  end
21
21
 
22
22
  def to_link(json)
23
+ target_url = case json['style']
24
+ when 'WEBSITE'
25
+ json['endpoint']['urlEndpoint']['url']
26
+ when 'PLAYLIST'
27
+ "https://www.youtube.com/watch?v=" +
28
+ json['endpoint']['watchEndpoint']['videoId'] +
29
+ "&list=" +
30
+ json['endpoint']['watchEndpoint']['playlistId']
31
+ when 'VIDEO'
32
+ "https://www.youtube.com/watch?v=" +
33
+ json['endpoint']['watchEndpoint']['videoId']
34
+ when 'CHANNEL'
35
+ if json['isSubscribe']
36
+ "https://www.youtube.com/channel/" +
37
+ json['hovercardButton']['subscribeButtonRenderer']['channelId']
38
+ else
39
+ "https://www.youtube.com/channel/" +
40
+ json['endpoint']['browseEndpoint']["browseId"]
41
+ end
42
+ end
23
43
  {
24
- url: json['targetUrl'], new_window: new_window(json['type']),
44
+ url: target_url, new_window: new_window(json['style']),
25
45
  type: link_type(json)
26
46
  }
27
47
  end
28
-
48
+
29
49
  def link_type(json)
30
- case json['type']
50
+ case json['style']
31
51
  when 'WEBSITE' then :website
32
52
  when 'PLAYLIST' then :playlist
33
53
  when 'VIDEO' then :video
34
54
  when 'CHANNEL' then (json['isSubscribe'] ? :subscribe : :channel)
35
55
  end
36
56
  end
37
-
57
+
38
58
  def new_window(type)
39
59
  %w(WEBSITE CHANNEL).include? type
40
60
  end
@@ -46,7 +46,7 @@ module Yt
46
46
 
47
47
  def json_to_annotations(json)
48
48
  annotations = json['elements']
49
- annotations.map{|data| Annotations::EndScreen.new data}
49
+ annotations.map{|data| Annotations::EndScreen.new data['endscreenElementRenderer']}
50
50
  end
51
51
 
52
52
  def annotation_class(data)
@@ -1,5 +1,5 @@
1
1
  module Yt
2
2
  module Annotations
3
- VERSION = '1.4.0'
3
+ VERSION = '1.4.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt-annotations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - claudiob
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-13 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.6.6
157
+ rubygems_version: 2.6.11
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Fetch annotations and cards from YouTube videos.