def download_images(image_urls):
    """Use wget to download new images into a specified directory."""
    fetched = []
    count = 0
    for img_url in image_urls:
        if not db.is_image_in_db(img_url):
            filename = os.path.basename(img_url)
            if not os.path.exists(cfg.PHOTO_DIR + filename):
                cmd = "wget {0} -O {1}".format(img_url, os.path.join(cfg.PHOTO_DIR, filename))
                os.system(cmd)
                fetched.append(img_url)
                count += 1
        else:
            print ("# {0} was already fetched once...".format(img_url))

    print ("# new imgage(s): {0}".format(count))
    return fetched
def download_images(image_urls):
    """Use wget to download new images into a specified directory."""
    fetched = []
    count = 0
    for img_url in image_urls:
        if not db.is_image_in_db(img_url):
            filename = os.path.basename(img_url)
            if not os.path.exists(cfg.PHOTO_DIR + filename):
                referer_string = web.get_referrer_string(img_url)  # to trick 4walled.org
                cmd = "wget {ref} {url} -O {save}".format(url=img_url, save=os.path.join(cfg.PHOTO_DIR, filename), ref=referer_string)
                print cmd
                os.system(cmd)
                fetched.append(img_url)
                count += 1
        else:
            print("# {0} was already fetched once...".format(img_url))

    print("# new imgage(s): {0}".format(count))
    return fetched
def download_images(image_urls):
    """Use wget to download new images into a specified directory."""
    fetched = []
    count = 0
    for img_url in image_urls:
        if not db.is_image_in_db(img_url):
            filename = os.path.basename(img_url)
            if not os.path.exists(cfg.PHOTO_DIR + filename):
                referer_string = web.get_referrer_string(
                    img_url)  # to trick 4walled.org
                cmd = "wget {ref} {url} -O {save}".format(url=img_url,
                                                          save=os.path.join(
                                                              cfg.PHOTO_DIR,
                                                              filename),
                                                          ref=referer_string)
                print cmd
                os.system(cmd)
                fetched.append(img_url)
                count += 1
        else:
            print("# {0} was already fetched once...".format(img_url))

    print("# new imgage(s): {0}".format(count))
    return fetched