YouTube-Viewer
YouTube-Viewer copied to clipboard
Improved way of seeing if livestream ended
Is there an existing issue for this?
- [X] I have searched the existing issues
I'm submitting a ...
- [ ] bug report
- [X] feature request
- [ ] support request --> Contact me over mail for support https://github.com/MShawon
Description
Your way of checking if a livestream is finished is by checking if the "x watching now" element exists. Not only this could make a watcher stay on forever if you are not using proxies with a english language, on some livestreams it just stops working for no reason, even when its in english.
A safer way is to check if the endscreen element is visible, and close the livestream if it is.
A way to do this in javascript is
document.querySelector(".html5-endscreen").style.display
If the result is "" (a blank string) then the livestream/video is finished (It works for videos too), and if the result is "none" then the livestream/video is still playing.
I am not sure how you could do this in python, but I guess it should not be different from now, since all you have to do is modify this part of the code:
while True:
try:
view_stat = driver.find_element(
By.CSS_SELECTOR, '#count span').text
if not view_stat:
raise WebDriverException
except WebDriverException:
view_stat = driver.find_element(
By.XPATH, '//*[@id="info"]/span[1]').text
if 'watching' in view_stat:
print(timestamp() + bcolors.OKBLUE + f"Worker {position} | " + bcolors.OKGREEN +
f"{proxy} | {output} | " + bcolors.OKCYAN + f"{view_stat} " + bcolors.ENDC)
create_html({"#3b8eea": f"Worker {position} | ",
"#23d18b": f"{proxy.split('@')[-1]} | {output} | ", "#29b2d3": f"{view_stat} "})
else:
error += 1
and change the view_stat element and the if statement.
Environment
- OS : It doesn't matter
- Python : I don't know python
- Script version : 1.8.0
config.json
not applicable
thanks! I will look into it in future releases