-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (28 loc) · 937 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import vlc
import pafy
import time
import random
import multiprocessing as mp
import json
import requests
import detector
VIDEO_URLS_URL = "https://raw.githubusercontent.com/Snarik/LabPeephole/main/video_urls.json"
def main():
sub_process = mp.Process(target=detector.human_detector)
sub_process.start()
while True:
video_urls= json.loads(requests.get(VIDEO_URLS_URL).text)
video = pafy.new(random.choice(video_urls))
best = video.getbest()
media = vlc.MediaPlayer(best.url)
print("created the media object: {}".format(media))
media.set_fullscreen(True)
media.play()
print("attempted to play the media: {}".format(media.get_state()))
while media.get_state() == vlc.State.Opening:
time.sleep(5)
while media.is_playing():
time.sleep(10)
media.stop()
if __name__ == "__main__":
main()