-
Notifications
You must be signed in to change notification settings - Fork 0
/
parseAlbum.rb
executable file
·54 lines (46 loc) · 1.12 KB
/
parseAlbum.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/ruby
require "rubygems"
require "php_serialize"
require "go_picasa_go"
require "theuser.rb"
require "getFileAsString.rb"
require "parsePhoto.rb"
class AlbumInfo
attr_accessor :picasaAlbum
@@user = Theuser.new
def initialize(galleryItem)
@item = galleryItem
@title = galleryItem.fields["name"]
end
def addtoPicasa
@picasaAlbum = Picasa::DefaultAlbum.new
@picasaAlbum.user = @@user
@picasaAlbum.title = @title
@picasaAlbum.access = 'private'
@picasaAlbum.picasa_save!
end
def getfromPicasa
allAlbums = @@user.albums
puts @title
@picasaAlbum = allAlbums.find {|a| a.title = @title}
puts "Found " + @picasaAlbum.title
end
end
class AlbumParser
def initialize(albumFolder, albumFile)
@folder = albumFolder
toDeserialize = get_file_as_string(albumFile)
out = PHP.unserialize(toDeserialize)
album = AlbumInfo.new(out)
if(!File.exist?(@folder + 'photosDone.txt'))
puts("Already processed this album once")
album.addtoPicasa
else
album.getfromPicasa
end
processor = PhotoParser.new(album.picasaAlbum, @folder)
open('albumsDone.txt', 'w'){|f|
f.puts(albumFile)
}
end
end