I have a log file, which currently stores the following information:
RTSP0 rtsp://admin:****@192.168.0.104:554/onvif1
RTSP1 rtsp://admin:****@192.168.0.104:554/onvif2
CAMERA_HASH a586c0c691aa7e3fb37d1ff318bf4d6fdb83b24b
RTSP0 rtsp://admin:****@192.168.0.104:554/onvif1
RTSP1 rtsp://admin:****@192.168.0.104:554/onvif2
CAMERA_HASH a586c0c691aa7e3fb37d1ff318bf4d6fdb83b24b
RTSP0 rtsp://admin:****@192.168.0.104:554/onvif1
RTSP1 rtsp://admin:****@192.168.0.104:554/onvif2
CAMERA_HASH a586c0c691aa7e3fb37d1ff318bf4d6fdb83b24b
Every time a camera is connected, two new RTSP streams (i.e. RTSP0 and RTSP1) and a HASH number is added to the log file. I need to extract the RTSP stream of the most recent camera connected (i.e. the recent RTSP0 stream). Is there a way to read through the file and extract only this specific stream? Currently, I am doing:
searchfile = open('/Eya/pine_onvif/logs/camera_hash.log', 'r')
search = searchfile.readlines()
stream = []
line_cont = []
streamValue = []
for i,line in enumerate(search):
   if 'RTSP0' in line:
      line_cont = line
      stream = line.split(' ')
      streamValue = stream[1]
      filename = streamValue
      print(streamValue)
searchfile.close()
But this method is yielding an output such as the following:
rtsp://admin:****@192.168.0.104:554/onvif1
rtsp://admin:****@192.168.0.104:554/onvif1
rtsp://admin:****@192.168.0.104:554/onvif1
I'm unable to retrieve only the last line of the streamValue array.