Aol e linux
Inviato: sabato 22 dicembre 2007, 3:24
Salve,
che voi sappiate esiste qualche programma e/o estensione per firefox che permetta di caricare le foto su aol foto? Vi chiedo questo perchè se lo faccio via browser devo selezionare le foto singolarmente e non tutte insieme e, per chi come me ha tante foto, risulta un po scomodo.
Grazie a tutti.
EDIT: girando per il web mi sono imbattuto in questo script in ruby, sapreste dirmi cosa devo modificare e dove devo mettere lo script affinchè mi carichi le foto di un'intera cartella?
che voi sappiate esiste qualche programma e/o estensione per firefox che permetta di caricare le foto su aol foto? Vi chiedo questo perchè se lo faccio via browser devo selezionare le foto singolarmente e non tutte insieme e, per chi come me ha tante foto, risulta un po scomodo.
Grazie a tutti.
EDIT: girando per il web mi sono imbattuto in questo script in ruby, sapreste dirmi cosa devo modificare e dove devo mettere lo script affinchè mi carichi le foto di un'intera cartella?
Codice: Seleziona tutto
#!/usr/bin/env ruby -W0
=begin
* Name: fotoAOL.rb
* Description: Linux mass uploader for foto.aol.it
* Author: Z3n0 (http://Z3n0.netsons.org)
* License: GPL2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=end
require 'net/http'
require 'net/https'
require 'uri'
require 'optparse'
@DEBUG = @VERBOSE = false
@USER = @PASS = @ALBUM = ''
@PATH = Dir.pwd
@EXT = "jpg|jpeg|gif|png|tiff"
USERAGENT= 'Mozilla/5.0 (X11; U; Linux i686; it-IT)'
parser = OptionParser.new do |opts|
opts.banner = File.basename($0)," - Copyright 2007 Z3n0\n",
"Usage:\t", File.basename($0)," [options]"
opts.separator ''
opts.separator 'Options:'
opts.on('-u', '--user UserName',
'Give username for login.') do |p|
@USER = p
end
opts.on('-P', '--pass Password',
'Give password for login.') do |p|
@PASS = p
end
opts.on('-a', '--album "Album Name"',
'Give album name (default name: Directory name).') do |p|
@ALBUM = URI.escape(p)
end
opts.on('-p', '--path Path', 'Path to files (default is current dir).') do |p|
@PATH = p if File.directory?(p)
end
opts.on('-d', '--debug', 'Run in debug mode.') do
@DEBUG = true
end
opts.on('-D', 'Run in verbose debug mode.') do
@VERBOSE = true
@DEBUG = true
end
opts.on_tail('-h', '--help', 'Show this message.') do
puts opts
exit
end
opts.on_tail("--version", "Show version.") do
puts OptionParser::Version.join('.')
exit
end
end
begin
parser.parse!(ARGV)
rescue OptionParser::InvalidOption
puts 'Invalid option, pass the --help parameter to get help!'
exit
end
if @USER == ''
print "Username: "
@USER = gets.chomp
end
if @PASS == ''
print "Password: "
begin
system "stty -echo"
@PASS = gets.chomp
print "\n"
ensure
system "stty echo"
end
end
if @ALBUM == ''
@ALBUM = @PATH.split("/").last
end
# .................. FASE 1 ..................
printf "Logging in: "
url = Net::HTTP.new('my.screenname.aol.com', 443)
url.use_ssl = true
url.verify_mode = OpenSSL::SSL::VERIFY_NONE
data = 'screenname=' + URI.escape(@USER, '@') + '&password=' + URI.escape(@PASS)+
'&sitedomain=intl.pictures.aol.com&mcState=initialized&lang=it&locale=it'
@headers = {
'User-Agent' => USERAGENT,
'Referer' => 'http://foto.aol.it/',
'Content-Type' => 'application/x-www-form-urlencoded'
}
resp = url.post('/_cqr/login/login.psp', data, @headers)
if resp.body.upcase.match('Password dimenticata'.upcase)
printf "Failed!\n"
exit
end
redir = resp.body.split("\n").fetch(-4).split("'").fetch(5)
if @DEBUG
puts "\n\n"+"="*24+"[ FASE 1 ]"+"="*24+"\n\n"
puts 'Code = ' + resp.code
resp.each {|key, val| printf "%-20s = %-50.50s\n", key, val }
if @VERBOSE
puts "~"*58
puts resp.body
end
puts "~"*58
puts 'Redirect to: '+redir
printf "Logging in: "
end
printf "."
# .................. FASE 2 ..................
url = Net::HTTP.new(URI::parse(redir).host)
url.use_ssl = false
@headers = {
'User-Agent' => USERAGENT
}
resp = url.get2(URI::parse(redir).path+'?'+URI::parse(redir).query, @headers)
cookie = resp.response['set-cookie'].split(%r{[;\s]})
if @DEBUG
puts "\n\n"+"="*24+"[ FASE 2 ]"+"="*24+"\n\n"
puts 'Code = ' + resp.code
resp.each {|key, val| printf "%-20s = %-50.50s\n", key, val }
if @VERBOSE
puts "~"*58
splitNum=0
cookie.each {|key|
puts "COOKIE[#{splitNum}] => " + key
splitNum += 1 }
end
puts "~"*58
puts 'Cookie '+cookie[10]
printf "Logging in: ."
end
printf "."
cookieAppend = cookie[10] # =RSP_LOCAL_INTL.PICTURES.AOL.COM
# .................. FASE 3 ..................
url = Net::HTTP.new('foto.aol.it')
@headers = {
'Cookie' => cookieAppend,
'User-Agent' => USERAGENT
}
resp = url.get('/', @headers)
if @DEBUG
puts "\n\n"+"="*24+"[ FASE 3 ]"+"="*24+"\n\n"
puts 'Code = ' + resp.code
resp.each {|key, val| printf "%-20s = %-50.50s\n", key, val }
if @VERBOSE
puts "~"*58
cookie = resp.response['set-cookie'].split(%r{[;,]})
splitNum=0
cookie.each {|key|
puts "COOKIE[#{splitNum}] => " + key
splitNum += 1 }
end
printf "Logging in: .."
end
if resp.body.upcase.match(
'<h1 class="npHidden">Album personali</h1>'.upcase)
printf ". OK\n"
else
puts ". Failed!\n"
exit
end
# .................. FASE 4 ..................
printf "Creating album "+@ALBUM+": "
files = Dir.new(@PATH).entries.sort.delete_if { |x| ! (x =~ /(#{@EXT})$/xi) } # ...sort.reverse...
tot = files.length
#exit if tot > 999
url = Net::HTTP.new('foto.aol.it')
url.use_ssl=false
@headers = {
'Cookie' => cookieAppend,
'User-Agent' => USERAGENT,
'Referer' => 'http://foto.aol.it/ap/createAlbum.do'
}
resp = url.post('/ap/pipe.do?_npcmd=getRedirector',
'title='+@ALBUM+'&count='+tot.to_s+'&command=getRedirector', @headers)
albumID = nil
if @DEBUG
puts "\n\n"+"="*24+"[ FASE 4 ]"+"="*24+"\n\n"
puts 'Code = ' + resp.code
resp.each {|key, val| printf "%-20s = %-50.50s\n", key, val }
if @VERBOSE
puts resp.body
end
puts "~"*58
end
resp = resp.body.split("\n")
resp.each {|key|
if key.match('redirectorUrl')
redir = key.split('\'')[3]
puts "redir => "+redir if @DEBUG
end
if key.match('albumId')
albumID = key.split('\'')[3]
puts "albumID => "+albumID if @DEBUG
end }
printf "Creating album "+@ALBUM+": " if @DEBUG
if albumID =~ /^(\d+\.\d+\.\d+\.\d+)$/
printf "OK\n"
else
printf "Failed\n"
exit
end
# .................. FASE 5 ..................
# ............... da reiterare ...............
printf "Upload file(s): [Cancel with Ctrl-C]\n"
url = Net::HTTP.new(URI::parse(redir).host)
url.use_ssl = false
num = 1
files.each { |filename|
printf "[%0-3d/%0-3d] %-16s: ", num, tot, filename
boundary = [Array.new(18) {rand(256)}].join
boundary = "-"*(54-boundary.length) + boundary
@headers = {
'User-Agent' => USERAGENT,
'Referer' => 'http://foto.aol.it/ap/Resources/2.0.10.00/html/hiddenButton.html',
'Content-Type' => 'multipart/form-data; boundary=' + boundary
}
content = open( filename ) { |f|
f.read
}
data = "--" + boundary+"\r\n"
data += 'Content-Disposition: form-data; name="uploadfile"; filename="' +
filename + '"' +"\r\n"
data += 'Content-Type: image/' +
(("jpeg" if (filename =~ /(jpg|jpeg)$/i)) || "") +
(("gif" if (filename =~ /gif$/i)) || "") +
(("png" if (filename =~ /png$/i)) || "") +
(("tiff" if (filename =~ /tiff$/i)) || "") + "\r\n\r\n"
data += content + "\r\n"
data += "--" + boundary + "--\r\n"
resp = url.post(URI::parse(redir).path+'?'+URI::parse(redir).query,
data, @headers)
if @DEBUG
puts "\n\n"+"="*24+"[ FASE 5 ]"+"="*24+"\n\n"
puts 'Code = ' + resp.code
puts 'x-upload = ' + resp.response["x-upload"]
if @VERBOSE
puts data
puts resp.body
end
puts "~"*58
end
if (resp.response["x-upload"].upcase.match('OK'))
printf "Upload OK\n"
else
printf "ERROR -- %s\n", resp.body.split("'").fetch(5)
end
num += 1
}