Skip to content

Commit

Permalink
Merge pull request #13 from nileshtrivedi/master
Browse files Browse the repository at this point in the history
Modified Shelr::Player.play_remote method to handle HTTPS as well
  • Loading branch information
antono committed Apr 11, 2012
2 parents 8db43df + 8db0110 commit e3c50ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/shelr
Expand Up @@ -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])
Expand Down
6 changes: 5 additions & 1 deletion lib/shelr/player.rb
@@ -1,5 +1,6 @@
# encoding: utf-8
require 'net/http'
require 'net/https'
require 'tmpdir'
require 'fileutils'
require 'pathname'
Expand All @@ -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

Expand Down

0 comments on commit e3c50ba

Please sign in to comment.