small bug fix

This commit is contained in:
cyberboy666 2024-06-13 16:21:06 +10:00
parent cd2fb7a452
commit e71c97bdca
2 changed files with 10 additions and 12 deletions

View file

@ -15,7 +15,16 @@ _NOTE: This project was quickly put together to explore diy automated broadcasti
### how to run ### how to run
- install python3 on your computer (i think you may need 3.9 or higher ?) - install python3 on your computer (i think you may need 3.9 or higher ?)
- clone this repo `git clone git@github.com:cyberboy666/obs_scheduler.git` and then `cd obs_scheduler` into the folder - clone this repo `git clone https://github.com/cyberboy666/obs_scheduler.git` and then `cd obs_scheduler` into the folder
### if you want to install virtual envirnment:
```
sudo apt-get install python3-venv
python3 -m venv venv
source venv/bin/activate
```
- install dependancies: `pip3 install -r requirements.txt` - install dependancies: `pip3 install -r requirements.txt`
- open OBS and enable web-sockets (tools -> websocket server settings -> enable websocket server) and set `port:4444` and password `your_password` - or update `obs_scheduler.py` with port/password used here - open OBS and enable web-sockets (tools -> websocket server settings -> enable websocket server) and set `port:4444` and password `your_password` - or update `obs_scheduler.py` with port/password used here
- run the program: `python3 obs_scheduler.py ` - run the program: `python3 obs_scheduler.py `

View file

@ -38,16 +38,6 @@ def parse_playlist(playlist_path):
run_time = run_time + segment.duration run_time = run_time + segment.duration
return videos return videos
def generate_schedule(start_time, playlist_path):
videos = parse_playlist(playlist_path)
schedule = []
current_time = start_time
for video in videos:
end_time = current_time + timedelta(seconds=video['duration'])
schedule.append({'title': video['title'], 'start_time': current_time, 'end_time': end_time})
current_time = end_time
return schedule
def start_stream(playlist_path, stream_name): def start_stream(playlist_path, stream_name):
global stream_active, current_playlist, schedule global stream_active, current_playlist, schedule
try: try:
@ -95,7 +85,6 @@ def start_stream(playlist_path, stream_name):
logging.info("Starting stream with playlist: {}".format(playlist_path)) logging.info("Starting stream with playlist: {}".format(playlist_path))
current_playlist = playlist_path current_playlist = playlist_path
start_time = datetime.now() start_time = datetime.now()
schedule = generate_schedule(start_time,playlist_path)
cl.start_stream() cl.start_stream()
stream_active = True stream_active = True