muri 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +1 -2
- data/VERSION.yml +2 -2
- data/lib/muri/base.rb +13 -10
- data/lib/muri/filters/facebook.rb +1 -1
- data/lib/muri/filters/picasa.rb +5 -3
- data/lib/muri/filters/youtube.rb +1 -1
- data/muri.gemspec +8 -8
- data/test/error_test.rb +9 -2
- metadata +8 -8
data/README.textile
CHANGED
@@ -8,7 +8,7 @@ MURI Currently supports:
|
|
8
8
|
* Vimeo (single videos and albums)
|
9
9
|
** "API documentation":http://vimeo.com/api/docs/simple-api
|
10
10
|
* Flickr (single images and sets)
|
11
|
-
** "API documentation":http://www.flickr.com/services/api/ or "
|
11
|
+
** "API documentation":http://www.flickr.com/services/api/ or "API Doc 2":http://developer.yahoo.com/flickr/
|
12
12
|
* Imageshack
|
13
13
|
* Photobucket
|
14
14
|
** "API documentation":http://photobucket.com/developer/documentation
|
@@ -68,7 +68,6 @@ Assuming the URI was successfully parsed (thus @a.valid? == true@), all media ty
|
|
68
68
|
|
69
69
|
|
70
70
|
* A direct media url for Youtube, Photobucket (photos, not albums), Twitpic, Imageshack (@http://img#{num}.imageshack.us/img#{num}/#{NUMBER}/#{IMAGENAME}@ format) and flickr (@http://farm#{num}.static.flickr.com/@ format)
|
71
|
-
d
|
72
71
|
|
73
72
|
<pre>
|
74
73
|
<code>
|
data/VERSION.yml
CHANGED
data/lib/muri/base.rb
CHANGED
@@ -9,19 +9,21 @@ class Muri
|
|
9
9
|
# match accepted formats
|
10
10
|
class UnsupportedURI < ArgumentError; end
|
11
11
|
|
12
|
-
|
12
|
+
AVAILABLE_PARSERS = %w[Youtube Flickr Vimeo Imageshack Photobucket Facebook Twitpic Picasa].freeze
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
PARSERS = { }
|
15
|
+
|
16
|
+
# Defines is_#{service}? and is_#{service type}? methods, and sets service name constnat
|
17
|
+
AVAILABLE_PARSERS.each do |parser|
|
18
|
+
eval "include Filter::#{parser}"
|
19
|
+
is_service = "is_#{parser.downcase}?"
|
20
|
+
define_method(is_service) { self.media_service == parser }
|
21
|
+
self.constants.reject { |c| c !~ /^#{parser.upcase}/ }.each do |exp|
|
20
22
|
define_method("is_#{exp.downcase}?") do
|
21
23
|
self.media_api_type == eval(exp) && self.instance_eval(is_service)
|
22
24
|
end
|
23
25
|
end
|
24
|
-
const_set "#{
|
26
|
+
const_set "#{parser.upcase}_SERVICE_NAME", "#{parser}"
|
25
27
|
end
|
26
28
|
|
27
29
|
def self.parse(url)
|
@@ -35,7 +37,7 @@ class Muri
|
|
35
37
|
|
36
38
|
def initialize(url)
|
37
39
|
@info = { }
|
38
|
-
|
40
|
+
parse(url)
|
39
41
|
end
|
40
42
|
|
41
43
|
# Determine if Muri object is valid (errors mean not valid)
|
@@ -59,8 +61,9 @@ class Muri
|
|
59
61
|
PARSERS.keys.detect {|klass| klass.parsable?(uri)}
|
60
62
|
end
|
61
63
|
|
62
|
-
def
|
64
|
+
def parse(raw_url)
|
63
65
|
begin
|
66
|
+
raw_url = URI.encode(URI.decode(raw_url)) unless raw_url.nil?
|
64
67
|
self.uri = URI.parse(raw_url)
|
65
68
|
if self.uri.scheme.nil?
|
66
69
|
raw_url = "http://#{raw_url}"
|
@@ -59,7 +59,7 @@ class Muri
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# The media_api_id is the PID which can be searched for in the facebook photos/albums table
|
62
|
-
self.media_api_id = (media_creator.to_i << 32) +self.media_id.to_i
|
62
|
+
self.media_api_id = (media_creator.to_i << 32) + self.media_id.to_i
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/muri/filters/picasa.rb
CHANGED
@@ -18,13 +18,15 @@ class Muri
|
|
18
18
|
def picasa_parse
|
19
19
|
self.media_service = PICASA_SERVICE_NAME
|
20
20
|
url_common = "http://picasaweb.google.com"
|
21
|
-
reencoded_url = URI.parse(URI.encode self.uri.to_s)
|
22
21
|
|
23
|
-
|
22
|
+
#I hate to have to do this, but it's the best way I can think of to get the hash symbol
|
23
|
+
#reencoded_url = URI.parse(URI.encode self.uri.to_s)
|
24
|
+
|
25
|
+
if self.uri.path =~ /^\/(.[^\/]+)\/(.[^\/]+)/i
|
24
26
|
username = $1
|
25
27
|
album_photoid = $2.split("%23")
|
26
28
|
photoid = album_photoid.last
|
27
|
-
album = album_photoid[0..-2].join("#")#in case other hash symbols exist
|
29
|
+
album = album_photoid[0..-2].join("#") #in case other hash symbols exist
|
28
30
|
self.media_id = photoid
|
29
31
|
self.media_website = "#{url_common}/#{username}/#{album}##{photoid}"
|
30
32
|
self.media_api_type = PICASA_PHOTO
|
data/lib/muri/filters/youtube.rb
CHANGED
@@ -36,7 +36,7 @@ class Muri
|
|
36
36
|
elsif (self.uri.path =~ REGEX_YOUTUBE_PLAYLIST_DIRECT)
|
37
37
|
self.media_id = $1
|
38
38
|
self.media_api_type = YOUTUBE_PLAYLIST
|
39
|
-
elsif (self.uri.path =~ REGEX_YOUTUBE_PLAYLIST_WATCH) &&
|
39
|
+
elsif (self.uri.path =~ REGEX_YOUTUBE_PLAYLIST_WATCH) && params['p']
|
40
40
|
self.media_id = params['p']
|
41
41
|
self.media_api_type = YOUTUBE_PLAYLIST
|
42
42
|
else
|
data/muri.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{muri}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["William Schneider"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-05}
|
13
13
|
s.description = %q{Automatically get media information from the URL.}
|
14
14
|
s.email = %q{bananastalktome@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -48,14 +48,14 @@ Gem::Specification.new do |s|
|
|
48
48
|
s.rubygems_version = %q{1.3.6}
|
49
49
|
s.summary = %q{Media URI Parser}
|
50
50
|
s.test_files = [
|
51
|
-
"test/
|
52
|
-
"test/
|
51
|
+
"test/error_test.rb",
|
52
|
+
"test/facebook_test.rb",
|
53
|
+
"test/flickr_test.rb",
|
54
|
+
"test/imageshack_test.rb",
|
53
55
|
"test/photobucket_test.rb",
|
54
|
-
"test/vimeo_test.rb",
|
55
56
|
"test/picasa_test.rb",
|
56
|
-
"test/
|
57
|
-
"test/
|
58
|
-
"test/flickr_test.rb",
|
57
|
+
"test/twitpic_test.rb",
|
58
|
+
"test/vimeo_test.rb",
|
59
59
|
"test/youtube_test.rb"
|
60
60
|
]
|
61
61
|
|
data/test/error_test.rb
CHANGED
@@ -33,9 +33,16 @@ describe "Parse Errors" do
|
|
33
33
|
m.errors.should == "Muri::UnsupportedURI"
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
it "should parse URI with spaces" do
|
38
|
+
a = Muri.parse 'http://i105.photobucket.com/albums/m226/Mascutti/Vikas couches with%20paintings/v214.jpg'
|
39
|
+
lambda { a.uri.path }.should_not raise_exception()
|
40
|
+
end
|
41
|
+
|
37
42
|
it "should not bomb if no URI is provided" do
|
38
43
|
lambda { Muri.parse nil }.should_not raise_exception()
|
39
44
|
end
|
40
|
-
|
41
45
|
end
|
46
|
+
|
47
|
+
|
48
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 1.1.
|
8
|
+
- 1
|
9
|
+
version: 1.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- William Schneider
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-05 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -83,12 +83,12 @@ signing_key:
|
|
83
83
|
specification_version: 3
|
84
84
|
summary: Media URI Parser
|
85
85
|
test_files:
|
86
|
+
- test/error_test.rb
|
86
87
|
- test/facebook_test.rb
|
87
|
-
- test/
|
88
|
+
- test/flickr_test.rb
|
89
|
+
- test/imageshack_test.rb
|
88
90
|
- test/photobucket_test.rb
|
89
|
-
- test/vimeo_test.rb
|
90
91
|
- test/picasa_test.rb
|
91
|
-
- test/
|
92
|
-
- test/
|
93
|
-
- test/flickr_test.rb
|
92
|
+
- test/twitpic_test.rb
|
93
|
+
- test/vimeo_test.rb
|
94
94
|
- test/youtube_test.rb
|