Class: VineDl::Video

Inherits:
Object
  • Object
show all
Defined in:
lib/vine_dl/video.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_user, _client_video) ⇒ Video

Returns a new instance of Video.



8
9
10
11
# File 'lib/vine_dl/video.rb', line 8

def initialize(_user, _client_video)
  @user = _user
  @client_video = _client_video
end

Instance Attribute Details

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/vine_dl/video.rb', line 6

def user
  @user
end

Instance Method Details

#download(path, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vine_dl/video.rb', line 13

def download(path, options = {})
  create_directory = options.fetch(:create_directory, false)
  # TODO: Find the dir more robustly.
  directory = File.join(path.split("/")[0..-2])

  if create_directory && !File.directory?(directory)
    Dir.mkdir(directory)
  end

  write_to_file(path)

  path
end

#file_nameObject



32
33
34
35
# File 'lib/vine_dl/video.rb', line 32

def file_name
  # TODO: Get the video name more robustly.
  @file_name ||= video_url.split("videos_h264high/")[1]
end

#video_urlObject



27
28
29
30
# File 'lib/vine_dl/video.rb', line 27

def video_url
  # TODO: Get the url without the query more robustly.
  @video_url ||= client_video.videoUrl.split("?")[0]
end