Class: Lumiere::YouTubePlaylist
Constant Summary
collapse
- USEABLE =
['www.youtube.com', 'youtube.com', 'youtu.be']
- RESULTS_PER_REQUEST =
25
Constants inherited
from Provider
Provider::PROVIDERS
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from EmbedCode
#embed_code
Methods inherited from Provider
#==, #accessible?, delegate, #duration, #embed_code, #upload_date, #video_id
Constructor Details
Returns a new instance of YouTubePlaylist.
14
15
16
17
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 14
def initialize(url, opts={})
@url = url
@start_index = opts[:start_index] || 1
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3
4
5
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 3
def url
@url
end
|
Class Method Details
.useable?(url) ⇒ Boolean
9
10
11
12
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 9
def self.useable?(url)
uri = URISchemeless.parse(url)
USEABLE.include?(uri.host) && (uri.path == '/playlist' || uri.path == '/view_play_list')
end
|
Instance Method Details
#api_url ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 27
def api_url
url = "http://gdata.youtube.com/feeds/api/playlists/#{playlist_id}"
url << "?max-results=#{RESULTS_PER_REQUEST}"
url << "&start-index=#{@start_index}"
url << "&v=2&alt=json"
url
end
|
#default_attributes ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 39
def default_attributes
{
iframe_attributes: {
frameborder: 0,
allowfullscreen: true
}
}
end
|
#description ⇒ Object
87
88
89
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 87
def description
fetch.description
end
|
#embed_url ⇒ Object
35
36
37
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 35
def embed_url
"//youtube.com/embed/?list=#{playlist_id}"
end
|
#playlist_id ⇒ Object
23
24
25
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 23
def playlist_id
@playlist_id ||= calculate_playlist_id
end
|
#provider ⇒ Object
19
20
21
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 19
def provider
"YouTube"
end
|
#thumbnail_large ⇒ Object
79
80
81
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 79
def thumbnail_large
fetch.thumbnails[2].url
end
|
#thumbnail_medium ⇒ Object
75
76
77
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 75
def thumbnail_medium
fetch.thumbnails[1].url
end
|
#thumbnail_small ⇒ Object
71
72
73
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 71
def thumbnail_small
fetch.thumbnails[0].url
end
|
#title ⇒ Object
83
84
85
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 83
def title
fetch.title
end
|
#total_results ⇒ Object
91
92
93
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 91
def total_results
fetch.total_results
end
|
#unpack_into ⇒ Object
95
96
97
98
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 95
def unpack_into
struct = OpenStruct.new
struct.extend(YouTubePlaylistRepresenter)
end
|
#videos ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 48
def videos
if @videos && @videos.size == total_results
return @videos
end
@videos = fetch.videos
remaining_pages = page_count - 1
remaining_pages.times do
@start_index =+ @videos.size + 1
@videos += fetch!.videos
end
@videos.map do |video|
YouTube.new_from_video_id(video.video_id, video)
end
end
|