def load(self, days=PRELOAD_DAYS, only_cameras=None,
             date_from=None, date_to=None, limit=None):
        """Load  Arlo videos from the given criteria

        :param days: number of days to retrieve
        :param only_cameras: retrieve only <ArloCamera> on that list
        :param date_from: refine from initial date
        :param date_to: refine final date
        :param limit: define number of objects to return
        """
        videos = []
        url = LIBRARY_ENDPOINT
        if not (date_from and date_to):
            now = datetime.today()
            date_from = (now - timedelta(days=days)).strftime('%Y%m%d')
            date_to = now.strftime('%Y%m%d')

        params = {'dateFrom': date_from, 'dateTo': date_to}
        data = self._session.query(url,
                                   method='POST',
                                   extra_params=params).get('data')

        # get all cameras to append to create ArloVideo object
        all_cameras = self._session.cameras

        for video in data:
            # pylint: disable=cell-var-from-loop
            srccam = \
                list(filter(
                    lambda cam: cam.device_id == video.get('deviceId'),
                    all_cameras)
                    )[0]

            # make sure only_cameras is a list
            if only_cameras and \
               not isinstance(only_cameras, list):
                only_cameras = [(only_cameras)]

            # filter by camera only
            if only_cameras:
                if list(filter(lambda cam: cam.device_id == srccam.device_id,
                               list(only_cameras))):
                    videos.append(ArloVideo(video, srccam, self._session))
            else:
                videos.append(ArloVideo(video, srccam, self._session))

        if limit:
            return videos[:limit]

        return videos
def load ( self , days = PRELOAD_DAYS , only_cameras = None , date_from = None , date_to = None , limit = None ) : videos = [ ] url = LIBRARY_ENDPOINT if not ( date_from and date_to ) : now = datetime . today ( ) date_from = ( now - timedelta ( days = days ) ) . strftime ( '%Y%m%d' ) date_to = now . strftime ( '%Y%m%d' ) params = { 'dateFrom' : date_from , 'dateTo' : date_to } data = self . _session . query ( url , method = 'POST' , extra_params = params ) . get ( 'data' ) all_cameras = self . _session . cameras for video in data : srccam = list ( filter ( lambda cam : cam . device_id == video . get ( 'deviceId' ) , all_cameras ) ) [ 0 ] if only_cameras and not isinstance ( only_cameras , list ) : only_cameras = [ ( only_cameras ) ] if only_cameras : if list ( filter ( lambda cam : cam . device_id == srccam . device_id , list ( only_cameras ) ) ) : videos . append ( ArloVideo ( video , srccam , self . _session ) ) else : videos . append ( ArloVideo ( video , srccam , self . _session ) ) if limit : return videos [ : limit ] return videos
Load  Arlo videos from the given criteria

        :param days: number of days to retrieve
        :param only_cameras: retrieve only <ArloCamera> on that list
        :param date_from: refine from initial date
        :param date_to: refine final date
        :param limit: define number of objects to return