diff --git a/bin/shelr b/bin/shelr index 337698c..78e5408 100755 --- a/bin/shelr +++ b/bin/shelr @@ -50,7 +50,7 @@ when 'list' Shelr::Player.list when 'play' if ARGV[1] - if ARGV[1] =~ /^http:.*/ # remote file + if ARGV[1] =~ /^https?:.*/ # remote file Shelr::Player.play_remote(ARGV[1]) elsif ARGV[1] =~ /.*\.json$/ # local file Shelr::Player.play_dump(ARGV[1]) diff --git a/lib/shelr/player.rb b/lib/shelr/player.rb index 11e94dc..be6a1cc 100644 --- a/lib/shelr/player.rb +++ b/lib/shelr/player.rb @@ -1,5 +1,6 @@ # encoding: utf-8 require 'net/http' +require 'net/https' require 'tmpdir' require 'fileutils' require 'pathname' @@ -13,7 +14,10 @@ def self.play(id) def self.play_remote(url) puts ".==> Fetching #{url}" - resp = Net::HTTP.get(URI.parse(url)) + uri = URI.parse(url) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true if uri.scheme == "https" + resp = http.request_get(uri.path).body play_parts_hash(JSON.parse(resp)) end