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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/yt/annotations/end_screen.rb +27 -7
- data/lib/yt/annotations/for.rb +1 -1
- data/lib/yt/annotations/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5af7335a71c02853df3dc551ac1644636fbfeb08
|
4
|
+
data.tar.gz: 972ddc78ffc07d534dc907218a3187bcb8bc0b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab38e436b2323ee00fbd2d9643c44138f9c4b3dabbb7f12ae787a2ab47002b44eafc19765519559954f49bdbe43b685939a5886f63239b248c76f3f7258efc48
|
7
|
+
data.tar.gz: 72cc855dea18be49d1a17db7662eecbd6874c5cb536936847d3a72900e4639fb569462e599dd06332fbce59b04824d1e1b3a0c19208314473391ad35a7748421
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
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:
|
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['
|
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
|
data/lib/yt/annotations/for.rb
CHANGED
@@ -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)
|
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.
|
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-
|
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.
|
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.
|