Add script for seting up media center
This commit is contained in:
parent
8789922ba6
commit
c08110ae38
6 changed files with 161 additions and 0 deletions
21
lib/downloader.rb
Normal file
21
lib/downloader.rb
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
require 'uri'
|
||||
require 'addressable/uri'
|
||||
|
||||
|
||||
module Downloader
|
||||
# use_cache => save in the home and return path to it
|
||||
# forced => download even if the file exists in the cache, saves to chace if use_cache == true
|
||||
def self.get(url, use_cache = true, forced = false)
|
||||
puts "downloading..."
|
||||
puts url
|
||||
|
||||
|
||||
uri = Addressable::URI.parse(url)
|
||||
path = File.join("#{ENV["HOME"]}/.cache/dat/downloads/", uri.domain, uri.path)
|
||||
|
||||
#uri = URI.parse(url)
|
||||
#file_name = File.basename(uri.path)
|
||||
puts "Download path: #{path}"
|
||||
yield path
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue