yt 0.29.0 → 0.29.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: e22a0e31744f1671b9ecb506921d0adfd61f1c9b
4
- data.tar.gz: 730c92a149f9fd7c00c23a13fef0c5f37ea43d2b
3
+ metadata.gz: 6d230c04ee3f54a7973c00c77df5da93267abe5c
4
+ data.tar.gz: f59ed4300490ef5955c4d29549da530ee5e2f5eb
5
5
  SHA512:
6
- metadata.gz: 1475b00ac7c0abed681ffa39c173d7a6a80507f09434c66ca27444ab65e6a0e399045a9d1a6a8d9cb0a9dfcccd5183ced1fa041bcd8b35b771eb05105c6ab631
7
- data.tar.gz: 8b6bfa677ddc77b178bc38d6db634e03cb51a1d1b04d8a1b1a47f1e5595ce32a75ed7e236b5588b64ce413883095bf50b88c0dc4e70d1306ee4446b5476ca214
6
+ metadata.gz: 052df215093feaa61545a96f41fa13de5919bf0f0abc78db9ee67788434b9c08b0451405673d0645d7491898f5f1fac608411a4c3290c01b8590a892b2fcce86
7
+ data.tar.gz: 5e7e1ffdc1ee27511e5f9172efb7964edae8c0bd541e76f8aed095cc686f70e0ccf1423cc6420533f23d4a966bcfa5eb915a9d8b43c2d958ed074d4816326518
@@ -6,6 +6,10 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.29.1 - 2017-02-26
10
+
11
+ * [FEATURE] Add `Video#length` to show the duration as an ISO 8601 time.
12
+
9
13
  ## 0.29.0 - 2017-02-17
10
14
 
11
15
  **How to upgrade**
@@ -29,6 +29,12 @@ module Yt
29
29
  content_rating['ytRating']
30
30
  end
31
31
 
32
+ # @return [<String>] the length of the video as an ISO 8601 time, HH:MM:SS.
33
+ def length
34
+ hh, mm, ss = duration / 3600, duration / 60 % 60, duration % 60
35
+ [hh, mm, ss].map{|t| t.to_s.rjust(2,'0')}.join(':')
36
+ end
37
+
32
38
  private
33
39
 
34
40
  # @return [Integer] the duration of the resource as reported by YouTube.
@@ -231,6 +231,10 @@ module Yt
231
231
  # @return [Integer] the duration of the video (in seconds).
232
232
  delegate :duration, to: :content_detail
233
233
 
234
+ # @!attribute [r] duration
235
+ # @return [String] the length of the video as an ISO 8601 time, HH:MM:SS.
236
+ delegate :length, to: :content_detail
237
+
234
238
  # @return [Boolean] whether the video is available in 3D.
235
239
  def stereoscopic?
236
240
  content_detail.dimension == '3d'
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.29.0'
2
+ VERSION = '0.29.1'
3
3
  end
@@ -42,4 +42,11 @@ describe Yt::ContentDetail do
42
42
  it { expect(content_detail.duration).to eq 51 }
43
43
  end
44
44
  end
45
+
46
+ describe '#length' do
47
+ context 'returns the duration in HH:MM:SS' do
48
+ let(:data) { {"duration"=>"PT1H18M52S"} }
49
+ it { expect(content_detail.length).to eq '01:18:52' }
50
+ end
51
+ end
45
52
  end
@@ -29,6 +29,7 @@ describe Yt::Video, :device_app do
29
29
  expect(video.favorite_count).to be_an Integer
30
30
  expect(video.comment_count).to be_an Integer
31
31
  expect(video.duration).to be_an Integer
32
+ expect(video.length).to be_a String
32
33
  expect(video.hd?).to be_in [true, false]
33
34
  expect(video.stereoscopic?).to be_in [true, false]
34
35
  expect(video.captioned?).to be_in [true, false]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo