Add basic logging to PhotosService

This commit is contained in:
Tor Arne Vestbø 2016-07-07 00:16:45 +02:00
parent 3b57397795
commit 1e53077ab9

View file

@ -1,5 +1,6 @@
import sys
import json
import logging
from datetime import datetime
from base64 import b64decode
@ -13,6 +14,8 @@ from pyicloud.exceptions import (
from future.moves.urllib.parse import unquote
from future.utils import listvalues, listitems
logger = logging.getLogger(__name__)
class PhotosService(object):
""" The 'Photos' iCloud service."""
@ -66,6 +69,7 @@ class PhotosService(object):
return self.albums['All Photos']
def _fetch_asset_data_for(self, client_ids):
logger.debug("Fetching data for client IDs %s", client_ids)
client_ids = [cid for cid in client_ids
if cid not in self._photo_assets]
@ -131,6 +135,8 @@ class PhotoAlbum(object):
return self._photo_assets
def _parse_binary_feed(self, feed):
logger.debug("Parsing binary feed %s", feed)
binaryfeed = bytearray(b64decode(feed))
bitstream = ConstBitStream(binaryfeed)
@ -170,6 +176,9 @@ class PhotoAlbum(object):
range_length = bitstream.read("uint:24")
range_end = range_start + range_length
logger.debug("Decoding indexes [%s-%s) (length %s)",
range_start, range_end, range_length)
previous_asset_id = 0
for index in range(range_start, range_end):
aspect_ratio = ASPECT_RATIOS[bitstream.read("uint:4")]