Module: Shikimori::API::V1::Videos

Included in:
Shikimori::API::V1
Defined in:
lib/shikimori/api/v1/videos.rb

Overview

Methods for the Videos API

Instance Method Summary collapse

Instance Method Details

#anime_videos(anime_id, headers: nil, **query) ⇒ Array<Hash>

Get anime videos

Examples:

Get videos for anime with id equal to 1

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
client.v1.anime_videos(1)

Parameters:

  • anime_id (#to_s)

    Anime id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Array<Hash>)

    Array of hashes representing videos

See Also:



26
27
28
# File 'lib/shikimori/api/v1/videos.rb', line 26

def anime_videos(anime_id, headers: nil, **query)
  rest.get base_url.join('animes', anime_id.to_s, 'videos').url, headers: headers, query: query
end

#create_anime_video(anime_id, video, headers: nil, **query) ⇒ Hash

Create Video

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)
video = { name: 'Funny cat!', kind: 'ed', url: 'https://youtu.be/dQw4w9WgXcQ' }
client.v1.create_anime_video(1, video)

Parameters:

  • video (Hash)

    Video data for creating

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Options Hash (video):

  • :name (String)

    Name of video

  • :kind ('pv', 'character_trailer', 'cm', 'op', 'ed', 'op_ed_clip', 'clip', 'other', 'episode_preview')

    Type of video

  • :url (String)

    URL to video. Supported hostings: youtube, vk, ok, coub, rutube, vimeo, sibnet, yandex, streamable, smotret_anime, myvi, youmite, viuly, stormo, mediafile

Returns:

  • (Hash)

    Hash representing created video

See Also:



53
54
55
56
57
# File 'lib/shikimori/api/v1/videos.rb', line 53

def create_anime_video(anime_id, video, headers: nil, **query)
  rest.post base_url.join('animes', anime_id.to_s, 'videos').url,
            { video: video },
            headers: headers, query: query
end

#delete_anime_video(anime_id:, video_id:, headers: nil, **query) ⇒ Boolean

Delete Video

Examples:

client = Shikimori::API::Client.new(
  app_name: 'Api Test',
  aceess_token: '****',
  refresh_token: '****'
)

client.v1.delete_anime_video(anime_id: 1, video_id: 1)

Parameters:

  • anime_id (#to_s)

    Anime id

  • video_id (#to_s)

    Video id

  • headers (Hash) (defaults to: nil)

    Request headers

  • query (Hash)

    Query string parameters for request

Returns:

  • (Boolean)

    True if deletion successful, false otherwise.

See Also:



77
78
79
80
81
# File 'lib/shikimori/api/v1/videos.rb', line 77

def delete_anime_video(anime_id:, video_id:, headers: nil, **query)
  rest.delete base_url.join('animes', anime_id.to_s, 'videos', video_id.to_s).url,
              headers: headers,
              query: query
end