1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
def fixDateTaken(fapi, apiKey, authToken, secret, photoId):
rsp = fapi.photos_getInfo(api_key=apiKey,
auth_token=authToken,
photo_id=photoId,
secret=secret)
title = rsp.photo[0].title[0].elementText
m = re.match("(\d\d)(\d\d)(\d\d)_\d+", title)
if not m:
print "Failed to match regex on photo %s with title %s" % (photoId, title)
return
if (len(m.groups()) != 3):
print "Skipping photo %s because we couldn't parse the title" % (photoId)
return
year = 2000 + int(m.group(1))
month = m.group(2)
day = m.group(3)
dateTaken = "%s-%s-%s 00:00:00" % (year, month, day)
print "Setting date taken for %s to %s" % (photoId, dateTaken)
rsp = fapi.photos_setDates(api_key=apiKey,
auth_token=authToken,
photo_id=photoId,
secret=secret,
date_taken=dateTaken)
print rsp['stat']
|