def html(): s = smug.Smug(smug.userCredentials()) albums = [x for x in s.getAlbums() if x.Category['Name'] != 'fnalbum' and x.Public == True] albums.sort() cat = None print '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Fnalbum</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head> <body> <h1>Fnalbum</h1> ''' for a in albums: if cat != a.Category['Name']: if cat is not None: print '</ul>' cat = a.Category['Name'] print '<h2>%s</h2><ul>' % (cat) print ('''<li><a href="%(url)s">%(name)s</a></li>''' % ({'url': a.getUrl(), 'name': a.Title})).encode('utf-8') if cat is not None: print '</ul>' print '''</body></html>'''
def diffAlbum(a, b): s = smug.Smug(smug.userCredentials()) a = s.getAlbum(a) b = s.getAlbum(b) print "%12s %30s %30s" % ('', 'Left', 'Right') print "-" * 79 for k in list(set(a.data.keys() + b.data.keys())): if a.data.has_key(k) and not b.data.has_key(k): print "a> ", k elif not a.data.has_key(k) and b.data.has_key(k): print "b> ", k elif a.data[k] != b.data[k]: print "%-12s %30s %30s" % (k, a.data[k], b.data[k])
def diffAlbum(a, b): s = smug.Smug(smug.userCredentials()) a = s.getAlbum(a) b = s.getAlbum(b) print "%12s %30s %30s" % ('', 'Left', 'Right') print "-" * 79 for k in list(set(a.data.keys() + b.data.keys())): if a.data.has_key(k) and not b.data.has_key(k): print "a> ",k elif not a.data.has_key(k) and b.data.has_key(k): print "b> ",k elif a.data[k] != b.data[k]: print "%-12s %30s %30s" % (k,a.data[k],b.data[k])
def kwRename(match, to): """kwRename(match, to) Rename all keywords matching regex 'match' to 'to'. If 'to' is empty, just remove all keywords matching 'match'. """ s = smug.Smug(smug.userCredentials()) n = 0 n2 = 0 albumn = 0 changedn = 0 for album in s.getAlbums(): albumn += 1 for image in album.getImages(): n += 1 n2 += 1 old = image.getKeywords() new = [] for k in old: k = re.sub(match, to, k) if len(k) and (not k in new): new.append(k) if verbose: s = "Album: %d, Image %d (%d total), Changed: %d" %(albumn, n, n2, changedn) sys.stdout.write("\r%-79s" % (s)) sys.stdout.write("\r%s" % (s)) sys.stdout.flush() if old != new: changedn += 1 if verbose > 1: print dir(image) sys.exit(1) if really: image.changeKeywords(new) else: print "Would change %s/%s from %s to %s" % (album.Title, image.Caption, old, new)
def main(parser, parms): parser.add_option("--raw", dest="raw", action="store_true", help="raw mode", default=False) (options, args) = parser.parse_args(parms) s = smoog.Smug(smoog.userCredentials(), options) where = {} for t in args[2:]: print t k,v = t.split('=',1) if v == 'True': v = True if v == 'False': v = False where[k] = v {'album': list_album, 'image': list_image}[args[1]](s, where=where, raw=options.raw)
def albumCopySettings(src, dst): s = smug.Smug(smug.userCredentials()) src = s.getAlbum(src) dst = s.getAlbum(dst) d = {} for k in src.data.keys(): if k in ('Title', 'id', 'Key', 'Position', 'LastUpdated', 'ImageCount', 'NiceName'): continue if src.data[k] != dst.data[k]: t = src.data[k] if t is False: t = "0" if t is True: t = "1" d[str(k)] = t if True: print "Setting:" for k in d.keys(): print "\t%-12s %20s" % (k, d[k]) dst.changeSettings(**d)
def kwRename(match, to): """kwRename(match, to) Rename all keywords matching regex 'match' to 'to'. If 'to' is empty, just remove all keywords matching 'match'. """ s = smug.Smug(smug.userCredentials()) n = 0 n2 = 0 albumn = 0 changedn = 0 for album in s.getAlbums(): albumn += 1 for image in album.getImages(): n += 1 n2 += 1 old = image.getKeywords() new = [] for k in old: k = re.sub(match, to, k) if len(k) and (not k in new): new.append(k) if verbose: s = "Album: %d, Image %d (%d total), Changed: %d" % ( albumn, n, n2, changedn) sys.stdout.write("\r%-79s" % (s)) sys.stdout.write("\r%s" % (s)) sys.stdout.flush() if old != new: changedn += 1 if verbose > 1: print dir(image) sys.exit(1) if really: image.changeKeywords(new) else: print "Would change %s/%s from %s to %s" % ( album.Title, image.Caption, old, new)
def main(parser, parms): parser.add_option("--raw", dest="raw", action="store_true", help="raw mode", default=False) (options, args) = parser.parse_args(parms) s = smoog.Smug(smoog.userCredentials(), options) where = {} for t in args[2:]: print t k, v = t.split('=', 1) if v == 'True': v = True if v == 'False': v = False where[k] = v { 'album': list_album, 'image': list_image }[args[1]](s, where=where, raw=options.raw)
def albumSettings(**kw): s = smug.Smug(smug.userCredentials()) for album in s.getAlbums(): print "Modifying", album.Title album.changeSettings(**kw)
def main(parser, parms): (options, args) = parser.parse_args(parms) s = smoog.Smug(smoog.userCredentials(), options) {'album': show_album}[parms[1]](s,parms[2])
def main(parser, parms): (options, args) = parser.parse_args(parms) s = smoog.Smug(smoog.userCredentials(), options) {'album': show_album}[parms[1]](s, parms[2])