Replace each "#" with a space. :)
import urllib
import httplib
import sys
import glob
import os.path
USERNAME = ''
PASSWORD = ''
VOLUME = ''
class FileUploadRequest:
####def __init__(self, uri, host, port):
########self.uri = uri
########self.host = host
########self.port = port
########self.queryString = None
########self.boundary= '-----------------------------11477706891467868222366684681'
########self.parts = []
####def loadfile(self, filepath, fieldname, headerDict=None):
########f = PrivoxyWindowOpen(filepath, 'rb')
########data = f.read()
########f.close()
########if filepath.find('/') != -1:
############filename = filepath.split('/')<-1>
########else:
############filename = filepath
########hdr = []
########hdr.append('%s' % ('--' + self.boundary))
########hdr.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (fieldname, filename))
########if filename.lower().endswith('jpg') or filename.lower().endswith('jpeg'):
############hdr.append('Content-Type: image/jpeg')
########elif filename.lower().endswith('gif'):
############hdr.append('Content-Type: image/gif')
########elif filename.lower().endswith('png'):
############hdr.append('Content-Type: image/png')
########if type(headerDict) == type({}):
############for k in headerDict.keys():
################hdr.append("%s: %s", (k, headerDict
))
########part = '%s\r\n\r\n%s' % ('\r\n'.join(hdr) , data)
########self.parts.extend()
####def loadfield(self, fieldname, data, headerDict=None):
########hdr = []
########hdr.append('%s' % ('--' + self.boundary))
########hdr.append('Content-Disposition: form-data; name="%s"' % fieldname)
########if type(headerDict) == type({}):
############for k in headerDict.keys():
################hdr.append("%s: %s", (k, headerDict))
########part='%s\r\n\r\n%s' % ('\r\n'.join(hdr) , data)
########self.parts.extend()
####def request(self, cookie):
########query = '%s\r\n%s' % ('\r\n'.join(self.parts), ('--' + self.boundary))
########query += '--\r\n'
########contentType = 'multipart/form-data; boundary=%s' % self.boundary
########contentLength = str(len(query))
########h = httplib.HTTP()
########h.connect(self.host, self.port)
########h.putrequest('POST', self.uri)
########h.putheader('Host', 'photobucket.com')
########h.putheader('User-Agent', 'Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.2) Gecko/20040803')
########h.putheader('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5')
########h.putheader('Accept-Language', 'en-us,en;q=0.5')
########h.putheader('Accept-Charset', 'ISO-8859-1,utf-8;q=0.7,*;q=0.7')
########h.putheader('Referer', 'http://photobucket.com/')
########h.putheader('Content-Type', contentType)
########h.putheader('Content-Length', contentLength)
########h.putheader('Cookie', cookie)
########h.putheader('Connection', 'close')
########h.endheaders()
########h.send(query)
########rcode, rmsg, headers = h.getreply()
########response = h.getfile().read()
########return int(rcode)
def LoginToPhotobucket():
####f = urllib.urlopen('http://photobucket.com/login.php?', \
####urllib.urlencode({'action': 'login', 'login':'Login', 'username':USERNAME, 'password':PASSWORD}))
####cookie = f.info().getheader('Set-Cookie') + ';'
####cookie = cookie.replace(' path=/;', '')
####return cookie
def UploadFileToPhotobucket(filepath, cookie):
####if filepath.find('/') != -1:
########filename = filepath.split('/')<-1>
####else:
########filename = filepath
####uri = '/albums/' + VOLUME + '/' + USERNAME + '/?sc=3'
####F = FileUploadRequest(uri, 'photobucket.com', 80)
####F.loadfield("action" , "addpic")
####F.loadfield("multi" , "")
####F.loadfield("addtype" , "")
####F.loadfile(filepath, "the_file[]")
####F.loadfield("desc[]", "")
####F.loadfield("preserve", "true")
####F.request(cookie)
def DeleteFileFromPhotobucket(filename, cookie):
####uri = '/albums/' + VOLUME + '/' + USERNAME + '/'
####F = FileUploadRequest(uri, 'photobucket.com', 80)
####F.loadfield('action' , 'deletepic')
####F.loadfield('pic', filename)
####F.loadfield('myurl' , 'http://img.photobucket.com/albums/' + VOLUME + '/' + USERNAME + '/' + filename)
####F.request(cookie)
action = sys.argv<1>
if action == '-d':
####cookie = LoginToPhotobucket()
####for filename in sys.argv<2:>:
########DeleteFileFromPhotobucket(filename, cookie)
elif action == '-u':
####files = []
####for spec in sys.argv<2:>:
########for file in glob.glob(spec):
############if os.path.isfile(file):
################files.append(file)
####cookie = LoginToPhotobucket()
####for file in files:
########UploadFileToPhotobucket(file, cookie)