# import time
# start = time.time()
# import logging
# import os, glob, sys, random
# from importlib import reload
# reload(logging)
# import coloredlogs
# import concurrent.futures
# from functions import *
# #from handling_json_file import *
# import json
# import cv2
# from datetime import datetime, timedelta
# #from moviepy.editor import VideoFileClip
# import telegram
# import asyncio
# from telegram import Bot
# # import tracemalloc

# # # Enable tracemalloc
# # tracemalloc.start()

# #def with_ffprobe(filename):
# with open('latest_5_ts.json') as f: #the latest 5 ts in the live
#     data = json.load(f)

# filename="2m/2m_hls/index202306131686612736.ts"
# result = subprocess.check_output(
#         f'ffprobe -v quiet -show_streams -select_streams v:0 -of json "{filename}"',
#         shell=True).decode()
# print(json.loads(result))
# fields = json.loads(result)['streams'][0]



# #return float(fields['duration'])
# # with open('latest_5_ts.json') as f: #the latest 5 ts in the live
# #     data = json.load(f)
# #with_ffprobe(data["ts_4"])
# # segment = "test.ts" #str(sys.argv[1])

# # #if os.path.isfile(table_name+"_test/2m_hls/"+segment) and ".ts" in segment and segment !=all_names['names'] and '@' not in segment and 'jingle' not in segment:

# #     #if level2['end']<current_time and data_stat['situation']

# # print("segment => "+segment)
# # #clip = VideoFileClip("2m/2m_hls/"+segment)
# # duration = with_ffprobe("2m_test/2m_hls/"+segment)
# # # duration = 6
# # print('the duration is :',duration)
# # ts = time.time()
# # ts = "."+str(ts).split('.')[0]
# # now = str(segment).split('.')[0]

# # home = os.path.expanduser("~")
# # ffmpeg = 'ffmpeg'
# # cwd = os.getcwd()

# # # video = 25 frame par second

# # cmd ="ffmpeg -y -i 2m_test/2m_hls/"+segment+" -vf 'select=gt(scene\,0.10)' -vsync vfr -frame_pts true 2m_test/iframe_live/"+now+"_%d_"+str(duration)+".png"
# # #cmd = "ffmpeg -y -i 2m_hls/"+segment+" -vf 'select=gt(scene\,0.10)' -vsync vfr -frame_pts true iframes_live/"+now+str(ts)+"_%d_"+str(duration)+".png"
# # # cmd = "ffmpeg -y -i 2m_hls/"+segment+" -vf \"select='eq(pict_type,PICT_TYPE_I)'\" -vsync vfr -frame_pts true iframes_live/"+now+str(ts)+"_%d_"+str(duration)+".png"
# # print(cmd)
# # # python3 iframe_scanner.py $file
# # os.system(cmd)
# # #send("from server 2 there is similarity between "+"test"+" and "+"test" +" with results = "+str(0),"-1001778433367", token=my_token)
# # print('done §')


import requests
import json

with open("state_ts_video.json", "r+") as jsonFile7: #insert all changed ts videos
    state_video = json.load(jsonFile7)


values_list = list(state_video.values())

# Get the last two values from the list
latest_values = values_list[-2:]

print('the values are :',latest_values)
# Check if the two latest values are similar
if latest_values[0] == latest_values[1]:
    print('similar')
    
else:
    print('are not')
    message=" are NOT similar"
    base_url = 'https://api.telegram.org/bot5522894419:AAE9CeONlV2lfmUGqbXGZAHC-l1Z90TMuD4/sendMessage?chat_id=-1001778433367&text="{}"'.format(message)
    requests.get(base_url)