Skip to content

Commit

Permalink
v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
nossebro committed Oct 30, 2021
1 parent a3c9069 commit c74d711
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.0.3 - Use SLCB randomness

* Use Parent.GetRandom for better randomness

## 0.0.2 - Random selection

* Add possibility to randomly select a mp3 file to play
Expand Down
11 changes: 3 additions & 8 deletions TwitchRewardSoundEffects_StreamlabsSystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
ScriptName = "TwitchRewardSoundEffects"
Website = "https://github.com/nossebro/TwitchRewardSoundEffects"
Creator = "nossebro"
Version = "0.0.2"
Version = "0.0.3"
Description = "Play sound effects depending on Twitch (Channel Points) Reward IDs"

#---------------------------------------
Expand Down Expand Up @@ -259,13 +259,8 @@ def LocalSocketEvent(ws, data):
fname = os.path.join(os.path.dirname(__file__), "sounds", "{0}.mp3".format(event["data"]["reward_id"]))
Logger.debug("Looking for file or folder: {0}".format(fname))
if os.path.isdir(fdir):
for x in os.listdir(fdir):
Logger.debug(x)
if x.lower().endswith(".mp3"):
Logger.debug("Yes!!!")
Logger.debug(os.path.join(fdir, x))
Logger.debug(os.path.isfile(os.path.join(fdir, x)))
fname = os.path.join(fdir, random.choice([x for x in os.listdir(fdir) if x.lower().endswith(".mp3") and os.path.isfile(os.path.join(fdir, x))]))
flist = [x for x in os.listdir(fdir) if x.lower().endswith(".mp3") and os.path.isfile(os.path.join(fdir, x))]
fname = os.path.join(fdir, flist[Parent.GetRandom(0, len(flist))])
Logger.debug("filename: {}".format(fname))
if os.path.isfile(fname):
Logger.debug("Found file: {0}".format(fname))
Expand Down

0 comments on commit c74d711

Please sign in to comment.