Add script for seting up media center

This commit is contained in:
Artur Gurgul 2025-08-11 10:20:07 +02:00
parent 8789922ba6
commit c08110ae38
6 changed files with 161 additions and 0 deletions

21
lib/downloader.rb Normal file
View 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