Class: TrueURL::Strategy::NicoVideo

Inherits:
Object
  • Object
show all
Defined in:
lib/true_url/strategy/nicovideo.rb

Instance Method Summary collapse

Instance Method Details

#execute(context) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/true_url/strategy/nicovideo.rb', line 4

def execute(context)
  path = context.working_url.path

  if path[0..6] == '/watch/'
    video_id = path.split('/')[2]

  elsif path[0..12] == '/thumb_watch/'
    video_id = path.split('/')[2]
  end

  if video_id
    context.set_working_url("http://www.nicovideo.jp/watch/#{video_id}")
    context.finalize
    context.attributes[:embed_url] = "http://embed.nicovideo.jp/watch/#{video_id}"
  end

  # Nico Video only supports HTTP
  context.working_url.scheme = 'http'
end