picasaweb 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ == 1.0.0 / 2007-11-29
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/picasaweb
6
+ lib/picasaweb.rb
7
+ test/test_picasaweb.rb
@@ -0,0 +1,59 @@
1
+ picasaweb
2
+ by Logan Koester
3
+ http://logankoester.com/tools/picasaweb
4
+
5
+ == DESCRIPTION:
6
+
7
+ Ruby interface to Google's Picasa Web Albums (photo sharing site). Includes a command-line tool for downloading photos from Picasa albums.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Users have many Albums, Albums have many Photos.
12
+ * Users have a name, url, and albums
13
+ * Albums have a title, description, link (url), date and photos
14
+ * Photos have a title, description, image (url), link (url), and date
15
+ * Not implemented at this time (feel free!): Search, posting/updating/deleting photos, adding albums, and editing tags and comments
16
+ * Untested on Windows/Mac
17
+
18
+ == SYNOPSIS:
19
+
20
+ # Displaying a list of photos in an album
21
+ my_album = PicasaAlbum.new( "http://picasaweb.google.com/BeatForgeProductions/Euphoria_Nov" )
22
+ my_album.photos.each do |photo|
23
+ puts photo.title + " at " + photo.image + "\n\n"
24
+ end
25
+
26
+ == REQUIREMENTS:
27
+
28
+ * Ruby
29
+ * Wget
30
+ * Ruby gems: rubygems, rss/1.0, rss/2.0, open-uri, hpricot, optiflag
31
+
32
+ == INSTALL:
33
+
34
+ * sudo gem install picasaweb
35
+
36
+ == LICENSE:
37
+
38
+ (The MIT License)
39
+
40
+ Copyright (c) 2007 FIX
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining
43
+ a copy of this software and associated documentation files (the
44
+ 'Software'), to deal in the Software without restriction, including
45
+ without limitation the rights to use, copy, modify, merge, publish,
46
+ distribute, sublicense, and/or sell copies of the Software, and to
47
+ permit persons to whom the Software is furnished to do so, subject to
48
+ the following conditions:
49
+
50
+ The above copyright notice and this permission notice shall be
51
+ included in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
54
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
57
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
58
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
59
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+ require './lib/picasaweb.rb'
6
+
7
+ Hoe.new('picasaweb', Picasaweb::VERSION) do |p|
8
+ p.rubyforge_name = 'picasaweb'
9
+ # p.author = 'Logan Koester'
10
+ # p.email = 'logan@logankoester.com'
11
+ # p.summary = "Ruby interface to Google's Picasa Web Albums (photo sharing site). Includes a command-line tool for downloading photos from Picasa albums."
12
+ # p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
13
+ # p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
14
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
15
+ end
16
+
17
+ # vim: syntax=Ruby
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/ruby
2
+ ###############################################################################
3
+ # Command-line tool for downloading photos from Picasa albums. May be expanded
4
+ # to other picasaweb-related tasks in the future as the picasaweb gem's
5
+ # functionality grows.
6
+ #
7
+ # See README.txt for more documentation
8
+ #
9
+ # Created by Logan Koester of Icecraft Media <logan@logankoester.com>
10
+ #
11
+ ###############################################################################
12
+
13
+ require 'picasaweb'
14
+ require 'optiflag'
15
+
16
+ def download_album_images (url)
17
+ my_album = PicasaAlbum.new( url )
18
+ `mkdir #{my_album.title}`
19
+ my_album.photos.each do |photo|
20
+ `wget --directory-prefix=#{my_album.title} #{photo.image}`
21
+ end
22
+ end
23
+
24
+ def download_user_images (username)
25
+ `mkdir #{username}`
26
+ my_user = PicasaUser.new("http://picasaweb.google.com/" + username)
27
+ my_user.albums.each do |album|
28
+ `mkdir #{username}/#{album.title}`
29
+ album.photos.each do |photo|
30
+ `wget --directory-prefix=#{username}/#{album.title} #{photo.image}`
31
+ end
32
+ end
33
+ end
34
+
35
+ module ParseFlags extend OptiFlagSet
36
+ # Set command-line arguments and such here
37
+ # See http://optiflag.rubyforge.org/ for help
38
+ optional_flag 'user'
39
+ optional_flag 'album'
40
+ and_process!
41
+ end
42
+
43
+ if (ARGV.flags.user)
44
+ download_user_images( ARGV.flags.user )
45
+ elsif (ARGV.flags.album)
46
+ download_album_images( ARGV.flags.album )
47
+ else
48
+ puts "picasaweb "
49
+ puts "A Ruby interface to Picasa Web Albums"
50
+ puts "If you run into trouble, mailto:logan@logankoester.com\n\n"
51
+ puts "To download an album:"
52
+ puts " picasaweb -album http://picasaweb.google.com/USERNAME/ALBUM\n\n"
53
+ puts "To download every album from a user:"
54
+ puts " picasaweb -user USERNAME\n\n"
55
+ puts "Enjoy!"
56
+ end
@@ -0,0 +1,112 @@
1
+ ###############################################################################
2
+ # Picasaweb: Ruby interface to Google's Picasa Web Albums (photo sharing site).
3
+ # See README.txt for more documentation
4
+ #
5
+ # Created by Logan Koester of Icecraft Media <logan@logankoester.com>
6
+ #
7
+ # Want to extend this library?
8
+ # Start here: http://code.google.com/apis/picasaweb/overview.html
9
+ #
10
+ # For usage examples see the included command-line utility (bin/picasaweb)
11
+ #
12
+ ###############################################################################
13
+
14
+ %w{rubygems rss/1.0 rss/2.0 open-uri hpricot}.each { |requirement| require requirement }
15
+
16
+ class Picasaweb
17
+ VERSION = '1.0.0'
18
+ def parse_rss (source)
19
+ # Parse an RSS feed
20
+ # See http://www.rubyrss.com/
21
+ content = ""
22
+ open(source) { |s| content = s.read }
23
+ return RSS::Parser.parse(content, false)
24
+ end
25
+
26
+ def find_rss (url, title)
27
+ # Find a specific RSS feed by the title attribute of it's <link> element
28
+ # The feed for a user's albums is titled "RSS Gallery Feed."
29
+ # The feed for an album's photos is titled "RSS Album Feed."
30
+ # You may need to modify this method if Google changes their HTML
31
+ content = ""
32
+ open(url) { |s| content = s.read }
33
+ document = Hpricot( content )
34
+ (document/"link").each do |link|
35
+ if (link.attributes['title'] == title)
36
+ return link.attributes['href']
37
+ end
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ class PicasaUser < Picasaweb
44
+ attr_reader :name, :link, :albums
45
+ def initialize (url)
46
+ @link = url
47
+
48
+ # Find the user's RSS feed and parse it
49
+ rss = parse_rss( find_user_rss( @link ) )
50
+
51
+ @name = rss.channel.title
52
+ @albums = get_albums_from_rss( rss )
53
+ end
54
+
55
+ def find_user_rss (url)
56
+ find_rss( url, "RSS Gallery Feed." )
57
+ end
58
+
59
+ def get_albums_from_rss(rss)
60
+ # Map albums from RSS to objects.
61
+ # Expects a parsed RSS object, not a string!
62
+ albums = Array.new
63
+ rss.items.each do |item|
64
+ album = PicasaAlbum.new( item.link )
65
+ albums.push( album )
66
+ end
67
+ return albums
68
+ end
69
+
70
+ end
71
+
72
+ class PicasaPhoto < Picasaweb
73
+ attr_accessor :title, :description, :image, :link, :date
74
+ end
75
+
76
+ class PicasaAlbum < Picasaweb
77
+ attr_reader :title, :description, :link, :date, :photos
78
+
79
+ def initialize (url)
80
+ @link = url
81
+
82
+ # Find the album's RSS feed and parse it
83
+ rss = parse_rss( find_album_rss( @link ) )
84
+
85
+ @title = rss.channel.title
86
+ @description = rss.channel.description
87
+ @date = rss.channel.date # Accurate?
88
+
89
+ @photos = get_photos_from_rss( rss )
90
+ end
91
+
92
+ def get_photos_from_rss(rss)
93
+ # Map photos from RSS to objects.
94
+ # Expects a parsed RSS object, not a string!
95
+ photos = Array.new
96
+ rss.items.each do |item|
97
+ photo = PicasaPhoto.new
98
+ photo.title = item.title
99
+ photo.description = item.description # raw html - could be parsed?
100
+ photo.link = item.link
101
+ photo.date = item.date # accurate?
102
+ photo.image = item.enclosure.url
103
+ photos.push( photo )
104
+ end
105
+ return photos
106
+ end
107
+
108
+ def find_album_rss (url)
109
+ find_rss( url, "RSS Album Feed." )
110
+ end
111
+
112
+ end
@@ -0,0 +1,2 @@
1
+ # Sorry, I didn't write any tests. Shame on me!
2
+
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: picasaweb
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.0.0
7
+ date: 2007-11-29 00:00:00 -05:00
8
+ summary: The author was too lazy to write a summary
9
+ require_paths:
10
+ - lib
11
+ email: ryand-ruby@zenspider.com
12
+ homepage: http://www.zenspider.com/ZSS/Products/picasaweb/
13
+ rubyforge_project: picasaweb
14
+ description: The author was too lazy to write a description
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Ryan Davis
31
+ files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ - Rakefile
36
+ - bin/picasaweb
37
+ - lib/picasaweb.rb
38
+ - test/test_picasaweb.rb
39
+ test_files:
40
+ - test/test_picasaweb.rb
41
+ rdoc_options:
42
+ - --main
43
+ - README.txt
44
+ extra_rdoc_files:
45
+ - History.txt
46
+ - Manifest.txt
47
+ - README.txt
48
+ executables:
49
+ - picasaweb
50
+ extensions: []
51
+
52
+ requirements: []
53
+
54
+ dependencies:
55
+ - !ruby/object:Gem::Dependency
56
+ name: hoe
57
+ version_requirement:
58
+ version_requirements: !ruby/object:Gem::Version::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 1.3.0
63
+ version: