Beispiel #1
0
def upcomingupdate(schedulelist):
    # updates the schedule text
    #? This might be slightly faster as a while loop seeing as all the math is already being done on 'i.'
    i = 1
    playlist = """"""
    for title in schedulelist:
        titlestring = ""
        namestring = ""
        numstring = ""
        artiststring = ""

        if title["title"]:
            if config['upcoming']['number'] == "yes":
                numstring = str(i) + config['upcoming']['afternumber'].strip(
                    '"')

            titlestring = numstring + updatercore("upcoming", title) + '\n'
            playlist += titlestring
        else:
            pass

        i += 1

        if i > int(config['upcoming']['count']):
            obsinstance.call(
                requests.SetTextGDIPlusProperties("upnext", text=playlist))
            return console.log(Panel.fit(playlist, title="Up Next"))

        #console.log("Updated Up Next item " + str(i))
    pass
Beispiel #2
0
def nowplayingupdate(title: dict):
    """
    updates the now playing text
    """

    nowplayingstring = updatercore("nowplaying", title)

    obsinstance.call(
        requests.SetTextGDIPlusProperties("nowplaying", text=nowplayingstring))

    return console.log(Panel.fit(nowplayingstring, title="Now Playing"))

    pass
Beispiel #3
0
playing_now = ""
client = obsws("localhost", 4444, "ThisIsVerySecret")

while True:
    sp_oauth = spotipy.SpotifyOAuth(scope=scope,username=username)

    if sp_oauth:
        sp = spotipy.Spotify(oauth_manager=sp_oauth)
        client.connect()
        for i in range (0, 359):
            results = sp.currently_playing()
            if results == None or results['item'] == None or results['is_playing'] == False:
                if playing_now != "":
                    playing_now = ""
                    client.call(requests.SetTextGDIPlusProperties('WhatsPlaying', text=playing_now))
                    print("Paused or nothing's playing on Spotify.", flush=True)
            else:
                artists = []
                for artist in results['item']['artists']:
                    artists.append(artist['name'])
                title = str(results['item']['name'])
                artist_list = ", ".join(artists)
                playing = artist_list + " - " + title
                print(playing, flush=True)
                if playing_now != playing:
                    playing_now = playing
                    client.call(requests.SetTextGDIPlusProperties('WhatsPlaying', text=playing))
            time.sleep(5)
    else:
        print("Can't get token for ", username)
Beispiel #4
0
#Send data to OBS
def sendpacket(packet):
    ws.send(packet)


if __name__ == '__main__':
    with open(list_txt1) as f:
        lines = f.readlines()
        selection_1 = (random.choice(lines))

    with open(list_txt2) as f:
        lines = f.readlines()
        selection_2 = (random.choice(lines))

    with open(list_txt3) as f:
        lines = f.readlines()
        selection_3 = (random.choice(lines))

    with open(list_txt4) as f:
        lines = f.readlines()
        selection_4 = (random.choice(lines))

    txt_result = (selection_1.rstrip() + " " + selection_2.rstrip() + " " +
                  selection_3.rstrip() + " " + selection_4.rstrip())

    ws.call(
        requests.SetTextGDIPlusProperties(source=source_txt, text=txt_result))
    ws.disconnect()
    exit()
Beispiel #5
0
        log.info(f"Update!")
       
if __name__ == '__main__':
    path = "."
    event_handler = MyEventHandler(patterns=['*duration.txt'])

    observer = Observer()
    observer.schedule(event_handler, path, recursive=True)
    observer.start()
    log.info("Started Watchdog")

    t = int(config['debug']['launchtime']) # initial countdown value used until song update
    log.info("t initialized as " + str(t))

    try:
        starttime = time.time()
        while True:
            if t > 0:
                obsinstance.call(requests.SetTextGDIPlusProperties("countdown", text=str(datetime.timedelta(seconds=int(t)))))
                console.log(str(datetime.timedelta(seconds=int(t))), highlight=False)
                t -= 1
            else:
                obsinstance.call(requests.SetTextGDIPlusProperties("countdown", text="0:00:00"))
                log.error("DEAD AIR!")
            time.sleep(1.0 - ((time.time() - starttime) % 1.0)) # sync to system clock
            
    except KeyboardInterrupt:
        observer.stop()
        console.log(obsinstance.call(requests.SetTextGDIPlusProperties("countdown", text="")))
    observer.join()