lib/airplayer/media.rb in airplayer-0.0.7 vs lib/airplayer/media.rb in airplayer-0.0.8
- old
+ new
@@ -19,10 +19,11 @@
video/mpeg4
)
SUPPORTED_DOMAINS = %w(
youtube
+ youtu.be
)
class Media
attr_reader :title, :path, :type
@@ -42,16 +43,16 @@
end
end
def self.playable?(path)
MIME::Types.type_for(path).each do |mimetype|
- return SUPPORTED_MIME_TYPES.include? mimetype
+ return SUPPORTED_MIME_TYPES.include?(mimetype)
end
- host = URI.parse(path).host
+ host = URI.parse(URI.escape(path)).host
SUPPORTED_DOMAINS.each do |domain|
- return host =~ /#{domain}/
+ return true if host =~ /#{domain}/
end
false
end
@@ -73,19 +74,19 @@
end
private
def online_media_path(uri)
case URI.parse(uri).host
- when /youtube/
+ when /youtube|youtu\.be/
uri = `youtube-dl -g #{uri}`
else
uri
end
end
def online_media_title(uri)
case URI.parse(uri).host
- when /youtube/
+ when /youtube|youtu\.be/
title = `youtube-dl -e #{uri}`
else
title = File.basename(uri)
end
end