How to use the pyicloud.exceptions.PyiCloudBinaryFeedParseError function in pyicloud

To help you get started, we’ve selected a few pyicloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nficano / alexa-find-my-iphone / src / site-packages / pyicloud / services / photos.py View on Github external
def _parse_binary_feed(self, feed):
        binaryfeed = bytearray(b64decode(feed))
        bitstream = ConstBitStream(binaryfeed)

        payload_encoding = binaryfeed[0]
        if payload_encoding != bitstream.read("uint:8"):
            raise PyiCloudBinaryFeedParseError(
                "Missmatch betweeen binaryfeed and bistream payload encoding")

        ASSET_PAYLOAD = 255
        ASSET_WITH_ORIENTATION_PAYLOAD = 254
        ASPECT_RATIOS = [
            0.75,
            4.0 / 3.0 - 3.0 * (4.0 / 3.0 - 1.0) / 4.0,
            4.0 / 3.0 - 2.0 * (4.0 / 3.0 - 1.0) / 4.0,
            1.25,
            4.0 / 3.0, 1.5 - 2.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5 - 1.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5,
            1.5694444444444444,
            1.6388888888888888,
            1.7083333333333333,
            16.0 / 9.0,
github nficano / alexa-find-my-iphone / src / site-packages / pyicloud / services / photos.py View on Github external
4.0 / 3.0, 1.5 - 2.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5 - 1.0 * (1.5 - 4.0 / 3.0) / 3.0,
            1.5,
            1.5694444444444444,
            1.6388888888888888,
            1.7083333333333333,
            16.0 / 9.0,
            2.0 - 2.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2.0 - 1.0 * (2.0 - 16.0 / 9.0) / 3.0,
            2,
            3
        ]

        valid_payloads = [ASSET_PAYLOAD, ASSET_WITH_ORIENTATION_PAYLOAD]
        if payload_encoding not in valid_payloads:
            raise PyiCloudBinaryFeedParseError(
                "Unknown payload encoding '%s'" % payload_encoding)

        assets = {}
        while len(bitstream) - bitstream.pos >= 48:
            range_start = bitstream.read("uint:24")
            range_length = bitstream.read("uint:24")
            range_end = range_start + range_length

            previous_asset_id = 0
            for index in range(range_start, range_end):
                aspect_ratio = ASPECT_RATIOS[bitstream.read("uint:4")]

                id_size = bitstream.read("uint:2")
                if id_size:
                    # A size has been reserved for the asset id
                    asset_id = bitstream.read("uint:%s" % (2 + 8 * id_size))
github nficano / alexa-find-my-iphone / src / site-packages / pyicloud / services / photos.py View on Github external
def photos(self):
        if not self._photo_assets:
            child_assets = self.data.get('childAssetsBinaryFeed')
            if not child_assets:
                raise PyiCloudBinaryFeedParseError(
                    "Missing childAssetsBinaryFeed in photo album")
            self._photo_assets = self._parse_binary_feed(child_assets)

        return self._photo_assets