Exemple #1
0
    if 0 == len(photo_elements):
        print "nothing found for checksum %s" % digest
        sys.exit(2)
    if 1 != len(photo_elements):
        print "Expected exactly 1 result searching for tag "+search_tag+"; actually got "+str(len(photo_elements))
        print "The photos were:"
        for p in photo_elements:
            print photo_page_url(p)
        sys.exit(3)
    photo = photo_elements[0]
    if just_photo_page_url:
        print photo_page_url(photo)
    elif options.size:
        print info_to_url(photo_info,size=options.size)
    if options.short:
        print short_url(photo_id)
else:
    # Only require sqlite if we're actually adding checksum tags:
    from sqlite3 import dbapi2 as sqlite

    db_filename = os.path.join(os.environ['HOME'],'.flickr-photos-checksummed.db')
    connection = sqlite.connect(db_filename)
    cursor = connection.cursor()
    cursor.execute("""
        CREATE TABLE IF NOT EXISTS done
        (photo_id text unique, 
        sha1 text,
        md5 text)
        """)

    def already_done(photo_id):
parser = OptionParser(usage="Usage: %prog [OPTION] [FILE]...")
parser.add_option('-v',
                  '--verbose',
                  dest='verbose',
                  default=False,
                  action='store_true',
                  help='Turn on verbose output')
options, args = parser.parse_args()

flickr = authenticate_to_flickr()

for filename in args:
    md5sum = checksum(filename, "md5")
    if options.verbose:
        print "filename was: " + filename
        print " with md5sum: " + md5sum
    existing = search_for_checksum(flickr, md5=md5sum)
    if 1 == len(existing):
        if options.verbose:
            print "  ... already uploaded"
            print short_url(existing[0].attrib['id'])
    elif len(existing) > 1:
        if options.verbose:
            print "  ... multiple copies uploaded"
    else:
        if options.verbose:
            print "  ... not uploaded"
        else:
            print filename
from flickrapi.shorturl import url as short_url

all_filenames = sys.argv[1:]

parser = OptionParser(usage="Usage: %prog [OPTION] [FILE]...")
parser.add_option('-v', '--verbose', dest='verbose', default=False,
                  action='store_true',
                  help='Turn on verbose output')
options, args = parser.parse_args()

flickr = authenticate_to_flickr()

for filename in args:
    md5sum = checksum(filename, "md5")
    if options.verbose:
        print "filename was: "+filename
        print " with md5sum: "+md5sum
    existing = search_for_checksum(flickr, md5=md5sum)
    if 1 == len(existing):
        if options.verbose:
            print "  ... already uploaded"
            print short_url(existing[0].attrib['id'])
    elif len(existing) > 1:
        if options.verbose:
            print "  ... multiple copies uploaded"
    else:
        if options.verbose:
            print "  ... not uploaded"
        else:
            print filename