Class: Youku::V2::Videos

Inherits:
Base
  • Object
show all
Defined in:
lib/youku/v2/videos.rb

Defined Under Namespace

Classes: Favorite

Constant Summary collapse

BASE_URI =
"#{BASE_URI}/videos"

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Instance Method Details

#by_category(category: nil, genre: nil, period: nil, orderby: 'view-count', page: 1, count: 20) ⇒ Object

Public: Get videos for a given category.

See: open.youku.com/docs?id=57

category - The String category. genre - The String genre. period - The String period. orderby - The String order of videos. page - The Integer page number. count - The Integer page size.

Returns the instance of Youku::V2::Request.



118
119
120
121
122
123
124
125
126
127
128
# File 'lib/youku/v2/videos.rb', line 118

def by_category(category: nil, genre: nil, period: nil, orderby: 'view-count', page: 1, count: 20)
  Youku::V2::Request.new "#{BASE_URI}/by_category.json", {
    client_id: client.client_id,
    category:  category,
    genre:     genre,
    period:    period,
    orderby:   orderby,
    page:      page,
    count:     count,
  }
end

Public: Get videos that relate to another video.

See: open.youku.com/docs?id=52

video_id - The String video ID. count - The Integer page size.

Returns the instance of Youku::V2::Request.



98
99
100
101
102
103
104
# File 'lib/youku/v2/videos.rb', line 98

def by_related(video_id: nil, count: 20)
  Youku::V2::Request.new "#{BASE_URI}/by_related.json", {
    client_id: client.client_id,
    video_id:  video_id,
    count:     count,
  }
end

#by_user(user_id: nil, user_name: nil, orderby: 'published', page: 1, count: 20) ⇒ Object

Public: Get videos for given Youku user.

See: open.youku.com/docs?id=49

user_id - The String Youku user ID. user_name - The String Youku user name. orderby - The String order of videos. page - The Integer page number. count - The Integer page size.

Returns the instance of Youku::V2::Request.



79
80
81
82
83
84
85
86
87
88
# File 'lib/youku/v2/videos.rb', line 79

def by_user(user_id: nil, user_name: nil, orderby: 'published', page: 1, count: 20)
  Youku::V2::Request.new "#{BASE_URI}/by_user.json", {
    client_id: client.client_id,
    user_id:   user_id,
    user_name: user_name,
    orderby:   orderby,
    page:      page,
    count:     count,
  }
end

#favoriteObject

Public: Get favourite API.

Returns the instance of Youku::V2::Videos::Favorite.



133
134
135
# File 'lib/youku/v2/videos.rb', line 133

def favorite
  Favorite.new(client)
end

#show(video_id: nil, ext: nil) ⇒ Object

Public: Get video by ID

See: open.youku.com/docs?id=46

video_id - The String video ID. ext - The String video extension information.

Returns the instance of Youku::V2::Request.



44
45
46
47
48
49
50
# File 'lib/youku/v2/videos.rb', line 44

def show(video_id: nil, ext: nil)
  Youku::V2::Request.new "#{BASE_URI}/show.json", {
    client_id: client.client_id,
    video_id:  video_id,
    ext:       ext,
  }
end

#show_basic(video_id: nil, video_url: nil) ⇒ Object

Public: Get basic information by video ID

See: open.youku.com/docs?id=44

video_id - The video ID. video_url - The video’s URL.

Returns the instance of Youku::V2::Request.



14
15
16
17
18
19
20
# File 'lib/youku/v2/videos.rb', line 14

def show_basic(video_id: nil, video_url: nil)
  Youku::V2::Request.new "#{BASE_URI}/show_basic.json", {
    client_id: client.client_id,
    video_id:  video_id,
    video_url: video_url,
  }
end

#show_basic_batch(video_ids: nil) ⇒ Object

Public: Get basic information by video IDs

See: open.youku.com/docs?id=45

video_ids - The String video IDs.

Returns the instance of Youku::V2::Request.



29
30
31
32
33
34
# File 'lib/youku/v2/videos.rb', line 29

def show_basic_batch(video_ids: nil)
  Youku::V2::Request.new "#{BASE_URI}/show_basic_batch.json", {
    client_id: client.client_id,
    video_ids: video_ids,
  }
end

#show_batch(video_ids: nil, ext: nil) ⇒ Object

Public: Get videos by IDs

See: open.youku.com/docs?id=47

video_ids - The comma separated String of video IDs. ext - The String video extension information.

Returns the instance of Youku::V2::Request.



60
61
62
63
64
65
66
# File 'lib/youku/v2/videos.rb', line 60

def show_batch(video_ids: nil, ext: nil)
  Youku::V2::Request.new "#{BASE_URI}/show_batch.json", {
    client_id: client.client_id,
    video_ids: video_ids,
    ext:       ext,
  }
end