Class: Bremen::Nicovideo

Inherits:
Base
  • Object
show all
Defined in:
lib/bremen/nicovideo.rb

Constant Summary collapse

BASE_URL =
'http://www.nicovideo.jp/'

Instance Attribute Summary

Attributes included from Track

#author, #created_at, #length, #thumbnail_url, #title, #uid, #updated_at, #url

Class Method Summary collapse

Methods inherited from Base

find, search

Methods included from Request

#build_query, #get

Methods included from Track

#initialize

Class Method Details

.find_url(uid_or_url) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bremen/nicovideo.rb', line 18

def find_url uid_or_url
  unless uid_or_url.include?('www.nicovideo.jp')
    "#{BASE_URL}watch/#{uid_or_url}"
  else
    uid_or_url
  end
end

.search_url(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bremen/nicovideo.rb', line 26

def search_url options = {}
  options = default_options.merge(options)
  query = {
    page: options[:page],
    sort: options[:sort],
    order: options[:order],
    f_range: options[:within],
    l_range: options[:length],
    opt_md: options[:downloadable],
  }
  "#{BASE_URL}search/#{CGI.escape(options[:keyword])}?#{build_query(query)}"
end