#   DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
#                    Version 0.2, January 2024 
#
# Copyright (C) 2024 Milan 't4c' Berger <t4c@ghcif.de>
#
# Everyone is permitted to copy and distribute verbatim or modified 
# copies of this license document, and changing it is allowed as long 
# as the name is changed. 
#
#            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 
#   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 
#
#  0. You just DO WHAT THE FUCK YOU WANT TO.
#
# 
# addtonies.py - A rudimentary Python script to simplify the adding of custom tonies.
# Script has to be in config directory of teddycloud, ex: /var/lib/docker/volumes/tc_config/_data
# this is the location of tonies.custom.json.

import json

# read tonies.custom.json 
with open("tonies.custom.json", "r") as f:
    tonies = json.load(f)

# query values
# model id is a custom string
# audio_id unixtimestamp, see webinterface
# hash see webinterface
# pic path or weburl
model = input("model id: ")
audio_id = input("audio_id: ")
hash = input("hash: ")
title = input("title: ")
series = input("series: ")
episodes = input("episode: ")
pic = input("path or URL: ")

# create a new block
tonies.append({
    "no": len(tonies),
    "model": model,
    "audio_id": audio_id,
    "hash": hash,
    "title": title,
    "series": series,
    "episodes": episodes,
    "pic": pic
})

# write file 
with open("tonies.custom.json", "w") as f:
    json.dump(tonies, f)

# print file for debugging purpose
# print(tonies)

# remember adjusting model id
print("\033[1;31;4mYou must edit your content json file located in your conten directory and adjust the model\033[0m")
print("\033[1;31;4m(Example: Tag ID 0A0B0C0D, /var/lib/docker/volumes/tc_content/_data/default/0A0B0C0D/500304E0.json)\033[0m")
