# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# LIBRARY_PATH = '/hmsweb/users/library'
# 
# PRELOAD_DAYS = 30
# 
# Path: config/hass/custom_components/aarlo/pyaarlo/util.py
# def arlotime_strftime(timestamp, date_format='%Y-%m-%dT%H:%M:%S'):
#     return arlotime_to_datetime(timestamp).strftime(date_format)
# 
# def arlotime_to_datetime(timestamp):
#     return datetime.fromtimestamp(int(timestamp / 1000))
# 
# def http_get(url, filename=None):
#     # make request
#     ret = _http_get(url)
#     if ret is None:
#         return False
# 
#     if filename is None:
#         return ret.content
# 
#     with open(filename, 'wb') as data:
#         data.write(ret.content)
#     return True
# 
# def http_stream(url, chunk=4096):
#     """Generate stream for a given record video.
# 
#     :param url: url of stream to read
#     :param chunk: chunk bytes to read per time
#     :returns generator object
#     """
#     ret = requests.get(url, stream=True)
#     ret.raise_for_status()
#     for data in ret.iter_content(chunk):
#         yield data


import threading
from datetime import datetime, timedelta
from .constant import LIBRARY_PATH, PRELOAD_DAYS
from .util import (arlotime_strftime, arlotime_to_datetime, http_get,
                   http_stream)
        return self._attrs.get('mediaDurationSecond', None)

    @property
    def triggered_by(self):
        return self._attrs.get('reason', None)

    @property
    def object_type(self):
        return self._attrs.get('objCategory', None)

    @property
    def object_region(self):
        return self._attrs.get('objRegion', None)

    @property
    def thumbnail_url(self):
        return self._attrs.get('presignedThumbnailUrl', None)

    @property
    def video_url(self):
        return self._attrs.get('presignedContentUrl', None)

    def download_thumbnail(self, filename=None):
        return http_get(self.thumbnail_url, filename)

    def download_video(self, filename=None):
        return http_get(self.video_url, filename)

    @property
    def stream_video(self):

# Path: config/hass/custom_components/aarlo/pyaarlo/constant.py
# LIBRARY_PATH = '/hmsweb/users/library'
# 
# PRELOAD_DAYS = 30
# 
# Path: config/hass/custom_components/aarlo/pyaarlo/util.py
# def arlotime_strftime(timestamp, date_format='%Y-%m-%dT%H:%M:%S'):
#     return arlotime_to_datetime(timestamp).strftime(date_format)
# 
# def arlotime_to_datetime(timestamp):
#     return datetime.fromtimestamp(int(timestamp / 1000))
# 
# def http_get(url, filename=None):
#     # make request
#     ret = _http_get(url)
#     if ret is None:
#         return False
# 
#     if filename is None:
#         return ret.content
# 
#     with open(filename, 'wb') as data:
#         data.write(ret.content)
#     return True
# 
# def http_stream(url, chunk=4096):
#     """Generate stream for a given record video.
# 
#     :param url: url of stream to read
#     :param chunk: chunk bytes to read per time
#     :returns generator object
#     """
#     ret = requests.get(url, stream=True)
#     ret.raise_for_status()
#     for data in ret.iter_content(chunk):
#         yield data


# Path: config/hass/custom_components/aarlo/pyaarlo/media.py
import threading
from datetime import datetime, timedelta
from .constant import LIBRARY_PATH, PRELOAD_DAYS
from .util import (arlotime_strftime, arlotime_to_datetime, http_get,
                   http_stream)

        return self._attrs.get('mediaDurationSecond', None)

    @property
    def triggered_by(self):
        return self._attrs.get('reason', None)

    @property
    def object_type(self):
        return self._attrs.get('objCategory', None)

    @property
    def object_region(self):
        return self._attrs.get('objRegion', None)

    @property
    def thumbnail_url(self):
        return self._attrs.get('presignedThumbnailUrl', None)

    @property
    def video_url(self):
        return self._attrs.get('presignedContentUrl', None)

    def download_thumbnail(self, filename=None):
        return http_get(self.thumbnail_url, filename)

    def download_video(self, filename=None):
        return http_get(self.video_url, filename)

    @property
    def stream_video(self):

        return http_stream(self.video_url)