From 6d5661c1f3472c41b7a16868d5429d08ba2d4cdb Mon Sep 17 00:00:00 2001 From: sk1982 Date: Sat, 13 Apr 2024 02:29:08 -0400 Subject: [PATCH] chuni: import note counts and chart credits --- .idea/actaeon.iml | 1 + .idea/misc.xml | 7 +++ ...413060445-create-chuni-static-music-ext.js | 53 +++++++++++++++++++ ...445-create-chuni-static-music-ext-down.sql | 1 + ...60445-create-chuni-static-music-ext-up.sql | 14 +++++ scripts/importers/chuni.py | 25 +++++++++ 6 files changed, 101 insertions(+) create mode 100644 .idea/misc.xml create mode 100644 migrations/20240413060445-create-chuni-static-music-ext.js create mode 100644 migrations/sqls/20240413060445-create-chuni-static-music-ext-down.sql create mode 100644 migrations/sqls/20240413060445-create-chuni-static-music-ext-up.sql diff --git a/.idea/actaeon.iml b/.idea/actaeon.iml index 24643cc..33d2bf5 100644 --- a/.idea/actaeon.iml +++ b/.idea/actaeon.iml @@ -5,6 +5,7 @@ + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..a887707 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/migrations/20240413060445-create-chuni-static-music-ext.js b/migrations/20240413060445-create-chuni-static-music-ext.js new file mode 100644 index 0000000..e0c2ce5 --- /dev/null +++ b/migrations/20240413060445-create-chuni-static-music-ext.js @@ -0,0 +1,53 @@ +'use strict'; + +var dbm; +var type; +var seed; +var fs = require('fs'); +var path = require('path'); +var Promise; + +/** + * We receive the dbmigrate dependency from dbmigrate initially. + * This enables us to not have to rely on NODE_PATH. + */ +exports.setup = function(options, seedLink) { + dbm = options.dbmigrate; + type = dbm.dataType; + seed = seedLink; + Promise = options.Promise; +}; + +exports.up = function(db) { + var filePath = path.join(__dirname, 'sqls', '20240413060445-create-chuni-static-music-ext-up.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports.down = function(db) { + var filePath = path.join(__dirname, 'sqls', '20240413060445-create-chuni-static-music-ext-down.sql'); + return new Promise( function( resolve, reject ) { + fs.readFile(filePath, {encoding: 'utf-8'}, function(err,data){ + if (err) return reject(err); + console.log('received data: ' + data); + + resolve(data); + }); + }) + .then(function(data) { + return db.runSql(data); + }); +}; + +exports._meta = { + "version": 1 +}; diff --git a/migrations/sqls/20240413060445-create-chuni-static-music-ext-down.sql b/migrations/sqls/20240413060445-create-chuni-static-music-ext-down.sql new file mode 100644 index 0000000..6a4d875 --- /dev/null +++ b/migrations/sqls/20240413060445-create-chuni-static-music-ext-down.sql @@ -0,0 +1 @@ +DROP TABLE actaeon_chuni_static_music_ext; \ No newline at end of file diff --git a/migrations/sqls/20240413060445-create-chuni-static-music-ext-up.sql b/migrations/sqls/20240413060445-create-chuni-static-music-ext-up.sql new file mode 100644 index 0000000..d87a87c --- /dev/null +++ b/migrations/sqls/20240413060445-create-chuni-static-music-ext-up.sql @@ -0,0 +1,14 @@ +CREATE TABLE actaeon_chuni_static_music_ext ( + songId INT NOT NULL, + chartId INT NOT NULL, + + chartDesigner VARCHAR(255), + tapJudgeCount INT NOT NULL, + holdJudgeCount INT NOT NULL, + slideJudgeCount INT NOT NULL, + airJudgeCount INT NOT NULL, + flickJudgeCount INT NOT NULL, + allJudgeCount INT NOT NULL, + + PRIMARY KEY (songId, chartId) +); diff --git a/scripts/importers/chuni.py b/scripts/importers/chuni.py index 1840e4e..eb0fae6 100644 --- a/scripts/importers/chuni.py +++ b/scripts/importers/chuni.py @@ -63,11 +63,36 @@ class Chuni(Importer): self.get_xml('trophy', 'Trophy', ('./name/id', int), './name/str', ('./rareType', int), './explainText') ) + def import_charts(self): + inserts = [] + for file in chain(self.data_dir.glob(f'A000/music/*/*.c2s'), + self.opt_dir.glob(f'*/music/*/*.c2s')): + print(file) + data = {} + song, chart = map(int, file.stem.split('_')) + if song >= 8000: chart = 5 + with open(file, 'r', encoding='utf8') as f: + for line in f.readlines(): + parts = line.strip().split('\t') + if len(parts) == 2: + data[parts[0]] = parts[1] + inserts.append((song, chart, data['CREATOR'], data['T_JUDGE_TAP'], data['T_JUDGE_HLD'], data['T_JUDGE_SLD'], + data['T_JUDGE_AIR'], data['T_JUDGE_FLK'], data['T_JUDGE_ALL'])) + fields = ['songId', 'chartId', 'chartDesigner', 'tapJudgeCount', 'holdJudgeCount', 'slideJudgeCount', + 'airJudgeCount', 'flickJudgeCount', 'allJudgeCount'] + self.cur.executemany( + f'''INSERT INTO actaeon_chuni_static_music_ext({','.join(fields)}) + VALUES ({','.join(['%s'] * len(fields))}) + ON DUPLICATE KEY UPDATE {','.join(f"{f}={f}" for f in fields)}''', + inserts + ) + def do_import(self): self.import_map_icon() self.import_name_plate() self.import_system_voice() self.import_trophies() + self.import_charts() @staticmethod def register(parser):