Files
OpenParty/core/scripts/generateSongdb.py

127 lines
8.6 KiB
Python
Raw Normal View History

2024-06-15 19:57:02 +08:00
import json
def generate_beats(bpm):
# Calculate time per beat
time_per_beat = 60000 / bpm
# Generate an array of beats for 30 seconds
beats_array = [time_per_beat * i for i in range(int(30 * 1000 / time_per_beat))]
# Multiply each beat by 48
final_array = [round(beat * 48) for beat in beats_array]
return json.dumps(final_array, separators=(',', ':'))
codename = input('Codename: ')
songtitle = input('Song Title: ')
songartist = input('Song Artist: ')
mapLength = input('mapLength: ')
coachcount = input('coachCount: ')
difficulty = input('difficulty: ')
originalJDVersion = input('originalJDVersion: ')
lyricsScolor = input('lyricsScolor: ')
customTypeName = input('customTypeName: ')
bpm = int(input('BPM (for preview): '))
if int(coachcount) == 1:
common = '''"map_bkgImageUrl": "",
"banner_bkgImageUrl": "",
"coach1ImageUrl": "",
"phoneCoach1ImageUrl": "",
"coverImageUrl": "",
"cover_smallImageUrl": "",
"expandCoachImageUrl": "",
"phoneCoverImageUrl": ""'''
if int(coachcount) == 2:
common = '''"map_bkgImageUrl": "",
"banner_bkgImageUrl": "",
"coach1ImageUrl": "",
"phoneCoach1ImageUrl": "",
"coach2ImageUrl": "",
"phoneCoach2ImageUrl": "",
"coverImageUrl": "",
"cover_smallImageUrl": "",
"expandCoachImageUrl": "",
"phoneCoverImageUrl": ""'''
if int(coachcount) == 3:
common = '''"map_bkgImageUrl": "",
"banner_bkgImageUrl": "",
"coach1ImageUrl": "",
"phoneCoach1ImageUrl": "",
"coach2ImageUrl": "",
"phoneCoach2ImageUrl": "",
"coach3ImageUrl": "",
"phoneCoach3ImageUrl": "",
"coverImageUrl": "",
"cover_smallImageUrl": "",
"expandCoachImageUrl": "",
"phoneCoverImageUrl": ""'''
if int(coachcount) == 4:
common = '''"map_bkgImageUrl": "",
"banner_bkgImageUrl": "",
"coach1ImageUrl": "",
"phoneCoach1ImageUrl": "",
"coach2ImageUrl": "",
"phoneCoach2ImageUrl": "",
"coach3ImageUrl": "",
"phoneCoach3ImageUrl": "",
"coach4ImageUrl": "",
"phoneCoach4ImageUrl": "",
"coverImageUrl": "",
"cover_smallImageUrl": "",
"expandCoachImageUrl": "",
"phoneCoverImageUrl": ""'''
songdb = '''
"''' + codename + '''": {
"artist": "''' + songartist + '''",
"assets": {
"nx": {},
"x1": {},
"common": {''' +common+'''}
},
"audioPreviewData": "{\\"__class\\":\\"MusicTrackData\\",\\"structure\\":{\\"__class\\":\\"MusicTrackStructure\\",\\"markers\\":''' + generate_beats(bpm) +''',\\"signatures\\":[{\\"__class\\":\\"MusicSignature\\",\\"marker\\":0,\\"beats\\":4}],\\"startBeat\\":0,\\"endBeat\\":60,\\"fadeStartBeat\\":0,\\"useFadeStartBeat\\":false,\\"fadeEndBeat\\":0,\\"useFadeEndBeat\\":false,\\"videoStartTime\\":0,\\"previewEntry\\":0,\\"previewLoopStart\\":0,\\"previewLoopEnd\\":65,\\"volume\\":0,\\"fadeInDuration\\":0,\\"fadeInType\\":0,\\"fadeOutDuration\\":0,\\"fadeOutType\\":0},\\"path\\":\\"\\",\\"url\\":\\"jmcs://jd-contents/''' + codename + '''/''' + codename + '''_AudioPreview.ogg\\"}",
"coachCount": ''' + coachcount + ''',
"credits": "All Credits Goes to ''' + songartist +'''. Placeholder Credits, Generated By Automodder",
"difficulty": ''' + difficulty +''',
"doubleScoringType": -1,
"jdmAttributes": {},
"lyricsColor": "'''+lyricsScolor+'''",
"lyricsType": 0,
"mainCoach": -1,
"mapLength": ''' + mapLength + ''',
"mapName": "''' + codename + '''",
"mapPreviewMpd": {
"videoEncoding": {
"vp8": "<?xml version=\\"1.0\\"?>\\r\\n<MPD xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\" xmlns=\\"urn:mpeg:DASH:schema:MPD:2011\\" xsi:schemaLocation=\\"urn:mpeg:DASH:schema:MPD:2011\\" type=\\"static\\" mediaPresentationDuration=\\"PT30S\\" minBufferTime=\\"PT1S\\" profiles=\\"urn:webm:dash:profile:webm-on-demand:2012\\">\\r\\n\\t<Period id=\\"0\\" start=\\"PT0S\\" duration=\\"PT30S\\">\\r\\n\\t\\t<AdaptationSet id=\\"0\\" mimeType=\\"video/webm\\" codecs=\\"vp8\\" lang=\\"eng\\" maxWidth=\\"720\\" maxHeight=\\"370\\" subsegmentAlignment=\\"true\\" subsegmentStartsWithSAP=\\"1\\" bitstreamSwitching=\\"true\\">\\r\\n\\t\\t\\t<Representation id=\\"0\\" bandwidth=\\"494704\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_LOW.vp8.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"638-1127\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-638\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"1\\" bandwidth=\\"1473607\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_MID.vp8.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"2\\" bandwidth=\\"2452716\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_HIGH.vp8.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"3\\" bandwidth=\\"2503315\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_ULTRA.vp8.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t</AdaptationSet>\\r\\n\\t</Period>\\r\\n</MPD>\\r\\n",
"vp9": "<?xml version=\\"1.0\\"?>\\r\\n<MPD xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\" xmlns=\\"urn:mpeg:DASH:schema:MPD:2011\\" xsi:schemaLocation=\\"urn:mpeg:DASH:schema:MPD:2011\\" type=\\"static\\" mediaPresentationDuration=\\"PT30S\\" minBufferTime=\\"PT1S\\" profiles=\\"urn:webm:dash:profile:webm-on-demand:2012\\">\\r\\n\\t<Period id=\\"0\\" start=\\"PT0S\\" duration=\\"PT30S\\">\\r\\n\\t\\t<AdaptationSet id=\\"0\\" mimeType=\\"video/webm\\" codecs=\\"vp9\\" lang=\\"eng\\" maxWidth=\\"720\\" maxHeight=\\"370\\" subsegmentAlignment=\\"true\\" subsegmentStartsWithSAP=\\"1\\" bitstreamSwitching=\\"true\\">\\r\\n\\t\\t\\t<Representation id=\\"0\\" bandwidth=\\"649637\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_LOW.vp9.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"1\\" bandwidth=\\"1494556\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_MID.vp9.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"2\\" bandwidth=\\"2985169\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_HIGH.vp9.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1129\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t\\t<Representation id=\\"3\\" bandwidth=\\"5932441\\">\\r\\n\\t\\t\\t\\t<BaseURL>jmcs://jd-contents/''' + codename + '''/''' + codename + '''_MapPreviewNoSoundCrop_ULTRA.vp9.webm</BaseURL>\\r\\n\\t\\t\\t\\t<SegmentBase indexRange=\\"639-1136\\">\\r\\n\\t\\t\\t\\t\\t<Initialization range=\\"0-639\\" />\\r\\n\\t\\t\\t\\t</SegmentBase>\\r\\n\\t\\t\\t</Representation>\\r\\n\\t\\t</AdaptationSet>\\r\\n\\t</Period>\\r\\n</MPD>\\r\\n"
}
},
"mode": 6,
"originalJDVersion": ''' + originalJDVersion + ''',
"packages": {
"mapContent": "''' + codename + '''_mapContent"
},
"parentMapName": "''' + codename + '''",
"skuIds": {},
"songColors": {
"songColor_1A": "444444FF",
"songColor_1B": "111111FF",
"songColor_2A": "AAAAAAFF",
"songColor_2B": "777777FF"
},
"status": 3,
"sweatDifficulty": 1,
"tags": [
"Main",
"subscribedSong"
],
"title": "''' + songtitle + '''",
"urls": {
"jmcs://jd-contents/''' + codename + '''/''' + codename + '''_AudioPreview.ogg": ""
},
"customTypeName": "''' + customTypeName + '''",
"serverChangelist": 696566
}
'''
print(songdb)
input('\n\nPress enter: ')