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.
17
18
19
20
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 17
def initialize(url, opts={})
@url = url
@start_index = opts[:start_index] || 1
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
6
7
8
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 6
def url
@url
end
|
Class Method Details
.useable?(url) ⇒ Boolean
12
13
14
15
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 12
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
30
31
32
33
34
35
36
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 30
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
42
43
44
45
46
47
48
49
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 42
def default_attributes
{
iframe_attributes: {
frameborder: 0,
allowfullscreen: true
}
}
end
|
#description ⇒ Object
90
91
92
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 90
def description
fetch.description
end
|
#embed_url ⇒ Object
38
39
40
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 38
def embed_url
"//youtube.com/embed/?list=#{playlist_id}"
end
|
#playlist_id ⇒ Object
26
27
28
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 26
def playlist_id
@playlist_id ||= calculate_playlist_id
end
|
#provider ⇒ Object
22
23
24
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 22
def provider
"YouTube"
end
|
#thumbnail_large ⇒ Object
82
83
84
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 82
def thumbnail_large
fetch.thumbnails[2].url
end
|
#thumbnail_medium ⇒ Object
78
79
80
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 78
def thumbnail_medium
fetch.thumbnails[1].url
end
|
#thumbnail_small ⇒ Object
74
75
76
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 74
def thumbnail_small
fetch.thumbnails[0].url
end
|
#title ⇒ Object
86
87
88
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 86
def title
fetch.title
end
|
#total_results ⇒ Object
94
95
96
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 94
def total_results
fetch.total_results
end
|
#unpack_into ⇒ Object
98
99
100
101
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 98
def unpack_into
struct = OpenStruct.new
struct.extend(YouTubePlaylistRepresenter)
end
|
#videos ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/provider/youtubeplaylist/youtubeplaylist.rb', line 51
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
|