--- a/flickr.py Sat Mar 29 08:28:24 2008 -0400
+++ b/flickr.py Sat Mar 29 09:11:51 2008 -0400
@@ -78,34 +78,39 @@
def get(self, working_path, size, force = False):
return get_photo(working_path, self.url(size), self.filename(size), force)
- def get_info(self):
+ def getInfo(self):
self.info = flickr.photos_getInfo(photo_id = self.id())
self.tags = []
try:
- self.tags = [t['raw'] for t in self.info.photo[0].tags[0].tag]
+ for t in self.info.photo[0].tags[0].tag:
+ self.tags += [(t['raw'], t['id'])]
except:
pass
def getTags(self):
- if not self.info: self.get_info()
+ if not self.info: self.getInfo()
return self.tags
+ def removeTag(self, id):
+ flickr.photos_removeTag(tag_id = id)
+ self.getInfo()
+
def addTag(self, tag):
if tag == '': return
flickr.photos_addTags(photo_id = self.id(), tags = '"%s"' % tag)
- self.tags = self.tags + [tag]
+ self.tags.append((tag,None))
- def rotate(self):
- res = flickr.photos_transform_rotate(photo_id = self.id(), degrees = 90)
+ def rotate(self, degrees = 90):
+ res = flickr.photos_transform_rotate(photo_id = self.id(), degrees = degrees)
self.update(res)
def is_public(self):
- if not self.info: self.get_info()
+ if not self.info: self.getInfo()
if self.info.photo[0].visibility[0]['ispublic'] == '1': return True
return False
def toggle_public(self):
- if not self.info: self.get_info()
+ if not self.info: self.getInfo()
if self.is_public(): set_public = '0'
else: set_public = '1'
res = flickr.photos_setPerms(photo_id = self.id(), is_public = set_public,
@@ -118,7 +123,7 @@
def update(self, res):
self.xml['secret'] = res.photoid[0]['secret']
self.xml['originalsecret'] = res.photoid[0]['originalsecret']
- self.get_info()
+ self.getInfo()
if __name__ == "__main__":
authenticate(raw_input)
--- a/mainwin.ui Sat Mar 29 08:28:24 2008 -0400
+++ b/mainwin.ui Sat Mar 29 09:11:51 2008 -0400
@@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>582</height>
+ <height>738</height>
</rect>
</property>
<property name="windowTitle" >
--- a/pyqflickr.py Sat Mar 29 08:28:24 2008 -0400
+++ b/pyqflickr.py Sat Mar 29 09:11:51 2008 -0400
@@ -42,10 +42,9 @@
self.show()
i = 0
for p in self.photos:
- print i
self.dialog.progressBar.setValue(i)
p.get(working_path, photo_size)
- p.get_info()
+ p.getInfo()
i = i + 1
QtGui.QApplication.processEvents()
if self.cancelled: break
@@ -74,7 +73,10 @@
self.photo = None
self.showSet()
elif key == QtCore.Qt.Key_R:
- self.photos[self.photo].rotate()
+ self.photos[self.photo].rotate(90)
+ self.showPhoto(force = True)
+ elif key == QtCore.Qt.Key_W:
+ self.photos[self.photo].rotate(270)
self.showPhoto(force = True)
elif key == QtCore.Qt.Key_P:
self.photos[self.photo].toggle_public()
@@ -92,24 +94,28 @@
self.ui.interfaceBrowser.setHtml(txt)
def showSet(self):
- txt = '<a href="fetchall">Pre-fetch all photos</a><br>'
+ txt = '<a href="fetchall">Pre-fetch all photos (with info)</a><br>'
i = 1
for p in self.photos:
txt = txt + '<td align="center"><a href="%i"><img src="%s"></a></td>' % \
(i-1, p.get(working_path, 's'))
- if i % 10 == 0: txt = txt + '</tr><tr>'
+ if i % 10 == 0: txt += '</tr><tr>'
i += 1
- txt = txt + '</tr></table>'
+ txt += '</tr></table>'
self.ui.interfaceBrowser.setHtml(txt)
def showPhoto(self, force = False):
photo = self.photos[self.photo]
tags = photo.getTags()
info_txt = '<b>Tags</b>:<br>'
- for t in tags:
- info_txt = info_txt + t + '<br>'
- if photo.is_public(): info_txt = info_txt + "Public"
- else: info_txt = info_txt + "Private"
+ for tag,id in tags:
+ info_txt += tag
+ if id:
+ info_txt += ('<a href="%s">X</a>' % id)
+ info_txt += '<br>'
+ info_txt = info_txt + '<br>'
+ if photo.is_public(): info_txt += "Public"
+ else: info_txt += "Private"
txt = '''<center>
<table>
@@ -143,6 +149,8 @@
self.showPhoto()
else:
self.prefetchAll()
+ else: # In photo mode
+ self.photos[self.photo].removeTag(url.toString())
def message(self, msg):
QtGui.QMessageBox.warning(None, "Warning", msg)