muri 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +7 -5
- data/VERSION.yml +1 -1
- data/lib/muri/filters/facebook.rb +36 -24
- data/lib/muri/filters/photobucket.rb +29 -8
- data/lib/muri/filters/vimeo.rb +4 -1
- data/lib/muri/filters/youtube.rb +3 -3
- data/muri.gemspec +2 -2
- data/test/facebook_test.rb +24 -24
- data/test/photobucket_test.rb +63 -2
- metadata +2 -2
data/README.textile
CHANGED
@@ -14,7 +14,7 @@ MURI Currently supports:
|
|
14
14
|
** "API documentation":http://photobucket.com/developer/documentation
|
15
15
|
* Twitpic
|
16
16
|
** "API documentation":http://twitpic.com/api.do
|
17
|
-
* Facebook
|
17
|
+
* Facebook (photos and albums)
|
18
18
|
** "API documentation":http://wiki.developers.facebook.com/index.php/API
|
19
19
|
|
20
20
|
h3. Installation & basic usage
|
@@ -62,7 +62,9 @@ Assuming the URI was successfully parsed (thus @a.valid? == true@), all media ty
|
|
62
62
|
|
63
63
|
* Services with a @media_api_id@ also have a @media_api_type@, which indicates what sort of API call should be made (be it 'photo', 'video', 'media', 'set', 'album', or 'playlist', depending on URI type)
|
64
64
|
|
65
|
-
|
65
|
+
|
66
|
+
* 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)
|
67
|
+
d
|
66
68
|
|
67
69
|
<pre>
|
68
70
|
<code>
|
@@ -70,7 +72,7 @@ Assuming the URI was successfully parsed (thus @a.valid? == true@), all media ty
|
|
70
72
|
</code>
|
71
73
|
</pre>
|
72
74
|
|
73
|
-
* A media landing website url for Facebook
|
75
|
+
* A media landing website url for Facebook, Youtube, Photobucket, Imageshack, Vimeo, Twitpic, and Flickr (flickr returns the @http://flic.kr/p/#{ID}@ short url)
|
74
76
|
|
75
77
|
<pre>
|
76
78
|
<code>
|
@@ -78,7 +80,7 @@ Assuming the URI was successfully parsed (thus @a.valid? == true@), all media ty
|
|
78
80
|
</code>
|
79
81
|
</pre>
|
80
82
|
|
81
|
-
* Content type for Imageshack, Photobucket and Flickr (flickr in the @http://farm#{num}.static.flickr.com/@ format)
|
83
|
+
* Content type for Imageshack, Photobucket (photos, not albums) and Flickr (flickr in the @http://farm#{num}.static.flickr.com/@ format)
|
82
84
|
|
83
85
|
<pre>
|
84
86
|
<code>
|
@@ -86,7 +88,7 @@ Assuming the URI was successfully parsed (thus @a.valid? == true@), all media ty
|
|
86
88
|
</code>
|
87
89
|
</pre>
|
88
90
|
|
89
|
-
* Thumbnails URL for Youtube, Photobucket, Twitpic, and Flickr (flickr in the @http://farm#{num}.static.flickr.com/@ format)
|
91
|
+
* Thumbnails URL for Youtube, Photobucket (photos, not albums), Twitpic, and Flickr (flickr in the @http://farm#{num}.static.flickr.com/@ format)
|
90
92
|
|
91
93
|
<pre>
|
92
94
|
<code>
|
data/VERSION.yml
CHANGED
@@ -4,7 +4,8 @@ class Muri
|
|
4
4
|
module Facebook
|
5
5
|
|
6
6
|
FACEBOOK_PHOTO = "photo"
|
7
|
-
FACEBOOK_VIDEO = "video"
|
7
|
+
#FACEBOOK_VIDEO = "video"
|
8
|
+
FACEBOOK_ALBUM = "album"
|
8
9
|
|
9
10
|
def self.included(base)
|
10
11
|
base.class_eval do
|
@@ -17,31 +18,41 @@ class Muri
|
|
17
18
|
params = @url.query.nil? ? {} : CGI::parse(@url.query)
|
18
19
|
url_common = "http://www.facebook.com"
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# if @url.path =~ /^\/v\/([0-9]+)/
|
22
|
+
# @info[:media_id] = $1
|
23
|
+
# @info[:media_url] = "#{url_common}/v/#{@info[:media_id]}"
|
24
|
+
#
|
25
|
+
# # Currently no API for video, but media_id is best guess value for such content
|
26
|
+
# @info[:media_api_id] = @info[:media_id]
|
27
|
+
# @info[:media_api_type] = FACEBOOK_VIDEO
|
28
|
+
if ((@url.path =~ /^\/photo\.php$/i) &&
|
29
|
+
params.include?("pid") && params["pid"].first =~ /^([0-9]+)$/ &&
|
30
|
+
params.include?("id") && params["id"].first =~ /^([0-9]+)$/ &&
|
31
|
+
params.include?("l") && params["l"].first =~ /^([0-9a-z]+)$/i)
|
23
32
|
|
24
|
-
|
25
|
-
@info[:
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
@info[:media_api_type] = FACEBOOK_PHOTO
|
34
|
+
@info[:media_id] = params["pid"].first
|
35
|
+
media_creator = params["id"].first
|
36
|
+
share_key = params["l"].first
|
37
|
+
|
38
|
+
@info[:website] = "#{url_common}/photo.php?pid=#{@info[:media_id]}&l=#{share_key}&id=#{media_creator}"
|
39
|
+
elsif ((@url.path =~ /^\/album\.php$/i) &&
|
40
|
+
params.include?("aid") && params["aid"].first =~ /^([0-9]+)$/ &&
|
41
|
+
params.include?("id") && params["id"].first =~ /^([0-9]+)$/ &&
|
42
|
+
params.include?("l") && params["l"].first =~ /^([0-9a-z]+)$/i)
|
43
|
+
|
44
|
+
@info[:media_api_type] = FACEBOOK_ALBUM
|
45
|
+
@info[:media_id] = params["aid"].first
|
46
|
+
media_creator = params["id"].first
|
47
|
+
share_key = params["l"].first
|
48
|
+
|
49
|
+
@info[:website] = "#{url_common}/album.php?aid=#{@info[:media_id]}&l=#{share_key}&id=#{media_creator}"
|
39
50
|
end
|
40
51
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
52
|
+
if self.valid?
|
53
|
+
# The media_api_id is the PID which can be searched for in the facebook photos table
|
54
|
+
@info[:media_api_id] = (media_creator.to_i << 32) + @info[:media_id].to_i
|
55
|
+
else
|
45
56
|
raise UnsupportedURI
|
46
57
|
end
|
47
58
|
|
@@ -55,10 +66,11 @@ class Muri
|
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
69
|
+
# http://www.facebook.com/album.php?aid=2131184&id=15201063&l=8917e51479
|
58
70
|
# http://www.facebook.com/photo.php?pid=34929102&l=a1abf8cd37&id=15201063 (preview)
|
59
71
|
# database_pid = (USER_ID << 32) + PID
|
60
72
|
# pid = photo id
|
61
73
|
# id = user id
|
62
74
|
# l = photo share key
|
63
|
-
# http://www.facebook.com/v/614695029223 (full)
|
75
|
+
# http://www.facebook.com/v/614695029223 (full) - deprecated
|
64
76
|
# http://www.facebook.com/album.php?aid=2149275&id=15201063&l=99900807c3
|
@@ -1,8 +1,11 @@
|
|
1
|
+
require 'cgi'
|
1
2
|
class Muri
|
2
3
|
module Filter
|
3
4
|
module Photobucket
|
4
5
|
|
5
6
|
PHOTOBUCKET_MEDIA = "media"
|
7
|
+
PHOTOBUCKET_ALBUM = "album"
|
8
|
+
PHOTOBUCKET_GROUP_ALBUM = "group_album"
|
6
9
|
|
7
10
|
def self.included(base)
|
8
11
|
base.class_eval do
|
@@ -14,9 +17,9 @@ class Muri
|
|
14
17
|
@info[:service] = 'Photobucket'
|
15
18
|
|
16
19
|
@url.host =~ /^([a-z0-9]*?[^(media)])\.photobucket\.com/i
|
17
|
-
server_id = $1.gsub(/([a-z]*)/i,"")
|
20
|
+
@info[:server_id] = $1.gsub(/([a-z]*)/i,"")
|
18
21
|
|
19
|
-
if @url.path =~ /^\/albums\/(
|
22
|
+
if @url.path =~ /^\/albums\/(.+?)\/(.+?)\/((?:.+?\/)*)(.+?)\.(.+)/i #Images
|
20
23
|
photobucket_id = $1
|
21
24
|
media_creator = $2
|
22
25
|
album = $3
|
@@ -24,25 +27,43 @@ class Muri
|
|
24
27
|
@info[:content_type] = $5
|
25
28
|
url_common = "#{server_id}.photobucket.com/albums/#{photobucket_id}/#{media_creator}/#{album}"
|
26
29
|
direct_url_suffix = "#{url_common}#{@info[:media_id]}.#{@info[:content_type]}"
|
27
|
-
|
30
|
+
@info[:media_api_type] = PHOTOBUCKET_MEDIA
|
28
31
|
@info[:media_url] = "http://i#{direct_url_suffix}"
|
29
32
|
@info[:website] = "http://s#{url_common}?action=view¤t=#{@info[:media_id]}.#{@info[:content_type]}"
|
30
|
-
elsif @url.path =~ /^\/
|
33
|
+
elsif @url.path =~ /^\/albums\/(.+?)\/(.+?)\/((?:.[^\/]+?)+)(?:\/|$)/i #Albums
|
34
|
+
photobucket_id = $1
|
35
|
+
media_creator = $2
|
36
|
+
album = $3
|
37
|
+
@info[:media_id] = "#{media_creator}/#{album}"
|
38
|
+
url_common = "#{server_id}.photobucket.com/albums/#{photobucket_id}/#{media_creator}/#{album}"
|
39
|
+
@info[:media_api_type] = PHOTOBUCKET_ALBUM
|
40
|
+
@info[:website] = "http://s#{url_common}/"
|
41
|
+
elsif @url.path =~ /^\/groups\/(.+?)\/(.+?)\/(.+?)\.(.+)/i #Group Images
|
31
42
|
group = $1
|
32
43
|
group_hash_value = $2
|
33
44
|
@info[:media_id] = $3
|
34
45
|
@info[:content_type] = $4
|
35
46
|
url_common = "#{server_id}.photobucket.com/groups/#{group}/#{group_hash_value}"
|
36
47
|
direct_url_suffix = "#{url_common}/#{@info[:media_id]}.#{@info[:content_type]}"
|
37
|
-
|
48
|
+
@info[:media_api_type] = PHOTOBUCKET_MEDIA
|
38
49
|
@info[:media_url] = "http://gi#{direct_url_suffix}"
|
39
50
|
@info[:website] = "http://gs#{url_common}/?action=view¤t=#{@info[:media_id]}.#{@info[:content_type]}"
|
51
|
+
elsif @url.path =~ /^\/groups\/(.+)\/(.+?)(?:\/|$)/i #Group Album
|
52
|
+
group = $1
|
53
|
+
group_hash_value = $2
|
54
|
+
url_common = "#{server_id}.photobucket.com/groups/#{group}/#{group_hash_value}"
|
55
|
+
@info[:media_id] = group_hash_value
|
56
|
+
@info[:website] = "http://gs#{url_common}/"
|
57
|
+
@info[:media_api_type] = PHOTOBUCKET_GROUP_ALBUM
|
40
58
|
end
|
41
59
|
|
42
60
|
if self.valid?
|
43
|
-
@info[:media_api_type]
|
44
|
-
|
45
|
-
|
61
|
+
if @info[:media_api_type] == PHOTOBUCKET_MEDIA
|
62
|
+
@info[:media_api_id] = @info[:media_url]
|
63
|
+
@info[:media_thumbnail] = "http://mobth#{direct_url_suffix}"
|
64
|
+
else
|
65
|
+
@info[:media_api_id] = @info[:media_id]
|
66
|
+
end
|
46
67
|
else
|
47
68
|
raise UnsupportedURI
|
48
69
|
end
|
data/lib/muri/filters/vimeo.rb
CHANGED
@@ -22,7 +22,7 @@ class Muri
|
|
22
22
|
elsif @url.path =~ /^\/groups\/([0-9a-z\@\-\_]+)\/videos\/([0-9]+)(\/)?$/i
|
23
23
|
@info[:media_id] = $2
|
24
24
|
@info[:media_api_type] = VIMEO_VIDEO
|
25
|
-
elsif ((@url.path =~ /^\/moogaloop\.swf
|
25
|
+
elsif ((@url.path =~ /^\/moogaloop\.swf$/i) && (params.include?("clip_id")))
|
26
26
|
@info[:media_id] = params["clip_id"].first if (params["clip_id"].first =~ /([0-9]+)/)
|
27
27
|
@info[:media_api_type] = VIMEO_VIDEO
|
28
28
|
end
|
@@ -31,6 +31,9 @@ class Muri
|
|
31
31
|
@info[:media_api_id] = @info[:media_id]
|
32
32
|
album = (@info[:media_api_type] == VIMEO_ALBUM) ? "album/" : ""
|
33
33
|
@info[:website] = "http://vimeo.com/#{album}#{@info[:media_id]}"
|
34
|
+
if @info[:media_api_type] == VIMEO_VIDEO
|
35
|
+
@info[:media_url] = "http://vimeo.com/moogaloop.swf?clip_id=#{@info[:media_id]}&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1"
|
36
|
+
end
|
34
37
|
else
|
35
38
|
raise UnsupportedURI
|
36
39
|
end
|
data/lib/muri/filters/youtube.rb
CHANGED
@@ -17,16 +17,16 @@ class Muri
|
|
17
17
|
url_common = "http://www.youtube.com"
|
18
18
|
params = @url.query.nil? ? {} : CGI::parse(@url.query)
|
19
19
|
|
20
|
-
if (@url.path =~
|
20
|
+
if (@url.path =~ /^\/watch$/i) && params.include?("v")
|
21
21
|
@info[:media_id] = params["v"].first
|
22
22
|
@info[:media_api_type] = YOUTUBE_VIDEO
|
23
23
|
elsif (@url.path =~ /\/v\/([a-z0-9\-\_]+)/i)
|
24
24
|
@info[:media_id] = $1
|
25
25
|
@info[:media_api_type] = YOUTUBE_VIDEO
|
26
|
-
elsif (@url.path =~
|
26
|
+
elsif (@url.path =~ /^\/p\/([a-z0-9\-\_]+)/i)
|
27
27
|
@info[:media_id] = $1
|
28
28
|
@info[:media_api_type] = YOUTUBE_PLAYLIST
|
29
|
-
elsif (@url.path =~ /^\/view\_play\_list
|
29
|
+
elsif (@url.path =~ /^\/view\_play\_list$/i) && (params.include?('p'))
|
30
30
|
@info[:media_id] = params['p'].first
|
31
31
|
@info[:media_api_type] = YOUTUBE_PLAYLIST
|
32
32
|
end
|
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 = "0.0.
|
8
|
+
s.version = "0.0.10"
|
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-03-
|
12
|
+
s.date = %q{2010-03-14}
|
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 = [
|
data/test/facebook_test.rb
CHANGED
@@ -16,31 +16,31 @@ shared_examples_for "Facebook parse photo" do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
shared_examples_for "Facebook parse video" do
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
19
|
+
# shared_examples_for "Facebook parse video" do
|
20
|
+
# it_should_behave_like "Facebook parse"
|
21
|
+
# it "should have media api type = FACEBOOK_VIDEO" do
|
22
|
+
# @a.media_api_type.should == Muri::FACEBOOK_VIDEO
|
23
|
+
# end
|
24
|
+
# end
|
25
25
|
|
26
|
-
describe "Facebook parse first" do
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
26
|
+
# describe "Facebook parse first" do
|
27
|
+
# before(:all) do
|
28
|
+
# @a = Muri.parse 'http://www.facebook.com/v/614695029223'
|
29
|
+
# end
|
30
|
+
# it_should_behave_like "Facebook parse video"
|
31
|
+
#
|
32
|
+
# it "should have media id" do
|
33
|
+
# @a.media_id.should == '614695029223'
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# it "should have a media_url" do
|
37
|
+
# @a.media_url.should == 'http://www.facebook.com/v/614695029223'
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# it "should have media api id" do
|
41
|
+
# @a.media_api_id.should == '614695029223'
|
42
|
+
# end
|
43
|
+
# end
|
44
44
|
|
45
45
|
describe "Facebook parse second" do
|
46
46
|
before(:all) do
|
data/test/photobucket_test.rb
CHANGED
@@ -8,17 +8,78 @@ shared_examples_for "Photobucket parse" do
|
|
8
8
|
it "should be valid" do
|
9
9
|
@a.valid?.should == true
|
10
10
|
end
|
11
|
+
end
|
12
|
+
|
13
|
+
shared_examples_for "Photobucket parse photo" do
|
14
|
+
it_should_behave_like "Photobucket parse"
|
15
|
+
it "should be Photobucket service" do
|
16
|
+
@a.service.should == 'Photobucket'
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be valid" do
|
20
|
+
@a.valid?.should == true
|
21
|
+
end
|
11
22
|
|
12
23
|
it "should have media api type = PHOTOBUCKET_MEDIA" do
|
13
24
|
@a.media_api_type.should == Muri::PHOTOBUCKET_MEDIA
|
14
25
|
end
|
15
26
|
end
|
27
|
+
shared_examples_for "Photobucket parse album" do
|
28
|
+
it_should_behave_like "Photobucket parse"
|
29
|
+
|
30
|
+
it "should have media api type = PHOTOBUCKET_ALBUM" do
|
31
|
+
@a.media_api_type.should == Muri::PHOTOBUCKET_ALBUM
|
32
|
+
end
|
33
|
+
end
|
34
|
+
shared_examples_for "Photobucket parse group album" do
|
35
|
+
it_should_behave_like "Photobucket parse"
|
36
|
+
|
37
|
+
it "should have media api type = PHOTOBUCKET_GROUP_ALBUM" do
|
38
|
+
@a.media_api_type.should == Muri::PHOTOBUCKET_GROUP_ALBUM
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "Photobucket parse group album first" do
|
43
|
+
before(:all) do
|
44
|
+
@a = Muri.parse 'http://gs0001.photobucket.com/groups/0001/F9P8EG7YR8/'
|
45
|
+
end
|
46
|
+
it_should_behave_like "Photobucket parse group album"
|
47
|
+
|
48
|
+
it "should have media id" do
|
49
|
+
@a.media_id.should == 'F9P8EG7YR8'
|
50
|
+
end
|
51
|
+
it "should have media api id" do
|
52
|
+
@a.media_id.should == 'F9P8EG7YR8'
|
53
|
+
end
|
54
|
+
|
55
|
+
it "shoud have website" do
|
56
|
+
@a.website.should == 'http://gs0001.photobucket.com/groups/0001/F9P8EG7YR8/'
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe "Photobucket parse album first" do
|
61
|
+
before(:all) do
|
62
|
+
@a = Muri.parse 'http://s244.photobucket.com/albums/gg17/pbapi/api-test/api-test-subalbum/'
|
63
|
+
end
|
64
|
+
it_should_behave_like "Photobucket parse album"
|
65
|
+
|
66
|
+
it "should have media id" do
|
67
|
+
@a.media_id.should == 'pbapi/api-test/api-test-subalbum'
|
68
|
+
end
|
69
|
+
it "should have media api id" do
|
70
|
+
@a.media_id.should == 'pbapi/api-test/api-test-subalbum'
|
71
|
+
end
|
72
|
+
|
73
|
+
it "shoud have website" do
|
74
|
+
@a.website.should == 'http://s244.photobucket.com/albums/gg17/pbapi/api-test/api-test-subalbum/'
|
75
|
+
end
|
76
|
+
end
|
16
77
|
|
17
78
|
describe "Photobucket parse first" do
|
18
79
|
before(:all) do
|
19
80
|
@a = Muri.parse 'http://i244.photobucket.com/albums/gg17/pbapi/file.jpg'
|
20
81
|
end
|
21
|
-
it_should_behave_like "Photobucket parse"
|
82
|
+
it_should_behave_like "Photobucket parse photo"
|
22
83
|
|
23
84
|
it "should have media id" do
|
24
85
|
@a.media_id.should == 'file'
|
@@ -49,7 +110,7 @@ describe "Photobucket parse second" do
|
|
49
110
|
before(:all) do
|
50
111
|
@a = Muri.parse 'http://gi0006.photobucket.com/groups/0006/G5PAK3TBQS/DSCF0015-1-1.jpg'
|
51
112
|
end
|
52
|
-
it_should_behave_like "Photobucket parse"
|
113
|
+
it_should_behave_like "Photobucket parse photo"
|
53
114
|
|
54
115
|
it "should have media id" do
|
55
116
|
@a.media_id.should == 'DSCF0015-1-1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Schneider
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-03-
|
12
|
+
date: 2010-03-14 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|