aboutsummaryrefslogtreecommitdiffstats
path: root/Soundboard.py
blob: 32ddfa61cec46e80f2b1a0b06f008893c47088e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Soundboard Engine - customizable soundboard
# Copyright (C) 2026  Vidhu Kant Sharma <vidhukant@vidhukant.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

import json


class Soundboard:
    def __init__(self, soundboard_path):
        self.soundboard_path = soundboard_path
        self.categories = []

    def build(self):
        data = json.load(open(self.soundboard_path))
        for _c in data["categories"]:
            c = SoundboardCategory(_c["name"], _c["image_path"])

            for _s in _c["sounds"]:
                s = SoundboardSound(_s["title"], _s["path"])
                c.sounds.append(s)

            self.categories.append(c)

        self.soundboard_name = data["soundboard_name"]
        self.soundboard_id = data["soundboard_id"]
        self.soundboard_author = data["soundboard_author"]
        self.soundboard_version = data["soundboard_version"]


class SoundboardCategory:
    def __init__(self, name, image_path):
        self.name = name
        self.image_path = image_path
        self.sounds = []


class SoundboardSound:
    def __init__(self, title, path):
        self.title = title
        self.path = path