OBS Crashes when loading Python script.

maxhewe

New Member
I just wrote a simple Code for an RSS feed. But when I select the Script location in OBS and load the script OBS crashes. (I can still see the script working in the background, but I can't do anything anymore)

1614628179948.png


this is my Code:

Python:
import obspython as obs
import feedparser
from bs4 import BeautifulSoup
import time

# ----------
# Script Einstellungen anfang
# ----------

textfeld_schlagzeile = "Testo"
textfeld_info        = "Testu"
URL                  = "https://www.tagesschau.de/xml/rss2/"

# ----------
# Script Einstellungen ende
# ----------


while True:
    NewsFeed = feedparser.parse(URL)
    print("Number of RSS posts :", len(NewsFeed.entries))
    rssnumber = len(NewsFeed.entries)
    i = 0
    while i < rssnumber:
        entry = NewsFeed.entries[i]

        source = obs.obs_get_source_by_name(textfeld_schlagzeile)
        text = entry.title
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)

        source = obs.obs_get_source_by_name(textfeld_info)
        text = entry.description
        settings = obs.obs_data_create()
        obs.obs_data_set_string(settings, "text", text)
        obs.obs_source_update(source, settings)
        obs.obs_data_release(settings)

        Imagesearch = NewsFeed.entries[i].content
        soup = BeautifulSoup(Imagesearch[0]['value'], features="html.parser")
        link = soup.find("img")["src"]

        i = i + 1
        time.sleep(10)

def script_description():
    return "änderungen an den einstellungen können im gekenzeichneten bereich im Code vorgenommen werden."

This is my Log file after restarting the program: https://obsproject.com/logs/nfR0voMExYxZUdNS

I hope you can help me with that.
 

maxhewe

New Member
Could it be something like the program wanting to finish the Script until it responds again or something like that? Because it's a loop and that would be pretty bad.

Edit: it's actually the time.sleep thing that's causing trouble. You can't use the program while its working.
 
Last edited:
Top