Skip to content

generate .txt file with playing song name, for OBS text source

Notifications You must be signed in to change notification settings

IBM5100o/CurrentSongText_OBS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

繼上篇→ 取得目前播放的歌曲 顯示於視窗提供直播擷取
由於我發現OBS的文字來源其實可以讀檔,而且是會即時更新的(如下)

所以就弄了一個文字版,省了產生panel的麻煩,也少一個視窗和吃的資源
code很短就直接貼了

import time
import pyautogui


def write_file(name):
    f = open("cs.txt", "w", encoding="utf-8")
    f.write(name)
    f.close()
    return


old = ""
while True:
    pot = pyautogui.getWindowsWithTitle("PotPlayer")
    if pot != []:
        now = pot[0].title
        if now != old:
            old = now
            idx = now.find(".mp3")
            if idx == -1:
                idx = now.find(".m4a")
                if idx == -1:
                    idx = now.find(".flac")
            if idx != -1:
                name = "Current Song: " + now[:idx]
                write_file(name)
    time.sleep(3)

主要邏輯跟上篇一樣,只是變成產生完文字檔就沒事了,之後就交給OBS處理
基本上只會吃20MB左右的記憶體

就這樣,沒了,8888888888

About

generate .txt file with playing song name, for OBS text source

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages