Skip to content

Creates and modifies Project Arrhythmia metadata.lsb files.

License

Notifications You must be signed in to change notification settings

PA-Toolkit/pa-meta

Repository files navigation

Welcome to pa-meta 👋

Version Documentation Maintenance License: MIT

Creates and modifies Project Arrhythmia metadata.lsb files.

Install

npm install pa-meta

Usage

import { Metadata, Artist, ... } from "pa-meta";
const { Metadata, Artist, ... } = require("pa-meta");

Creating

Creating Metadata

With default values:

const metadata = new Metadata();

With specified values:

const metadata = new Metadata({
  artist: new Artist({
    /* ... */
  }),
  /* ... */
});

Creating Artist

With default values:

const artist = new Artist();

With specified values:

const artist = new Artist({
  name: "Artist name",
  link: "artistLink",
  linkType: LinkType.SoundCloud,
});

Creating Creator

With default values:

const creator = new Creator();

With specified values:

const creator = new Creator({
  steamName: "Name",
  steamId: 471736531,
});

Creating Song

With default values:

const song = new Song();

With specified values:

const song = new Song({
  title: "Song title",
  difficulty: Difficulty.Easy,
  description: "Song description",
  bpm: 120,
  /* ... */
});

Creating Beatmap

With default values:

const beatmap = new Beatmap();

With specified values:

const beatmap = new Beatmap({
  dateEdited: new Date() /* OR */ Date.now();
  gameVersion: "20.4.4",
  workshopID: -1,
  /* ... */
});

Working

NOTE: toJson() and toString() return serialized values that PA accepts (e.g. steam_name instead of steamName).

Working with Metadata

Setting values:

metadata.artist = new Artist({ ... });

Getting values:

  • As class instances
metadata.artist; // [Artist]
  • As JSON objects
metadata.artist.toJson(); // { name: "Artist name", ... }
  • As JSON strings
metadata.artist.toString(); // "{ name: "Artist name", ... }"

Working with Artist

Setting values:

artist.name = "Artist name";
artist.link = "artistLink";
artist.linkType = LinkType.SoundCloud;

Getting:

  • Normal values
artist.name; // "Artist name"
artist.link; // "artistLink"
artist.linkType; // 1
  • JSON object
artist.toJson(); // { name: "Artist name", ... }
  • JSON string
artist.toString(); // "{ name: "Artist name", ... }"

Working with Creator

Setting values:

creator.steamName = "Name";
creator.steamId = 0;

Getting:

  • Normal values
creator.steamName; // "Name"
creator.steamId; // 0
  • JSON object
creator.toJson(); // { steam_name: "Name", ... }
  • JSON string
creator.toString(); // "{ steam_name: "Name", ... }"

Working with Song

Setting values:

song.title = "Song title";
song.difficulty = Difficulty.Easy;
song.bpm = 120;

Getting:

  • Normal values
song.title; // "Song title"
song.difficulty; // 0
song.description; // "Song description"
song.bpm; // 120
song.previewStart; // 140
song.previewLength; // 60
  • JSON object
song.toJson(); // { title: "Song title", ... }
  • JSON string
song.toString(); // "{ title: "Song title", ... }"

Working with Beatmap

Setting values:

beatmap.dateEdited = new Date() /* OR */ Date.now();
beatmap.versionNumber = 0;
beatmap.gameVersion = "20.4.4";

Getting:

  • Normal values
beatmap.dateEdited; // 2022-01-01T00:00:00.000Z
beatmap.versionNumber; // 0
beatmap.gameVersion; // "20.4.4"
beatmap.workshopID; // -1

beatmap.getDateString(); // "2022-01-01_00.00.00"
  • JSON object
beatmap.toJson(); // { date_edited: "2022-01-01_00.00.00", ... }
  • JSON string
beatmap.toString(); // "{ date_edited: "2022-01-01_00.00.00", ... }"

Building the metadata

You can convert the metadata to a JSON string/object, then write it to a file.

const fs = require("fs");

fs.writeFileSync("metadata.lsb", metadata.toString());

Reading the metadata

You can read an existing metadata from the string/object.

const { Metadata } = require("pa-meta");
const fs = require("fs");

const jsonString = fs.readFileSync("metadata.lsb", "utf8");
const json = JSON.parse(jsonString);
const metadata = new Metadata();
metadata.fromJson(json);

Author

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2023 PA Toolkit.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator