Downloading someone elses images from Photobucket

pb-ripper

UPDATE: there has been an update for the tool and it is now completely automated, Refer to the post here: http://9v.lt/blog/update-photobucket-ripper/

Greetings.
Another blog post after such a long time. This time about how to download images from photobucket, not owned by you. Because if you own the images, you can download all of them in a package from the control panel and whatnot.
But what if you don’t own them? Well I guess you can open and download them one by one, but what if you have 1000+?

I was very surprised that I could not find any kind of image downloading software that would reliably do this. No Firefox add-ons or Opera Extensions…
There is this software called “Bulk image downloader” which is OK for a few images, but I had to get well over 1 thousand of them and that software was b0rking up.

After some experimenting I found a way to get all the images I wanted, and once again I was saved by the code (this time Python) :D

First things first, this method is not completely automated, so a computer illiterate blonde will have a hard time, but I will try to keep it very simple.

So my method in theory works by copying the list of images in the code provided by the slidshow that photobucket provides. This is much simpler because there are much less text to process, compared to copying raw HTML code and parsing that way.

What you first need to do is go to the album in your browser and click on “View as slideshow“, which will open an image slideshow.

Now when slideshow opens, go ahead and press “Ctlr+F3” in Opera, or “Ctrl+U” in Firefox. You can also right-click anywhere on the page (except image itself) and select “View page source” or something similar.
It will open up the HTML code, so scroll down and you will see “PB.Slideshow.data”.
Copy everything from there to the end (down to the colon) and paste it into notepad and remove “PB.Slideshow.data = [” from the beginning and “];” at the end, so that only the data is left. Save it as “images.txt”.

Ok, cool. Now to get the images, all you have to do is copy the code I produced just for this, save it where you saved the images.txt and run it.

'''
Simple script to download images from Photobucket album
http://9v.lt/blog/downloading-someone-elses-images-from-photobucket/
'''
 
import os
import re
import urllib
import time
import shutil
 
#====== global vars, change values here ======
mainFolder = 'PhotobucketGetter'
linkFile = 'images.txt'
noNameGirl = 'NoName'
#=============================================
 
print 'Creating a %s dir...' % mainFolder
try:
    os.mkdir(mainFolder)
except:
    shutil.rmtree(mainFolder)
    time.sleep(0.1)
    os.mkdir(mainFolder)
 
print 'Opening and reading "%s"...' % linkFile
linksFile = open(linkFile, 'r')
links = linksFile.read()
linksList = [i.strip() for i in re.split(',\s{2,}', links)]
 
print 'Compiling regex patterns and downloading the images...'
picUrl = re.compile('url: "(https?://[^.]+\.photobucket\.com/albums/[^/]+/[^/]+/[^/]+/[^/]+)",')
girlName = re.compile('title: "([\w\d]+)"')
 
counter = 1
for link in linksList:
    name = girlName.findall(link)
    if (len(name) == 0):
        name = noNameGirl
    else:
        name = name[0]
    if (os.path.exists(mainFolder+'/'+name) == False):
        os.mkdir(mainFolder+'/'+name)
    girlLink = picUrl.findall(link)
    girlLink = girlLink[0]
    fileName = os.path.basename(girlLink)
    print '%d. Retrieving "%s" into %s/ folder' % (counter, fileName, name)
    urllib.urlretrieve(girlLink, mainFolder+'/'+name+'/'+fileName)
    counter += 1

Leave a Reply

Your email address will not be published. Required fields are marked *