Skip to content

Commit 2c2a8b4

Browse files
authored
Merge pull request #84 from tomquirk/master
Save photo with original file extension
2 parents a8ee1eb + 36fec02 commit 2c2a8b4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

flickr_api/objects.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ def save(self, filename, size_label=None):
13021302
given size.
13031303
13041304
Arguments:
1305-
filename: target file name
1305+
filename: target file name (without extension)
13061306
13071307
size_label: The label corresponding to the photo size
13081308
@@ -1316,8 +1316,12 @@ def save(self, filename, size_label=None):
13161316
"""
13171317
if size_label is None:
13181318
size_label = self._getLargestSizeLabel()
1319-
r = urllib.request.urlopen(self.getPhotoFile(size_label))
1320-
with open(filename, 'wb') as f:
1319+
1320+
photo_file = self.getPhotoFile(size_label)
1321+
file_ext = '.' + photo_file.split('.')[-1]
1322+
r = urllib.request.urlopen(photo_file)
1323+
1324+
with open(filename + file_ext, 'wb') as f:
13211325
f.write(r.read())
13221326
f.close()
13231327

0 commit comments

Comments
 (0)