morgoth-picasa 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +8 -8
- data/VERSION.yml +2 -2
- data/lib/picasa.rb +10 -33
- data/lib/web_albums.rb +47 -0
- data/picasa.gemspec +4 -3
- data/test/picasa_test.rb +19 -19
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -2,25 +2,25 @@
|
|
2
2
|
|
3
3
|
Simple google picasa managment.
|
4
4
|
Only for public albums so far.
|
5
|
-
|
5
|
+
|
6
6
|
= Installation
|
7
7
|
|
8
8
|
gem sources -a http://gems.github.com
|
9
9
|
sudo gem install morgoth-picasa
|
10
10
|
|
11
11
|
In RAILS_ROOT/config/environment.rb
|
12
|
-
|
12
|
+
|
13
13
|
config.gem "morgoth-picasa", :lib => "picasa"
|
14
14
|
|
15
15
|
== Usage
|
16
16
|
|
17
|
-
Picasa.albums(google_username)
|
18
|
-
#=> [ {:id => "666", :title => "satan-album", :photos_count =>
|
19
|
-
|
20
|
-
Picasa.photos(google_username, album_id)
|
17
|
+
Picasa.albums(:google_username => 'google_username')
|
18
|
+
#=> [ {:id => "666", :title => "satan-album", :photos_count => 6}, {another one} ]
|
19
|
+
|
20
|
+
Picasa.photos(:google_username => google_username, :album_id => 'album_id')
|
21
21
|
#=> {:photos => [{ :title, :thumbnail_1, :thumbnail_2, :thumbnail_3, :photo },{}],
|
22
|
-
#
|
23
|
-
|
22
|
+
# :slideshow => "link to picasa slideshow"}
|
23
|
+
|
24
24
|
= Copyright
|
25
25
|
|
26
26
|
Copyright (c) 2009 Wojciech Wnętrzak, released under the MIT license.
|
data/VERSION.yml
CHANGED
data/lib/picasa.rb
CHANGED
@@ -2,38 +2,15 @@ module Picasa
|
|
2
2
|
require 'net/http'
|
3
3
|
require "xmlsimple"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
albums
|
10
|
-
xml['entry'].each do |album|
|
11
|
-
attribute = {}
|
12
|
-
attribute[:id] = album['id'][1]
|
13
|
-
attribute[:title] = album['title'][0]['content']
|
14
|
-
attribute[:photos_count] = album['numphotos'][0]
|
15
|
-
albums << attribute
|
16
|
-
end
|
17
|
-
albums
|
5
|
+
require 'web_albums.rb'
|
6
|
+
|
7
|
+
def self.albums(options = {})
|
8
|
+
web_albums = Picasa::WebAlbums.new(options[:google_user])
|
9
|
+
web_albums.albums
|
18
10
|
end
|
19
11
|
|
20
|
-
def photos(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
xml['entry'].each do |photo|
|
26
|
-
attribute = {}
|
27
|
-
attribute[:title] = photo['group'][0]['description'][0]['content'] #returns nil if empty
|
28
|
-
attribute[:thumbnail_1] = photo['group'][0]['thumbnail'][0]['url']
|
29
|
-
attribute[:thumbnail_2] = photo['group'][0]['thumbnail'][1]['url']
|
30
|
-
attribute[:thumbnail_3] = photo['group'][0]['thumbnail'][2]['url']
|
31
|
-
#attributes[:photo] << photo['group'][0]['content']['url']
|
32
|
-
attribute[:photo] = photo['content']['src']
|
33
|
-
photos << attribute
|
34
|
-
end
|
35
|
-
{ :photos => photos, :slideshow => xml['link'][2]['href'] }
|
36
|
-
end
|
37
|
-
|
38
|
-
module_function :albums, :photos
|
39
|
-
end
|
12
|
+
def self.photos(options = {})
|
13
|
+
web_albums = Picasa::WebAlbums.new(options[:google_user])
|
14
|
+
web_albums.photos(options[:album_id])
|
15
|
+
end
|
16
|
+
end
|
data/lib/web_albums.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Picasa
|
2
|
+
class WebAlbums
|
3
|
+
attr_accessor :google_user
|
4
|
+
|
5
|
+
def initialize(google_user)
|
6
|
+
@google_user = google_user
|
7
|
+
end
|
8
|
+
|
9
|
+
def albums
|
10
|
+
data = connect("/data/feed/api/user/#{google_user}")
|
11
|
+
xml=XmlSimple.xml_in(data)
|
12
|
+
albums = []
|
13
|
+
xml['entry'].each do |album|
|
14
|
+
attribute = {}
|
15
|
+
attribute[:id] = album['id'][1]
|
16
|
+
attribute[:title] = album['title'][0]['content']
|
17
|
+
attribute[:photos_count] = album['numphotos'][0].to_i
|
18
|
+
albums << attribute
|
19
|
+
end
|
20
|
+
albums
|
21
|
+
end
|
22
|
+
|
23
|
+
def photos(album_id)
|
24
|
+
data = connect("/data/feed/api/user/#{google_user}/albumid/#{album_id}")
|
25
|
+
xml = XmlSimple.xml_in(data)
|
26
|
+
photos = []
|
27
|
+
xml['entry'].each do |photo|
|
28
|
+
attribute = {}
|
29
|
+
attribute[:title] = photo['group'][0]['description'][0]['content'] #returns nil if empty
|
30
|
+
attribute[:thumbnail_1] = photo['group'][0]['thumbnail'][0]['url']
|
31
|
+
attribute[:thumbnail_2] = photo['group'][0]['thumbnail'][1]['url']
|
32
|
+
attribute[:thumbnail_3] = photo['group'][0]['thumbnail'][2]['url']
|
33
|
+
#attributes[:photo] << photo['group'][0]['content']['url']
|
34
|
+
attribute[:photo] = photo['content']['src']
|
35
|
+
photos << attribute
|
36
|
+
end
|
37
|
+
{ :photos => photos, :slideshow => xml['link'][2]['href'] }
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def connect(url)
|
43
|
+
full_url = "http://picasaweb.google.com" + url
|
44
|
+
Net::HTTP.get(URI.parse(full_url))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/picasa.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{picasa}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Wojciech Wn\304\231trzak"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-02}
|
10
10
|
s.email = %q{w.wnetrzak@gmail.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
"Rakefile",
|
21
21
|
"VERSION.yml",
|
22
22
|
"lib/picasa.rb",
|
23
|
+
"lib/web_albums.rb",
|
23
24
|
"picasa.gemspec",
|
24
25
|
"test/fixtures/albums",
|
25
26
|
"test/fixtures/photos",
|
@@ -29,7 +30,7 @@ Gem::Specification.new do |s|
|
|
29
30
|
s.homepage = %q{http://github.com/morgoth/picasa}
|
30
31
|
s.rdoc_options = ["--charset=UTF-8"]
|
31
32
|
s.require_paths = ["lib"]
|
32
|
-
s.rubygems_version = %q{1.3.
|
33
|
+
s.rubygems_version = %q{1.3.4}
|
33
34
|
s.summary = %q{simple google picasa managment}
|
34
35
|
s.test_files = [
|
35
36
|
"test/picasa_test.rb",
|
data/test/picasa_test.rb
CHANGED
@@ -3,34 +3,34 @@ require 'test_helper'
|
|
3
3
|
class PicasaTest < Test::Unit::TestCase
|
4
4
|
context 'with albums page' do
|
5
5
|
setup do
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
page = fixture_file('albums')
|
7
|
+
FakeWeb.register_uri(:get, "picasaweb.google.com/data/feed/api/user/some.user", :response => page)
|
8
|
+
end
|
9
9
|
|
10
10
|
should 'parse it' do
|
11
|
-
albums = Picasa.albums('some.user')
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
albums = Picasa.albums(:google_user => 'some.user')
|
12
|
+
assert_equal 5, albums.count
|
13
|
+
assert_equal "SAPS in da akcion :P", albums.first[:title]
|
14
|
+
assert_equal 10, albums[2][:photos_count]
|
15
|
+
assert_equal "5277503612406515713", albums.first[:id]
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
context 'with photos page' do
|
20
20
|
setup do
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
page = fixture_file('photos')
|
22
|
+
FakeWeb.register_uri(:get, "picasaweb.google.com/data/feed/api/user/some.user/albumid/666", :response => page)
|
23
|
+
end
|
24
24
|
|
25
25
|
should 'parse it' do
|
26
|
-
photos = Picasa.photos('some.user', '666')
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
photos = Picasa.photos(:google_user => 'some.user', :album_id => '666')
|
27
|
+
assert_equal photos[:photos].count.to_i, 10
|
28
|
+
assert_not_nil photos[:slideshow]
|
29
|
+
assert_not_nil photos[:photos].first[:thumbnail_1]
|
30
|
+
assert_not_nil photos[:photos].first[:thumbnail_2]
|
31
|
+
assert_not_nil photos[:photos].first[:thumbnail_3]
|
32
|
+
assert_nil photos[:photos].first[:title]
|
33
|
+
assert_equal photos[:photos].first[:photo], "http://lh5.ggpht.com/_Kp7xCOU0f_U/SQS8EFqEXjI/AAAAAAAAAFo/aUOA6byXAuE/Jurek.JPG"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: morgoth-picasa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Wojciech Wn\xC4\x99trzak"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-07-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- VERSION.yml
|
41
41
|
- lib/picasa.rb
|
42
|
+
- lib/web_albums.rb
|
42
43
|
- picasa.gemspec
|
43
44
|
- test/fixtures/albums
|
44
45
|
- test/fixtures/photos
|