Skip to content

Commit

Permalink
Fix support for Python 3.6.
Browse files Browse the repository at this point in the history
  • Loading branch information
skarppi committed Sep 15, 2017
1 parent ff35bdd commit dce0bc0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions download_photos.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,15 @@ def truncate_middle(s, n):
return '{0}...{1}'.format(s[:n_1], s[-n_2:])

def filename_with_size(photo, size):
if sys.version_info[0] >= 3:
filename = photo.filename
else:
filename = photo.filename.encode('utf-8')

if size == 'original':
return photo.filename.encode('utf-8')
return filename
else:
return photo.filename.encode('utf-8') \
.decode('ascii', 'ignore').replace('.', '-%s.' % size)
return filename.decode('ascii', 'ignore').replace('.', '-%s.' % size)

def download_photo(photo, size, force_size, album, progress_bar):
# Strip any non-ascii characters.
Expand Down Expand Up @@ -241,7 +245,7 @@ def download_photo(photo, size, force_size, album, progress_bar):
if size not in photo.versions and not force_size and size != 'original':
return download_photo(photo, 'original', True, album, progress_bar)

progress_bar.set_description("Downloading %s to %s" % (truncated_filename.decode('ascii', 'ignore'), truncated_path.decode('ascii', 'ignore')))
progress_bar.set_description("Downloading %s to %s" % (truncated_filename.encode().decode('ascii', 'ignore'), truncated_path.encode().decode('ascii', 'ignore')))

for _ in range(MAX_RETRIES):
try:
Expand Down
10 changes: 7 additions & 3 deletions filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ def __init__(self, path):
def __str__(self):
return self.path

def item(self, filename):
filepath = '/'.join((self.path, filename))
if os.path.isfile(filepath):
return FileSystemPhoto(filepath, os.path.getmtime(filepath))

def create_item(self, filename, filetype, created, modified = None, filesize = None, title = None, description = None, rating = None, latitude = None, longitude = None):
filepath = '/'.join((self.path, filename))
return FileSystemPhoto(filepath, created)
Expand All @@ -51,6 +56,5 @@ def save_content(self, url):
os.utime(self.path, (self.created / 1000,self.created / 1000))

def delete(self):
if exists():
print "Deleting %s!" % self.path
os.remove(self.path)
print ("Deleting %s!" % self.path)
os.remove(self.path)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ python-dateutil
requests
tqdm>=4.5.0
git+https://github.com/chadj/pyicloud.git@ckdatabasews#egg=pyicloud
photostation>=0.1.4
photostation>=0.1.5
biplist
requests_toolbelt
2 changes: 1 addition & 1 deletion spk/INFO
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package="icloud_photo_station"
version="0.1.4"
version="0.1.5"
description="Synchronize iCloud Photos to Photo Station"

maintainer="Juho Kolehmainen"
Expand Down

0 comments on commit dce0bc0

Please sign in to comment.