Esempio n. 1
0
 def live_stream_url(self):
     signer = SecureLink(format='{value} {secret}')
     url = 'rtmp://{url}:{port:d}/kam/kam_sp{point}_{cam}'.format(
         url=getattr(settings, 'MEDIASERVER_URL', ''),
         port=getattr(settings, 'MEDIASERVER_RTMP_PORT', ''),
         point=self.point.spid,
         cam=self.slug,
         )
     return signer.sign_live(url)
Esempio n. 2
0
 def get(self, request, spid, slug):
     _date = self.request.QUERY_PARAMS.get('date')
     if _date:
         try:
             self.get_object(spid, slug)
             dt = timezone.datetime.strptime(_date, '%d.%m.%Y').date()
             url_args = {
                 'url': getattr(settings, 'MEDIASERVER_URL', ''),
                 'port': getattr(settings, 'MEDIASERVER_HTTP_PORT', ''),
                 'serve': '{serve}',
                 'type': '{type}',
                 'point': spid,
                 'cam': slug,
                 'date': dt,
                 'hour': '{hour}',
                 'ext': '{ext}',
             }
             urlpath = 'http://{url}:{port:d}/{serve}/{type}/kam_sp{point}_{cam}_' \
                       '{date:%d-%m-%Y}_{hour}.{ext}'.format(**url_args)
             actual_hours = self.get_archive_hours(webcam=slug, rec_date=_date)
             signer = SecureLink()
             return Response(
                 [
                     {
                         'label': '{}'.format(hr),
                         'img': signer.sign(
                             urlpath.format(serve='media', type='img', hour=hr, ext='jpg')
                         ),
                         'mp4': signer.sign(
                             urlpath.format(serve='media', type='rec', hour=hr, ext='mp4')
                         ),
                         'download': signer.sign(
                             urlpath.format(serve='download', type='rec', hour=hr, ext='mp4')
                         ),
                     }
                     for hr in ARCHIVE_HOURS if hr in actual_hours
                 ]
             )
         except ValueError:
             pass
     return Response()