How to get the total time and current time of a video on a web page using python-selenium

Solution for How to get the total time and current time of a video on a web page using python-selenium
is Given Below:

While writing a web automation program, I found that my program does not get the total duration of the video properly (it throws an error)

But I couldn’t find any other information to help me

So I came here for help
(I just started using this website and my English is not too good, please excuse me)

Here is part of the code

Thanks

            print("Try to find video")
            video = browser.find_element_by_tag_name("video")
            print("Find Video")
            totalTime = video.find_element_by_class_name('duration').get_attribute('textContent')
            print(totalTime)
            while True:
                currentTime = video.find_element_by_class_name('currentTime').get_attribute('textContent')
                print(currentTime)
                if currentTime == totalTime:
                    print("video end")
                    break
                print("isEnd is working!")

because you might be using a wrong selector.
Example in the youtube videos, you can easily find the youtube total video length by using the xpath //span[@class="ytp-time-duration"]