osu-play 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -5
- package/dist/index.d.ts +6 -3
- package/dist/index.js +9 -15
- package/dist/index.js.map +1 -1
- package/dist/src/cli/main.d.ts +18 -1
- package/dist/src/cli/main.js +101 -40
- package/dist/src/cli/main.js.map +1 -1
- package/package.json +2 -1
- package/src/cli/main.ts +105 -32
- package/src/utils/mod.ts +15 -19
package/README.md
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
|
-
# OSU!
|
|
1
|
+
# OSU!Pplay
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
client to listen to your beatmaps as a spotify playlist.
|
|
3
|
+
Listen to your favourite [OSU!Lazer](https://lazer.ppy.sh) beatmaps as a spotify playlist from the terminal
|
|
5
4
|
|
|
6
5
|
## Installation
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
### Requirements
|
|
8
|
+
|
|
9
|
+
- [Node.js](https://nodejs.org/en/) (v18 or higher)
|
|
10
|
+
- [osu!lazer](https://lazer.ppy.sh/home/download) with some beatmaps to listen to 😉
|
|
11
|
+
- That's it!
|
|
12
|
+
|
|
13
|
+
### Quick start
|
|
14
|
+
|
|
15
|
+
- Try out the latest release without installing anything:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npx osu-play # using npm
|
|
19
|
+
pnpm dlx osu-play # using pnpm
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- Install the latest release globally:
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm i -g osu-play # using npm
|
|
26
|
+
pnpm i -g osu-play # using pnpm
|
|
27
|
+
```
|
|
9
28
|
|
|
10
29
|
## Usage
|
|
11
30
|
|
|
31
|
+
### Cli
|
|
32
|
+
|
|
33
|
+
The `osu-play` command can be used with the following options:
|
|
12
34
|
```sh
|
|
13
|
-
|
|
35
|
+
➜ korigamik git:(main) ✗ osu-play --help
|
|
36
|
+
Play music from your osu!lazer beatmaps from the terminal
|
|
37
|
+
Usage: osu-play [options]
|
|
38
|
+
|
|
39
|
+
Options:
|
|
40
|
+
--help Show help [boolean]
|
|
41
|
+
--version Show version number [boolean]
|
|
42
|
+
-r, --reload Reload lazer database [boolean] [default: false]
|
|
43
|
+
-d, --osuDataDir Osu!lazer data directory [string] [default: "~/.local/share/osu"]
|
|
44
|
+
-c, --configDir Config directory [string] [default: "~/.config/osu-play"]
|
|
45
|
+
-l, --loop Loop the playlist on end [boolean] [default: false]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This package can be used as a library or as a cli application. To use the lazer
|
|
49
|
+
database interaction in your applicatoins import the `osu-play` package and
|
|
50
|
+
start using it!
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { lazer } from "osu-play";
|
|
54
|
+
|
|
55
|
+
const realm = getLazerDB();
|
|
14
56
|
```
|
|
57
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import Realm, { ObjectSchema } from 'realm';
|
|
2
2
|
|
|
3
|
-
declare function getDataDir(): string |
|
|
4
|
-
declare function getConfigDir(): string |
|
|
3
|
+
declare function getDataDir(): string | undefined;
|
|
4
|
+
declare function getConfigDir(): string | undefined;
|
|
5
5
|
/**
|
|
6
6
|
* Get Realm for the app, import to the config if it doesn't exist
|
|
7
7
|
*/
|
|
8
|
-
declare function getRealmDBPath(appConfigDir: string,
|
|
8
|
+
declare function getRealmDBPath(appConfigDir: string, options?: {
|
|
9
|
+
osuDataDir: string;
|
|
10
|
+
reload: boolean;
|
|
11
|
+
}): string | null;
|
|
9
12
|
|
|
10
13
|
declare const mod$1_getConfigDir: typeof getConfigDir;
|
|
11
14
|
declare const mod$1_getDataDir: typeof getDataDir;
|
package/dist/index.js
CHANGED
|
@@ -33,9 +33,9 @@ function getDataDir() {
|
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
35
|
case "win32":
|
|
36
|
-
return process.env["LOCALAPPDATA"] ??
|
|
36
|
+
return process.env["LOCALAPPDATA"] ?? void 0;
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return void 0;
|
|
39
39
|
}
|
|
40
40
|
function getConfigDir() {
|
|
41
41
|
switch (process.platform) {
|
|
@@ -57,24 +57,18 @@ function getConfigDir() {
|
|
|
57
57
|
break;
|
|
58
58
|
}
|
|
59
59
|
case "win32":
|
|
60
|
-
return process.env["APPDATA"] ??
|
|
60
|
+
return process.env["APPDATA"] ?? void 0;
|
|
61
61
|
}
|
|
62
|
-
return
|
|
62
|
+
return void 0;
|
|
63
63
|
}
|
|
64
|
-
function getRealmDBPath(appConfigDir,
|
|
64
|
+
function getRealmDBPath(appConfigDir, options = { reload: false, osuDataDir: getDataDir() || "." }) {
|
|
65
65
|
const localDBPath = path.join(appConfigDir, "client.realm");
|
|
66
|
-
if (!reload && existsSync(localDBPath))
|
|
66
|
+
if (!options.reload && existsSync(localDBPath))
|
|
67
67
|
return localDBPath;
|
|
68
|
-
const osuDBPath = path.join(
|
|
69
|
-
osuDataDir || getDataDir() || ".",
|
|
70
|
-
"osu",
|
|
71
|
-
"client.realm"
|
|
72
|
-
);
|
|
68
|
+
const osuDBPath = path.join(options.osuDataDir, "client.realm");
|
|
73
69
|
if (existsSync(osuDBPath)) {
|
|
74
|
-
console.log(
|
|
75
|
-
|
|
76
|
-
);
|
|
77
|
-
mkdirSync(appConfigDir);
|
|
70
|
+
console.log(`[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`);
|
|
71
|
+
mkdirSync(appConfigDir, { recursive: true });
|
|
78
72
|
copyFileSync(osuDBPath, localDBPath);
|
|
79
73
|
return localDBPath;
|
|
80
74
|
} else {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/mod.ts","../src/realm/mod.ts","../src/realm/schema/beatmap.ts","../src/realm/schema/beatmapMetadata.ts","../src/realm/schema/beatmapSet.ts","../src/realm/schema/realmFile.ts","../src/realm/schema/realmUser.ts","../src/realm/schema/realmNamedFileUsage.ts"],"sourcesContent":["import path from \"node:path\";\nimport { copyFileSync, existsSync, mkdirSync } from \"node:fs\";\n\nexport function getDataDir(): string | null {\n switch (process.platform) {\n case \"linux\":\n case \"openbsd\":\n case \"freebsd\": {\n const xdg = process.env[\"XDG_DATA_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".local\", \"share\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Application Support\");\n break;\n }\n\n case \"win32\":\n return process.env[\"LOCALAPPDATA\"] ?? null;\n }\n\n return null;\n}\n\nexport function getConfigDir(): string | null {\n switch (process.platform) {\n case \"openbsd\":\n case \"freebsd\":\n case \"linux\": {\n const xdg = process.env[\"XDG_CONFIG_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".config\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Preferences\");\n break;\n }\n\n case \"win32\":\n return process.env[\"APPDATA\"] ?? null;\n }\n\n return null;\n}\n\n/**\n * Get Realm for the app, import to the config if it doesn't exist\n */\nexport function getRealmDBPath(\n appConfigDir: string,\n osuDataDir?: string,\n reload: boolean = false,\n) {\n const localDBPath = path.join(appConfigDir, \"client.realm\");\n if (!reload && existsSync(localDBPath)) return localDBPath;\n\n const osuDBPath = path.join(\n osuDataDir || getDataDir()! || \".\",\n \"osu\",\n \"client.realm\",\n );\n if (existsSync(osuDBPath)) {\n console.log(\n `[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`,\n );\n mkdirSync(appConfigDir);\n copyFileSync(osuDBPath, localDBPath);\n return localDBPath;\n } else {\n console.log(`[getRealmDBPath]: ${osuDBPath} not found`);\n return null;\n }\n}\n","import Realm from \"realm\";\nimport path from \"node:path\";\nimport { getDataDir } from \"../utils/mod.js\";\nimport {\n Beatmap,\n BeatmapMetadata,\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n RealmUser,\n} from \"./schema/mod.js\";\n\nexport const getLazerDB = async (realmDBPath: string) => {\n const realm = await Realm.open({\n schema: [\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n Beatmap,\n BeatmapMetadata,\n RealmUser,\n ],\n path: realmDBPath,\n schemaVersion: 36,\n onMigration: (oldRealm, newRealm) => {\n console.log(\n `[onMigration]: Migrating ${oldRealm.path} - ${oldRealm.schemaVersion} -> ${newRealm.path} - ${newRealm.schemaVersion}`,\n );\n },\n });\n\n return realm;\n};\n\nexport const hashedFilePath = (hash: string) => {\n const dataDir = getDataDir();\n if (!dataDir) return null;\n return path.join(\n dataDir,\n \"osu\",\n \"files\",\n hash.slice(0, 1),\n hash.slice(0, 2),\n hash,\n );\n};\n\nexport const getNamedFileHash = (fileName: string, beatmapSet: BeatmapSet) => {\n const files = beatmapSet.Files;\n for (const file of files) {\n if (file.Filename == fileName) return file.File.Hash;\n }\n return undefined;\n};\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { BeatmapMetadata } from \"./beatmapMetadata.js\";\n\nexport class Beatmap extends Realm.Object<Beatmap> {\n ID!: string;\n DifficultyName?: string;\n Ruleset!: any;\n Difficulty!: any;\n Metadata!: BeatmapMetadata;\n UserSettings!: any;\n BeatmapSet!: any;\n Status!: number;\n OnlineID!: number;\n Length!: number;\n BPM!: number;\n Hash?: string;\n StarRating!: number;\n MD5Hash?: string;\n OnlineMD5Hash?: string;\n LastLocalUpdate?: Date;\n LastOnlineUpdate?: Date;\n Hidden!: boolean;\n AudioLeadIn!: number;\n StackLeniency!: number;\n SpecialStyle!: boolean;\n LetterboxInBreaks!: boolean;\n WidescreenStoryboard!: boolean;\n EpilepsyWarning!: boolean;\n SamplesMatchPlaybackRate!: boolean;\n LastPlayed?: Date;\n DistanceSpacing!: number;\n BeatDivisor!: number;\n GridSize!: number;\n TimelineZoom!: number;\n EditorTimestamp?: number;\n CountdownOffset!: number;\n\n static schema: ObjectSchema = {\n name: \"Beatmap\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n DifficultyName: { type: \"string\", default: \"\", optional: true },\n // Ruleset: { type: \"object\", objectType: \"Ruleset\", default: null },\n // Difficulty: { type: \"object\", objectType: \"BeatmapDifficulty\", default: null },\n Metadata: {\n type: \"object\",\n objectType: \"BeatmapMetadata\",\n default: null,\n },\n // UserSettings: { type: \"object\", objectType: \"BeatmapUserSettings\", default: null },\n BeatmapSet: { type: \"object\", objectType: \"BeatmapSet\", default: null },\n Status: { type: \"int\", default: -3 },\n OnlineID: { type: \"int\", default: -1 },\n Length: { type: \"double\", default: 0 },\n BPM: { type: \"double\", default: 0 },\n Hash: { type: \"string\", default: \"\", optional: true },\n StarRating: { type: \"double\", default: -1 },\n MD5Hash: { type: \"string\", default: \"\", optional: true },\n OnlineMD5Hash: {\n type: \"string\",\n default: \"\",\n optional: true,\n },\n LastLocalUpdate: { type: \"date\", optional: true },\n LastOnlineUpdate: { type: \"date\", optional: true },\n Hidden: { type: \"bool\", default: false },\n AudioLeadIn: { type: \"double\", default: 0 },\n StackLeniency: { type: \"float\", default: 0.7 },\n SpecialStyle: { type: \"bool\", default: false },\n LetterboxInBreaks: { type: \"bool\", default: false },\n WidescreenStoryboard: { type: \"bool\", default: false },\n EpilepsyWarning: { type: \"bool\", default: false },\n SamplesMatchPlaybackRate: { type: \"bool\", default: false },\n LastPlayed: { type: \"date\", optional: true },\n DistanceSpacing: { type: \"double\", default: 0 },\n BeatDivisor: { type: \"int\", default: 0 },\n GridSize: { type: \"int\", default: 0 },\n TimelineZoom: { type: \"double\", default: 0 },\n EditorTimestamp: { type: \"double\", optional: true },\n CountdownOffset: { type: \"int\", default: 0 },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmUser } from \"./realmUser.js\";\n\nexport class BeatmapMetadata extends Realm.Object<BeatmapMetadata> {\n Title?: string;\n TitleUnicode?: string;\n Artist?: string;\n ArtistUnicode?: string;\n Author?: RealmUser;\n Source?: string;\n Tags?: string;\n PreviewTime?: number;\n AudioFile?: string;\n BackgroundFile?: string;\n\n static schema: ObjectSchema = {\n name: \"BeatmapMetadata\",\n properties: {\n Title: { type: \"string\", default: \"\", optional: true },\n TitleUnicode: { type: \"string\", default: \"\", optional: true },\n Artist: { type: \"string\", default: \"\", optional: true },\n ArtistUnicode: { type: \"string\", default: \"\", optional: true },\n Author: { type: \"object\", objectType: \"RealmUser\", default: null },\n Source: { type: \"string\", default: \"\", optional: true },\n Tags: { type: \"string\", default: \"\", optional: true },\n PreviewTime: { type: \"int\", default: 0 },\n AudioFile: { type: \"string\", default: \"\", optional: true },\n BackgroundFile: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { Beatmap } from \"./beatmap.js\";\nimport { RealmNamedFileUsage } from \"./realmNamedFileUsage.js\";\n\nexport class BeatmapSet extends Realm.Object<BeatmapSet> {\n ID!: string;\n OnlineID!: number;\n DateAdded!: Date;\n DateSubmitted?: Date;\n DateRanked?: Date;\n Beatmaps!: Array<Beatmap>;\n Files!: Array<RealmNamedFileUsage>;\n Status!: number;\n DeletePending!: boolean;\n Hash?: string;\n Protected!: boolean;\n\n static schema: ObjectSchema = {\n name: \"BeatmapSet\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n OnlineID: { type: \"int\", default: -1 },\n DateAdded: { type: \"date\" },\n DateSubmitted: { type: \"date\", optional: true },\n DateRanked: { type: \"date\", optional: true },\n Beatmaps: { type: \"list\", objectType: \"Beatmap\", default: [] },\n Files: { type: \"list\", objectType: \"RealmNamedFileUsage\", default: [] },\n Status: { type: \"int\", default: -3 },\n DeletePending: { type: \"bool\", default: false },\n Hash: { type: \"string\", default: \"\", optional: true },\n Protected: { type: \"bool\", default: false },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmFile extends Realm.Object<RealmFile> {\n Hash?: string;\n\n static schema: ObjectSchema = {\n name: \"File\",\n primaryKey: \"Hash\",\n properties: {\n Hash: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmUser extends Realm.Object<RealmUser> {\n OnlineID!: number;\n Username?: string;\n CountryCode?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmUser\",\n embedded: true,\n properties: {\n OnlineID: { type: \"int\", default: 1 },\n Username: { type: \"string\", default: \"\", optional: true },\n CountryCode: { type: \"string\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmFile } from \"./realmFile.js\";\n\nexport class RealmNamedFileUsage extends Realm.Object<RealmNamedFileUsage> {\n File!: RealmFile;\n Filename?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmNamedFileUsage\",\n embedded: true,\n properties: {\n File: \"File\",\n Filename: { type: \"string\", optional: true },\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAO,UAAU;AACjB,SAAS,cAAc,YAAY,iBAAiB;AAE7C,SAAS,aAA4B;AAC1C,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,WAAW;AACd,YAAM,MAAM,QAAQ,IAAI,eAAe;AACvC,UAAI;AAAK,eAAO;AAChB,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO,KAAK,KAAK,MAAM,UAAU,OAAO;AAClD;AAAA,IACF;AAAA,IAEA,KAAK,UAAU;AACb,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO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QACN,4BAA4B,SAAS,IAAI,MAAM,SAAS,aAAa,OAAO,SAAS,IAAI,MAAM,SAAS,aAAa;AAAA,MACvH;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO;AACT;AAEO,IAAM,iBAAiB,CAAC,SAAiB;AAC9C,QAAM,UAAU,WAAW;AAC3B,MAAI,CAAC;AAAS,WAAO;AACrB,SAAOC,MAAK;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,KAAK,MAAM,GAAG,CAAC;AAAA,IACf,KAAK,MAAM,GAAG,CAAC;AAAA,IACf;AAAA,EACF;AACF;AAEO,IAAM,mBAAmB,CAAC,UAAkB,eAA2B;AAC5E,QAAM,QAAQ,WAAW;AACzB,aAAW,QAAQ,OAAO;AACxB,QAAI,KAAK,YAAY;AAAU,aAAO,KAAK,KAAK;AAAA,EAClD;AACA,SAAO;AACT;","names":["mod_exports","Realm","path","Realm","Realm","Realm","Realm","Realm","Realm","path"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/mod.ts","../src/realm/mod.ts","../src/realm/schema/beatmap.ts","../src/realm/schema/beatmapMetadata.ts","../src/realm/schema/beatmapSet.ts","../src/realm/schema/realmFile.ts","../src/realm/schema/realmUser.ts","../src/realm/schema/realmNamedFileUsage.ts"],"sourcesContent":["import path from \"node:path\";\nimport { copyFileSync, existsSync, mkdirSync } from \"node:fs\";\n\nexport function getDataDir(): string | undefined {\n switch (process.platform) {\n case \"linux\":\n case \"openbsd\":\n case \"freebsd\": {\n const xdg = process.env[\"XDG_DATA_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".local\", \"share\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Application Support\");\n break;\n }\n\n case \"win32\":\n return process.env[\"LOCALAPPDATA\"] ?? undefined;\n }\n\n return undefined;\n}\n\nexport function getConfigDir(): string | undefined {\n switch (process.platform) {\n case \"openbsd\":\n case \"freebsd\":\n case \"linux\": {\n const xdg = process.env[\"XDG_CONFIG_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".config\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Preferences\");\n break;\n }\n\n case \"win32\":\n return process.env[\"APPDATA\"] ?? undefined;\n }\n\n return undefined;\n}\n\n/**\n * Get Realm for the app, import to the config if it doesn't exist\n */\nexport function getRealmDBPath(\n appConfigDir: string,\n options: {\n osuDataDir: string;\n reload: boolean;\n } = { reload: false, osuDataDir: getDataDir() || \".\" },\n) {\n const localDBPath = path.join(appConfigDir, \"client.realm\");\n if (!options.reload && existsSync(localDBPath)) return localDBPath;\n\n const osuDBPath = path.join(options.osuDataDir, \"client.realm\");\n if (existsSync(osuDBPath)) {\n console.log( `[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`);\n mkdirSync(appConfigDir, { recursive: true });\n copyFileSync(osuDBPath, localDBPath );\n return localDBPath;\n } else {\n console.log(`[getRealmDBPath]: ${osuDBPath} not found`);\n return null;\n }\n}\n","import Realm from \"realm\";\nimport path from \"node:path\";\nimport { getDataDir } from \"../utils/mod.js\";\nimport {\n Beatmap,\n BeatmapMetadata,\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n RealmUser,\n} from \"./schema/mod.js\";\n\nexport const getLazerDB = async (realmDBPath: string) => {\n const realm = await Realm.open({\n schema: [\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n Beatmap,\n BeatmapMetadata,\n RealmUser,\n ],\n path: realmDBPath,\n schemaVersion: 36,\n onMigration: (oldRealm, newRealm) => {\n console.log(\n `[onMigration]: Migrating ${oldRealm.path} - ${oldRealm.schemaVersion} -> ${newRealm.path} - ${newRealm.schemaVersion}`,\n );\n },\n });\n\n return realm;\n};\n\nexport const hashedFilePath = (hash: string) => {\n const dataDir = getDataDir();\n if (!dataDir) return null;\n return path.join(\n dataDir,\n \"osu\",\n \"files\",\n hash.slice(0, 1),\n hash.slice(0, 2),\n hash,\n );\n};\n\nexport const getNamedFileHash = (fileName: string, beatmapSet: BeatmapSet) => {\n const files = beatmapSet.Files;\n for (const file of files) {\n if (file.Filename == fileName) return file.File.Hash;\n }\n return undefined;\n};\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { BeatmapMetadata } from \"./beatmapMetadata.js\";\n\nexport class Beatmap extends Realm.Object<Beatmap> {\n ID!: string;\n DifficultyName?: string;\n Ruleset!: any;\n Difficulty!: any;\n Metadata!: BeatmapMetadata;\n UserSettings!: any;\n BeatmapSet!: any;\n Status!: number;\n OnlineID!: number;\n Length!: number;\n BPM!: number;\n Hash?: string;\n StarRating!: number;\n MD5Hash?: string;\n OnlineMD5Hash?: string;\n LastLocalUpdate?: Date;\n LastOnlineUpdate?: Date;\n Hidden!: boolean;\n AudioLeadIn!: number;\n StackLeniency!: number;\n SpecialStyle!: boolean;\n LetterboxInBreaks!: boolean;\n WidescreenStoryboard!: boolean;\n EpilepsyWarning!: boolean;\n SamplesMatchPlaybackRate!: boolean;\n LastPlayed?: Date;\n DistanceSpacing!: number;\n BeatDivisor!: number;\n GridSize!: number;\n TimelineZoom!: number;\n EditorTimestamp?: number;\n CountdownOffset!: number;\n\n static schema: ObjectSchema = {\n name: \"Beatmap\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n DifficultyName: { type: \"string\", default: \"\", optional: true },\n // Ruleset: { type: \"object\", objectType: \"Ruleset\", default: null },\n // Difficulty: { type: \"object\", objectType: \"BeatmapDifficulty\", default: null },\n Metadata: {\n type: \"object\",\n objectType: \"BeatmapMetadata\",\n default: null,\n },\n // UserSettings: { type: \"object\", objectType: \"BeatmapUserSettings\", default: null },\n BeatmapSet: { type: \"object\", objectType: \"BeatmapSet\", default: null },\n Status: { type: \"int\", default: -3 },\n OnlineID: { type: \"int\", default: -1 },\n Length: { type: \"double\", default: 0 },\n BPM: { type: \"double\", default: 0 },\n Hash: { type: \"string\", default: \"\", optional: true },\n StarRating: { type: \"double\", default: -1 },\n MD5Hash: { type: \"string\", default: \"\", optional: true },\n OnlineMD5Hash: {\n type: \"string\",\n default: \"\",\n optional: true,\n },\n LastLocalUpdate: { type: \"date\", optional: true },\n LastOnlineUpdate: { type: \"date\", optional: true },\n Hidden: { type: \"bool\", default: false },\n AudioLeadIn: { type: \"double\", default: 0 },\n StackLeniency: { type: \"float\", default: 0.7 },\n SpecialStyle: { type: \"bool\", default: false },\n LetterboxInBreaks: { type: \"bool\", default: false },\n WidescreenStoryboard: { type: \"bool\", default: false },\n EpilepsyWarning: { type: \"bool\", default: false },\n SamplesMatchPlaybackRate: { type: \"bool\", default: false },\n LastPlayed: { type: \"date\", optional: true },\n DistanceSpacing: { type: \"double\", default: 0 },\n BeatDivisor: { type: \"int\", default: 0 },\n GridSize: { type: \"int\", default: 0 },\n TimelineZoom: { type: \"double\", default: 0 },\n EditorTimestamp: { type: \"double\", optional: true },\n CountdownOffset: { type: \"int\", default: 0 },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmUser } from \"./realmUser.js\";\n\nexport class BeatmapMetadata extends Realm.Object<BeatmapMetadata> {\n Title?: string;\n TitleUnicode?: string;\n Artist?: string;\n ArtistUnicode?: string;\n Author?: RealmUser;\n Source?: string;\n Tags?: string;\n PreviewTime?: number;\n AudioFile?: string;\n BackgroundFile?: string;\n\n static schema: ObjectSchema = {\n name: \"BeatmapMetadata\",\n properties: {\n Title: { type: \"string\", default: \"\", optional: true },\n TitleUnicode: { type: \"string\", default: \"\", optional: true },\n Artist: { type: \"string\", default: \"\", optional: true },\n ArtistUnicode: { type: \"string\", default: \"\", optional: true },\n Author: { type: \"object\", objectType: \"RealmUser\", default: null },\n Source: { type: \"string\", default: \"\", optional: true },\n Tags: { type: \"string\", default: \"\", optional: true },\n PreviewTime: { type: \"int\", default: 0 },\n AudioFile: { type: \"string\", default: \"\", optional: true },\n BackgroundFile: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { Beatmap } from \"./beatmap.js\";\nimport { RealmNamedFileUsage } from \"./realmNamedFileUsage.js\";\n\nexport class BeatmapSet extends Realm.Object<BeatmapSet> {\n ID!: string;\n OnlineID!: number;\n DateAdded!: Date;\n DateSubmitted?: Date;\n DateRanked?: Date;\n Beatmaps!: Array<Beatmap>;\n Files!: Array<RealmNamedFileUsage>;\n Status!: number;\n DeletePending!: boolean;\n Hash?: string;\n Protected!: boolean;\n\n static schema: ObjectSchema = {\n name: \"BeatmapSet\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n OnlineID: { type: \"int\", default: -1 },\n DateAdded: { type: \"date\" },\n DateSubmitted: { type: \"date\", optional: true },\n DateRanked: { type: \"date\", optional: true },\n Beatmaps: { type: \"list\", objectType: \"Beatmap\", default: [] },\n Files: { type: \"list\", objectType: \"RealmNamedFileUsage\", default: [] },\n Status: { type: \"int\", default: -3 },\n DeletePending: { type: \"bool\", default: false },\n Hash: { type: \"string\", default: \"\", optional: true },\n Protected: { type: \"bool\", default: false },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmFile extends Realm.Object<RealmFile> {\n Hash?: string;\n\n static schema: ObjectSchema = {\n name: \"File\",\n primaryKey: \"Hash\",\n properties: {\n Hash: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmUser extends Realm.Object<RealmUser> {\n OnlineID!: number;\n Username?: string;\n CountryCode?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmUser\",\n embedded: true,\n properties: {\n OnlineID: { type: \"int\", default: 1 },\n Username: { type: \"string\", default: \"\", optional: true },\n CountryCode: { type: \"string\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmFile } from \"./realmFile.js\";\n\nexport class RealmNamedFileUsage extends Realm.Object<RealmNamedFileUsage> {\n File!: RealmFile;\n Filename?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmNamedFileUsage\",\n embedded: true,\n properties: {\n File: \"File\",\n Filename: { type: \"string\", optional: true },\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAO,UAAU;AACjB,SAAS,cAAc,YAAY,iBAAiB;AAE7C,SAAS,aAAiC;AAC/C,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,WAAW;AACd,YAAM,MAAM,QAAQ,IAAI,eAAe;AACvC,UAAI;AAAK,eAAO;AAChB,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO,KAAK,KAAK,MAAM,UAAU,OAAO;AAClD;AAAA,IACF;AAAA,IAEA,KAAK,UAAU;AACb,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO,KAAK,KAAK,MAAM,WAAW,qBAAqB;AACjE;AAAA,IACF;AAAA,IAEA,KAAK;AACH,aAAO,QAAQ,IAAI,cAAc,KAAK;AAAA,EAC1C;AAEA,SAAO;AACT;AAEO,SAAS,eAAmC;AACjD,UAAQ,QAAQ,UAAU;AAAA,IACxB,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK,SAAS;AACZ,YAAM,MAAM,QAAQ,IAAI,iBAAiB;AACzC,UAAI;AAAK,eAAO;AAChB,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO,KAAK,KAAK,MAAM,SAAS;AAC1C;AAAA,IACF;AAAA,IAEA,KAAK,UAAU;AACb,YAAM,OAAO,QAAQ,IAAI,MAAM;AAC/B,UAAI;AAAM,eAAO,KAAK,KAAK,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K,YAAY;AAAU,aAAO,KAAK,KAAK;AAAA,EAClD;AACA,SAAO;AACT;","names":["mod_exports","Realm","path","Realm","Realm","Realm","Realm","Realm","Realm","path"]}
|
package/dist/src/cli/main.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
declare function getArgs(): {
|
|
2
|
+
[x: string]: unknown;
|
|
3
|
+
reload: boolean;
|
|
4
|
+
osuDataDir: string;
|
|
5
|
+
configDir: string;
|
|
6
|
+
loop: boolean;
|
|
7
|
+
_: (string | number)[];
|
|
8
|
+
$0: string;
|
|
9
|
+
} | Promise<{
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
reload: boolean;
|
|
12
|
+
osuDataDir: string;
|
|
13
|
+
configDir: string;
|
|
14
|
+
loop: boolean;
|
|
15
|
+
_: (string | number)[];
|
|
16
|
+
$0: string;
|
|
17
|
+
}>;
|
|
1
18
|
declare function main(): Promise<void>;
|
|
2
19
|
|
|
3
|
-
export { main };
|
|
20
|
+
export { getArgs, main };
|
package/dist/src/cli/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/cli/main.ts
|
|
2
2
|
import path3 from "path";
|
|
3
3
|
import { existsSync as existsSync2 } from "fs";
|
|
4
|
-
import {
|
|
4
|
+
import { execFileSync } from "child_process";
|
|
5
5
|
import Realm8 from "realm";
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
|
|
@@ -221,9 +221,9 @@ function getDataDir() {
|
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
223
223
|
case "win32":
|
|
224
|
-
return process.env["LOCALAPPDATA"] ??
|
|
224
|
+
return process.env["LOCALAPPDATA"] ?? void 0;
|
|
225
225
|
}
|
|
226
|
-
return
|
|
226
|
+
return void 0;
|
|
227
227
|
}
|
|
228
228
|
function getConfigDir() {
|
|
229
229
|
switch (process.platform) {
|
|
@@ -245,24 +245,18 @@ function getConfigDir() {
|
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
247
|
case "win32":
|
|
248
|
-
return process.env["APPDATA"] ??
|
|
248
|
+
return process.env["APPDATA"] ?? void 0;
|
|
249
249
|
}
|
|
250
|
-
return
|
|
250
|
+
return void 0;
|
|
251
251
|
}
|
|
252
|
-
function getRealmDBPath(appConfigDir,
|
|
252
|
+
function getRealmDBPath(appConfigDir, options = { reload: false, osuDataDir: getDataDir() || "." }) {
|
|
253
253
|
const localDBPath = path.join(appConfigDir, "client.realm");
|
|
254
|
-
if (!reload && existsSync(localDBPath))
|
|
254
|
+
if (!options.reload && existsSync(localDBPath))
|
|
255
255
|
return localDBPath;
|
|
256
|
-
const osuDBPath = path.join(
|
|
257
|
-
osuDataDir || getDataDir() || ".",
|
|
258
|
-
"osu",
|
|
259
|
-
"client.realm"
|
|
260
|
-
);
|
|
256
|
+
const osuDBPath = path.join(options.osuDataDir, "client.realm");
|
|
261
257
|
if (existsSync(osuDBPath)) {
|
|
262
|
-
console.log(
|
|
263
|
-
|
|
264
|
-
);
|
|
265
|
-
mkdirSync(appConfigDir);
|
|
258
|
+
console.log(`[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`);
|
|
259
|
+
mkdirSync(appConfigDir, { recursive: true });
|
|
266
260
|
copyFileSync(osuDBPath, localDBPath);
|
|
267
261
|
return localDBPath;
|
|
268
262
|
} else {
|
|
@@ -317,11 +311,50 @@ var getNamedFileHash = (fileName, beatmapSet) => {
|
|
|
317
311
|
};
|
|
318
312
|
|
|
319
313
|
// src/cli/main.ts
|
|
314
|
+
import yargs from "yargs/yargs";
|
|
315
|
+
import { hideBin } from "yargs/helpers";
|
|
316
|
+
function getArgs() {
|
|
317
|
+
const argv = yargs(hideBin(process.argv)).usage("Play music from your osu!lazer beatmaps from the terminal\nUsage: $0 [options]").options({
|
|
318
|
+
reload: {
|
|
319
|
+
type: "boolean",
|
|
320
|
+
default: false,
|
|
321
|
+
alias: "r",
|
|
322
|
+
describe: "Reload lazer database"
|
|
323
|
+
},
|
|
324
|
+
osuDataDir: {
|
|
325
|
+
type: "string",
|
|
326
|
+
default: path3.join(getDataDir() || ".", "osu"),
|
|
327
|
+
alias: "d",
|
|
328
|
+
describe: "Osu!lazer data directory"
|
|
329
|
+
},
|
|
330
|
+
configDir: {
|
|
331
|
+
type: "string",
|
|
332
|
+
default: path3.join(getConfigDir() || ".", "osu-play"),
|
|
333
|
+
alias: "c",
|
|
334
|
+
describe: "Config directory"
|
|
335
|
+
},
|
|
336
|
+
loop: {
|
|
337
|
+
type: "boolean",
|
|
338
|
+
default: false,
|
|
339
|
+
alias: "l",
|
|
340
|
+
describe: "Loop the playlist on end"
|
|
341
|
+
}
|
|
342
|
+
}).argv;
|
|
343
|
+
return argv;
|
|
344
|
+
}
|
|
320
345
|
async function main() {
|
|
346
|
+
const argv = await getArgs();
|
|
321
347
|
console.log("[INFO] OSU!list");
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
)
|
|
348
|
+
let reload = false;
|
|
349
|
+
let osuDataDir = argv.osuDataDir;
|
|
350
|
+
if (argv.reload) {
|
|
351
|
+
console.log("[INFO] Reloading lazer database");
|
|
352
|
+
reload = true;
|
|
353
|
+
}
|
|
354
|
+
if (argv.osuDataDir !== getDataDir()) {
|
|
355
|
+
console.log(`[INFO] Using osu!lazer data directory: ${argv.osuDataDir}`);
|
|
356
|
+
}
|
|
357
|
+
const realmDBPath = getRealmDBPath(argv.configDir, { reload, osuDataDir });
|
|
325
358
|
if (realmDBPath == null) {
|
|
326
359
|
console.log("[ERROR] Realm DB not found");
|
|
327
360
|
process.exit(1);
|
|
@@ -332,34 +365,62 @@ async function main() {
|
|
|
332
365
|
const realm = await getLazerDB(realmDBPath);
|
|
333
366
|
console.log(`realm.isClosed: ${realm.isClosed}`);
|
|
334
367
|
const beatmapSets = realm.objects(BeatmapSet);
|
|
335
|
-
|
|
336
|
-
const
|
|
368
|
+
const songSet = /* @__PURE__ */ new Set();
|
|
369
|
+
const uniqueBeatmaps = [];
|
|
370
|
+
for (const beatmapSet of beatmapSets) {
|
|
371
|
+
for (const beatmap of beatmapSet.Beatmaps) {
|
|
372
|
+
const fileName = beatmap.Metadata.AudioFile;
|
|
373
|
+
const hash = getNamedFileHash(fileName ?? "", beatmapSet);
|
|
374
|
+
if (!hash)
|
|
375
|
+
continue;
|
|
376
|
+
if (songSet.has(hash))
|
|
377
|
+
continue;
|
|
378
|
+
songSet.add(hash);
|
|
379
|
+
const meta = beatmap.Metadata;
|
|
380
|
+
const path4 = hashedFilePath(hash);
|
|
381
|
+
const title = `${meta.Title} : ${meta.Artist} - ${meta.TitleUnicode} : ${meta.ArtistUnicode}`;
|
|
382
|
+
uniqueBeatmaps.push({ title, path: path4 });
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
console.log(`beatmap songs: ${beatmapSets.length}`);
|
|
386
|
+
let selectedBeatmap = (await prompts({
|
|
337
387
|
type: "autocomplete",
|
|
338
|
-
name: "
|
|
388
|
+
name: "beatmap",
|
|
339
389
|
message: "Which map do you want to play:",
|
|
340
|
-
choices:
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
390
|
+
choices: uniqueBeatmaps.map((mp, index) => ({
|
|
391
|
+
title: mp.title,
|
|
392
|
+
value: index
|
|
393
|
+
}))
|
|
394
|
+
})).beatmap;
|
|
395
|
+
for (let i = selectedBeatmap; i < uniqueBeatmaps.length; ++i) {
|
|
396
|
+
const beatmap = uniqueBeatmaps[i];
|
|
397
|
+
console.log(`Map : ${beatmap.title}`);
|
|
398
|
+
if (beatmap.path && existsSync2(beatmap.path)) {
|
|
399
|
+
console.log(`File exists: ${beatmap.path}`);
|
|
400
|
+
console.log(`Playing ${beatmap.title}`);
|
|
401
|
+
try {
|
|
402
|
+
execFileSync("exo-open", [beatmap.path]);
|
|
403
|
+
} catch (err) {
|
|
404
|
+
console.log(`Error: ${err}`);
|
|
405
|
+
break;
|
|
406
|
+
}
|
|
407
|
+
} else {
|
|
408
|
+
console.log(`File does not exist: ${beatmap.path}`);
|
|
409
|
+
}
|
|
410
|
+
if (i < uniqueBeatmaps.length - 1) {
|
|
411
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
412
|
+
} else if (argv.loop) {
|
|
413
|
+
console.log("[INFO] Looping playlist");
|
|
414
|
+
i = 0;
|
|
415
|
+
} else {
|
|
416
|
+
console.log("[INFO] Done. Use --loop to loop the playlist");
|
|
417
|
+
}
|
|
356
418
|
}
|
|
357
|
-
console.log(`Playing file ${selectedBeatmapSet.Beatmaps[0].Metadata.Title}`);
|
|
358
|
-
filePath && execSync(`exo-open ${filePath}`);
|
|
359
419
|
realm.close();
|
|
360
420
|
console.log(`realm.isClosed: ${realm.isClosed}`);
|
|
361
421
|
}
|
|
362
422
|
export {
|
|
423
|
+
getArgs,
|
|
363
424
|
main
|
|
364
425
|
};
|
|
365
426
|
//# sourceMappingURL=main.js.map
|
package/dist/src/cli/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cli/main.ts","../../../src/realm/schema/beatmap.ts","../../../src/realm/schema/beatmapMetadata.ts","../../../src/realm/schema/beatmapSet.ts","../../../src/realm/schema/realmFile.ts","../../../src/realm/schema/realmUser.ts","../../../src/realm/schema/realmNamedFileUsage.ts","../../../src/utils/mod.ts","../../../src/realm/mod.ts"],"sourcesContent":["import path from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { execSync } from \"node:child_process\";\n\nimport Realm from \"realm\";\nimport prompts from \"prompts\";\nimport { BeatmapSet } from \"../realm/schema/mod.js\";\nimport { getConfigDir, getRealmDBPath } from \"../utils/mod.js\";\nimport { getLazerDB, getNamedFileHash, hashedFilePath } from \"../realm/mod.js\";\n\nexport async function main() {\n console.log(\"[INFO] OSU!list\");\n\n const realmDBPath = getRealmDBPath(\n path.join(getConfigDir() || \".\", \"osu-play\"),\n );\n\n if (realmDBPath == null) {\n console.log(\"[ERROR] Realm DB not found\");\n process.exit(1);\n }\n\n const currentSchema = Realm.schemaVersion(realmDBPath);\n console.log(`currentSchema: ${currentSchema}`);\n\n Realm.flags.ALLOW_CLEAR_TEST_STATE = true;\n\n const realm: Realm = await getLazerDB(realmDBPath);\n\n console.log(`realm.isClosed: ${realm.isClosed}`);\n\n const beatmapSets = realm.objects(BeatmapSet);\n\n console.log(`beatmaps: ${beatmapSets.length}`);\n\n // Get the map index from the user\n const selectedBeatmapSet = (\n await prompts({\n type: \"autocomplete\",\n name: \"beatmapSet\",\n message: \"Which map do you want to play:\",\n choices: beatmapSets.map((beatmapSet) => {\n const meta = beatmapSet.Beatmaps[0].Metadata;\n return {\n title:\n `${meta.Title} : ${meta.Artist} - ${meta.TitleUnicode} : ${meta.ArtistUnicode}`,\n value: beatmapSet,\n };\n }),\n })\n ).beatmapSet;\n\n console.log(`Map : ${selectedBeatmapSet.Beatmaps[0].Metadata.Title}`);\n const fileName = selectedBeatmapSet.Beatmaps[0].Metadata.AudioFile;\n const fileHash = fileName\n ? getNamedFileHash(fileName, selectedBeatmapSet)\n : undefined;\n const filePath = fileHash ? hashedFilePath(fileHash) : undefined;\n if (filePath && existsSync(filePath)) {\n console.log(`File exists: ${filePath}`);\n } else {\n console.log(`File does not exist: ${filePath}`);\n }\n\n // Open file using exo-open.\n console.log(`Playing file ${selectedBeatmapSet.Beatmaps[0].Metadata.Title}`);\n filePath && execSync(`exo-open ${filePath}`);\n\n realm.close();\n console.log(`realm.isClosed: ${realm.isClosed}`);\n\n // Realm.clearTestState();\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { BeatmapMetadata } from \"./beatmapMetadata.js\";\n\nexport class Beatmap extends Realm.Object<Beatmap> {\n ID!: string;\n DifficultyName?: string;\n Ruleset!: any;\n Difficulty!: any;\n Metadata!: BeatmapMetadata;\n UserSettings!: any;\n BeatmapSet!: any;\n Status!: number;\n OnlineID!: number;\n Length!: number;\n BPM!: number;\n Hash?: string;\n StarRating!: number;\n MD5Hash?: string;\n OnlineMD5Hash?: string;\n LastLocalUpdate?: Date;\n LastOnlineUpdate?: Date;\n Hidden!: boolean;\n AudioLeadIn!: number;\n StackLeniency!: number;\n SpecialStyle!: boolean;\n LetterboxInBreaks!: boolean;\n WidescreenStoryboard!: boolean;\n EpilepsyWarning!: boolean;\n SamplesMatchPlaybackRate!: boolean;\n LastPlayed?: Date;\n DistanceSpacing!: number;\n BeatDivisor!: number;\n GridSize!: number;\n TimelineZoom!: number;\n EditorTimestamp?: number;\n CountdownOffset!: number;\n\n static schema: ObjectSchema = {\n name: \"Beatmap\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n DifficultyName: { type: \"string\", default: \"\", optional: true },\n // Ruleset: { type: \"object\", objectType: \"Ruleset\", default: null },\n // Difficulty: { type: \"object\", objectType: \"BeatmapDifficulty\", default: null },\n Metadata: {\n type: \"object\",\n objectType: \"BeatmapMetadata\",\n default: null,\n },\n // UserSettings: { type: \"object\", objectType: \"BeatmapUserSettings\", default: null },\n BeatmapSet: { type: \"object\", objectType: \"BeatmapSet\", default: null },\n Status: { type: \"int\", default: -3 },\n OnlineID: { type: \"int\", default: -1 },\n Length: { type: \"double\", default: 0 },\n BPM: { type: \"double\", default: 0 },\n Hash: { type: \"string\", default: \"\", optional: true },\n StarRating: { type: \"double\", default: -1 },\n MD5Hash: { type: \"string\", default: \"\", optional: true },\n OnlineMD5Hash: {\n type: \"string\",\n default: \"\",\n optional: true,\n },\n LastLocalUpdate: { type: \"date\", optional: true },\n LastOnlineUpdate: { type: \"date\", optional: true },\n Hidden: { type: \"bool\", default: false },\n AudioLeadIn: { type: \"double\", default: 0 },\n StackLeniency: { type: \"float\", default: 0.7 },\n SpecialStyle: { type: \"bool\", default: false },\n LetterboxInBreaks: { type: \"bool\", default: false },\n WidescreenStoryboard: { type: \"bool\", default: false },\n EpilepsyWarning: { type: \"bool\", default: false },\n SamplesMatchPlaybackRate: { type: \"bool\", default: false },\n LastPlayed: { type: \"date\", optional: true },\n DistanceSpacing: { type: \"double\", default: 0 },\n BeatDivisor: { type: \"int\", default: 0 },\n GridSize: { type: \"int\", default: 0 },\n TimelineZoom: { type: \"double\", default: 0 },\n EditorTimestamp: { type: \"double\", optional: true },\n CountdownOffset: { type: \"int\", default: 0 },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmUser } from \"./realmUser.js\";\n\nexport class BeatmapMetadata extends Realm.Object<BeatmapMetadata> {\n Title?: string;\n TitleUnicode?: string;\n Artist?: string;\n ArtistUnicode?: string;\n Author?: RealmUser;\n Source?: string;\n Tags?: string;\n PreviewTime?: number;\n AudioFile?: string;\n BackgroundFile?: string;\n\n static schema: ObjectSchema = {\n name: \"BeatmapMetadata\",\n properties: {\n Title: { type: \"string\", default: \"\", optional: true },\n TitleUnicode: { type: \"string\", default: \"\", optional: true },\n Artist: { type: \"string\", default: \"\", optional: true },\n ArtistUnicode: { type: \"string\", default: \"\", optional: true },\n Author: { type: \"object\", objectType: \"RealmUser\", default: null },\n Source: { type: \"string\", default: \"\", optional: true },\n Tags: { type: \"string\", default: \"\", optional: true },\n PreviewTime: { type: \"int\", default: 0 },\n AudioFile: { type: \"string\", default: \"\", optional: true },\n BackgroundFile: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { Beatmap } from \"./beatmap.js\";\nimport { RealmNamedFileUsage } from \"./realmNamedFileUsage.js\";\n\nexport class BeatmapSet extends Realm.Object<BeatmapSet> {\n ID!: string;\n OnlineID!: number;\n DateAdded!: Date;\n DateSubmitted?: Date;\n DateRanked?: Date;\n Beatmaps!: Array<Beatmap>;\n Files!: Array<RealmNamedFileUsage>;\n Status!: number;\n DeletePending!: boolean;\n Hash?: string;\n Protected!: boolean;\n\n static schema: ObjectSchema = {\n name: \"BeatmapSet\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n OnlineID: { type: \"int\", default: -1 },\n DateAdded: { type: \"date\" },\n DateSubmitted: { type: \"date\", optional: true },\n DateRanked: { type: \"date\", optional: true },\n Beatmaps: { type: \"list\", objectType: \"Beatmap\", default: [] },\n Files: { type: \"list\", objectType: \"RealmNamedFileUsage\", default: [] },\n Status: { type: \"int\", default: -3 },\n DeletePending: { type: \"bool\", default: false },\n Hash: { type: \"string\", default: \"\", optional: true },\n Protected: { type: \"bool\", default: false },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmFile extends Realm.Object<RealmFile> {\n Hash?: string;\n\n static schema: ObjectSchema = {\n name: \"File\",\n primaryKey: \"Hash\",\n properties: {\n Hash: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmUser extends Realm.Object<RealmUser> {\n OnlineID!: number;\n Username?: string;\n CountryCode?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmUser\",\n embedded: true,\n properties: {\n OnlineID: { type: \"int\", default: 1 },\n Username: { type: \"string\", default: \"\", optional: true },\n CountryCode: { type: \"string\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmFile } from \"./realmFile.js\";\n\nexport class RealmNamedFileUsage extends Realm.Object<RealmNamedFileUsage> {\n File!: RealmFile;\n Filename?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmNamedFileUsage\",\n embedded: true,\n properties: {\n File: \"File\",\n Filename: { type: \"string\", optional: true },\n },\n };\n}\n","import path from \"node:path\";\nimport { copyFileSync, existsSync, mkdirSync } from \"node:fs\";\n\nexport function getDataDir(): string | null {\n switch (process.platform) {\n case \"linux\":\n case \"openbsd\":\n case \"freebsd\": {\n const xdg = process.env[\"XDG_DATA_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".local\", \"share\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Application Support\");\n break;\n }\n\n case \"win32\":\n return process.env[\"LOCALAPPDATA\"] ?? null;\n }\n\n return null;\n}\n\nexport function getConfigDir(): string | null {\n switch (process.platform) {\n case \"openbsd\":\n case \"freebsd\":\n case \"linux\": {\n const xdg = process.env[\"XDG_CONFIG_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".config\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Preferences\");\n break;\n }\n\n case \"win32\":\n return process.env[\"APPDATA\"] ?? null;\n }\n\n return null;\n}\n\n/**\n * Get Realm for the app, import to the config if it doesn't exist\n */\nexport function getRealmDBPath(\n appConfigDir: string,\n osuDataDir?: string,\n reload: boolean = false,\n) {\n const localDBPath = path.join(appConfigDir, \"client.realm\");\n if (!reload && existsSync(localDBPath)) return localDBPath;\n\n const osuDBPath = path.join(\n osuDataDir || getDataDir()! || \".\",\n \"osu\",\n \"client.realm\",\n );\n if (existsSync(osuDBPath)) {\n console.log(\n `[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`,\n );\n mkdirSync(appConfigDir);\n copyFileSync(osuDBPath, localDBPath);\n return localDBPath;\n } else {\n console.log(`[getRealmDBPath]: ${osuDBPath} not found`);\n return null;\n }\n}\n","import Realm from \"realm\";\nimport path from \"node:path\";\nimport { getDataDir } from \"../utils/mod.js\";\nimport {\n Beatmap,\n BeatmapMetadata,\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n RealmUser,\n} from \"./schema/mod.js\";\n\nexport const getLazerDB = async (realmDBPath: string) => {\n const realm = await Realm.open({\n schema: [\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n Beatmap,\n BeatmapMetadata,\n RealmUser,\n ],\n path: realmDBPath,\n schemaVersion: 36,\n onMigration: (oldRealm, newRealm) => {\n console.log(\n `[onMigration]: Migrating ${oldRealm.path} - ${oldRealm.schemaVersion} -> ${newRealm.path} - ${newRealm.schemaVersion}`,\n );\n },\n });\n\n return realm;\n};\n\nexport const hashedFilePath = (hash: string) => {\n const dataDir = getDataDir();\n if (!dataDir) return null;\n return path.join(\n dataDir,\n \"osu\",\n \"files\",\n hash.slice(0, 1),\n hash.slice(0, 2),\n hash,\n );\n};\n\nexport const getNamedFileHash = (fileName: string, beatmapSet: BeatmapSet) => {\n const files = beatmapSet.Files;\n for (const file of files) {\n if (file.Filename == fileName) return file.File.Hash;\n }\n return undefined;\n};\n"],"mappings":";AAAA,OAAOA,WAAU;AACjB,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,gBAAgB;AAEzB,OAAOC,YAAW;AAClB,OAAO,aAAa;;;ACLpB,OAAO,WAAW;AAIX,IAAM,UAAN,cAAsB,MAAM,OAAgB;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,OAAO,SAAuB;AAAA,IAC5B,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,YAAY;AAAA,MACV,IAAI,EAAE,MAAM,QAAQ,SAAS,GAAG;AAAA,MAChC,gBAAgB,EAAE,MAAM,UAAU,SAAS,IAAI,UAAU,KAAK;AAAA;AAAA;AAAA,MAG9D,UAAU;AAAA,Q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WACb,iBAAiB,UAAU,kBAAkB,IAC7C;AACJ,QAAM,WAAW,WAAW,eAAe,QAAQ,IAAI;AACvD,MAAI,YAAYC,YAAW,QAAQ,GAAG;AACpC,YAAQ,IAAI,gBAAgB,QAAQ,EAAE;AAAA,EACxC,OAAO;AACL,YAAQ,IAAI,wBAAwB,QAAQ,EAAE;AAAA,EAChD;AAGA,UAAQ,IAAI,gBAAgB,mBAAmB,SAAS,CAAC,EAAE,SAAS,KAAK,EAAE;AAC3E,cAAY,SAAS,YAAY,QAAQ,EAAE;AAE3C,QAAM,MAAM;AACZ,UAAQ,IAAI,mBAAmB,MAAM,QAAQ,EAAE;AAGjD;","names":["path","existsSync","Realm","Realm","Realm","Realm","Realm","Realm","Realm","path","Realm","path","path","Realm","existsSync"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/cli/main.ts","../../../src/realm/schema/beatmap.ts","../../../src/realm/schema/beatmapMetadata.ts","../../../src/realm/schema/beatmapSet.ts","../../../src/realm/schema/realmFile.ts","../../../src/realm/schema/realmUser.ts","../../../src/realm/schema/realmNamedFileUsage.ts","../../../src/utils/mod.ts","../../../src/realm/mod.ts"],"sourcesContent":["import path from \"node:path\";\nimport { existsSync } from \"node:fs\";\nimport { execFileSync } from \"node:child_process\";\n\nimport Realm from \"realm\";\nimport prompts from \"prompts\";\nimport { BeatmapSet } from \"../realm/schema/mod.js\";\nimport { getConfigDir, getDataDir, getRealmDBPath } from \"../utils/mod.js\";\nimport { getLazerDB, getNamedFileHash, hashedFilePath } from \"../realm/mod.js\";\n\nimport yargs from \"yargs/yargs\";\nimport { hideBin } from \"yargs/helpers\";\n\nexport function getArgs() {\n const argv = yargs(hideBin(process.argv))\n .usage(\"Play music from your osu!lazer beatmaps from the terminal\\nUsage: $0 [options]\")\n .options({\n reload: {\n type: \"boolean\",\n default: false,\n alias: \"r\",\n describe: \"Reload lazer database\",\n },\n osuDataDir: {\n type: \"string\",\n default: path.join(getDataDir() || \".\", \"osu\"),\n alias: \"d\",\n describe: \"Osu!lazer data directory\",\n },\n configDir: {\n type: \"string\",\n default: path.join(getConfigDir() || \".\", \"osu-play\"),\n alias: \"c\",\n describe: \"Config directory\",\n },\n loop: {\n type: \"boolean\",\n default: false,\n alias: \"l\",\n describe: \"Loop the playlist on end\",\n },\n }).argv;\n return argv;\n}\n\nexport async function main() {\n const argv = await getArgs();\n console.log(\"[INFO] OSU!list\");\n\n let reload = false;\n let osuDataDir = argv.osuDataDir;\n\n if (argv.reload) {\n console.log(\"[INFO] Reloading lazer database\");\n reload = true;\n }\n\n if (argv.osuDataDir !== getDataDir()) {\n console.log(`[INFO] Using osu!lazer data directory: ${argv.osuDataDir}`);\n }\n\n const realmDBPath = getRealmDBPath(argv.configDir, { reload, osuDataDir });\n\n if (realmDBPath == null) {\n console.log(\"[ERROR] Realm DB not found\");\n process.exit(1);\n }\n\n const currentSchema = Realm.schemaVersion(realmDBPath);\n console.log(`currentSchema: ${currentSchema}`);\n\n Realm.flags.ALLOW_CLEAR_TEST_STATE = true;\n\n const realm: Realm = await getLazerDB(realmDBPath);\n\n console.log(`realm.isClosed: ${realm.isClosed}`);\n\n const beatmapSets = realm.objects(BeatmapSet);\n\n const songSet = new Set<string>();\n const uniqueBeatmaps: {\n title: string;\n path: string | null;\n }[] = [];\n\n for (const beatmapSet of beatmapSets) {\n for (const beatmap of beatmapSet.Beatmaps) {\n const fileName = beatmap.Metadata.AudioFile;\n const hash = getNamedFileHash(fileName ?? \"\", beatmapSet);\n if (!hash) continue;\n if (songSet.has(hash)) continue;\n songSet.add(hash);\n const meta = beatmap.Metadata;\n const path = hashedFilePath(hash);\n const title = `${meta.Title} : ${meta.Artist} - ${meta.TitleUnicode} : ${meta.ArtistUnicode}`;\n uniqueBeatmaps.push({ title, path });\n }\n }\n\n console.log(`beatmap songs: ${beatmapSets.length}`);\n\n // Get the map index from the user\n let selectedBeatmap: number = (\n await prompts({\n type: \"autocomplete\",\n name: \"beatmap\",\n message: \"Which map do you want to play:\",\n choices: uniqueBeatmaps.map((mp, index) => ({\n title: mp.title,\n value: index,\n })),\n })\n ).beatmap;\n\n for (let i = selectedBeatmap; i < uniqueBeatmaps.length; ++i) {\n const beatmap = uniqueBeatmaps[i];\n console.log(`Map : ${beatmap.title}`);\n if (beatmap.path && existsSync(beatmap.path)) {\n // Open file using exo-open.\n console.log(`File exists: ${beatmap.path}`);\n console.log(`Playing ${beatmap.title}`);\n try {\n execFileSync(\"exo-open\", [beatmap.path]);\n } catch (err) {\n console.log(`Error: ${err}`);\n break;\n }\n } else {\n console.log(`File does not exist: ${beatmap.path}`);\n }\n if (i < uniqueBeatmaps.length - 1) {\n // Wait 1 second between\n await new Promise((resolve) => setTimeout(resolve, 1000));\n } else if (argv.loop) {\n console.log('[INFO] Looping playlist');\n i = 0;\n } else { \n console.log('[INFO] Done. Use --loop to loop the playlist');\n }\n }\n\n realm.close();\n console.log(`realm.isClosed: ${realm.isClosed}`);\n\n // Realm.clearTestState();\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { BeatmapMetadata } from \"./beatmapMetadata.js\";\n\nexport class Beatmap extends Realm.Object<Beatmap> {\n ID!: string;\n DifficultyName?: string;\n Ruleset!: any;\n Difficulty!: any;\n Metadata!: BeatmapMetadata;\n UserSettings!: any;\n BeatmapSet!: any;\n Status!: number;\n OnlineID!: number;\n Length!: number;\n BPM!: number;\n Hash?: string;\n StarRating!: number;\n MD5Hash?: string;\n OnlineMD5Hash?: string;\n LastLocalUpdate?: Date;\n LastOnlineUpdate?: Date;\n Hidden!: boolean;\n AudioLeadIn!: number;\n StackLeniency!: number;\n SpecialStyle!: boolean;\n LetterboxInBreaks!: boolean;\n WidescreenStoryboard!: boolean;\n EpilepsyWarning!: boolean;\n SamplesMatchPlaybackRate!: boolean;\n LastPlayed?: Date;\n DistanceSpacing!: number;\n BeatDivisor!: number;\n GridSize!: number;\n TimelineZoom!: number;\n EditorTimestamp?: number;\n CountdownOffset!: number;\n\n static schema: ObjectSchema = {\n name: \"Beatmap\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n DifficultyName: { type: \"string\", default: \"\", optional: true },\n // Ruleset: { type: \"object\", objectType: \"Ruleset\", default: null },\n // Difficulty: { type: \"object\", objectType: \"BeatmapDifficulty\", default: null },\n Metadata: {\n type: \"object\",\n objectType: \"BeatmapMetadata\",\n default: null,\n },\n // UserSettings: { type: \"object\", objectType: \"BeatmapUserSettings\", default: null },\n BeatmapSet: { type: \"object\", objectType: \"BeatmapSet\", default: null },\n Status: { type: \"int\", default: -3 },\n OnlineID: { type: \"int\", default: -1 },\n Length: { type: \"double\", default: 0 },\n BPM: { type: \"double\", default: 0 },\n Hash: { type: \"string\", default: \"\", optional: true },\n StarRating: { type: \"double\", default: -1 },\n MD5Hash: { type: \"string\", default: \"\", optional: true },\n OnlineMD5Hash: {\n type: \"string\",\n default: \"\",\n optional: true,\n },\n LastLocalUpdate: { type: \"date\", optional: true },\n LastOnlineUpdate: { type: \"date\", optional: true },\n Hidden: { type: \"bool\", default: false },\n AudioLeadIn: { type: \"double\", default: 0 },\n StackLeniency: { type: \"float\", default: 0.7 },\n SpecialStyle: { type: \"bool\", default: false },\n LetterboxInBreaks: { type: \"bool\", default: false },\n WidescreenStoryboard: { type: \"bool\", default: false },\n EpilepsyWarning: { type: \"bool\", default: false },\n SamplesMatchPlaybackRate: { type: \"bool\", default: false },\n LastPlayed: { type: \"date\", optional: true },\n DistanceSpacing: { type: \"double\", default: 0 },\n BeatDivisor: { type: \"int\", default: 0 },\n GridSize: { type: \"int\", default: 0 },\n TimelineZoom: { type: \"double\", default: 0 },\n EditorTimestamp: { type: \"double\", optional: true },\n CountdownOffset: { type: \"int\", default: 0 },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmUser } from \"./realmUser.js\";\n\nexport class BeatmapMetadata extends Realm.Object<BeatmapMetadata> {\n Title?: string;\n TitleUnicode?: string;\n Artist?: string;\n ArtistUnicode?: string;\n Author?: RealmUser;\n Source?: string;\n Tags?: string;\n PreviewTime?: number;\n AudioFile?: string;\n BackgroundFile?: string;\n\n static schema: ObjectSchema = {\n name: \"BeatmapMetadata\",\n properties: {\n Title: { type: \"string\", default: \"\", optional: true },\n TitleUnicode: { type: \"string\", default: \"\", optional: true },\n Artist: { type: \"string\", default: \"\", optional: true },\n ArtistUnicode: { type: \"string\", default: \"\", optional: true },\n Author: { type: \"object\", objectType: \"RealmUser\", default: null },\n Source: { type: \"string\", default: \"\", optional: true },\n Tags: { type: \"string\", default: \"\", optional: true },\n PreviewTime: { type: \"int\", default: 0 },\n AudioFile: { type: \"string\", default: \"\", optional: true },\n BackgroundFile: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { Beatmap } from \"./beatmap.js\";\nimport { RealmNamedFileUsage } from \"./realmNamedFileUsage.js\";\n\nexport class BeatmapSet extends Realm.Object<BeatmapSet> {\n ID!: string;\n OnlineID!: number;\n DateAdded!: Date;\n DateSubmitted?: Date;\n DateRanked?: Date;\n Beatmaps!: Array<Beatmap>;\n Files!: Array<RealmNamedFileUsage>;\n Status!: number;\n DeletePending!: boolean;\n Hash?: string;\n Protected!: boolean;\n\n static schema: ObjectSchema = {\n name: \"BeatmapSet\",\n primaryKey: \"ID\",\n properties: {\n ID: { type: \"uuid\", default: \"\" },\n OnlineID: { type: \"int\", default: -1 },\n DateAdded: { type: \"date\" },\n DateSubmitted: { type: \"date\", optional: true },\n DateRanked: { type: \"date\", optional: true },\n Beatmaps: { type: \"list\", objectType: \"Beatmap\", default: [] },\n Files: { type: \"list\", objectType: \"RealmNamedFileUsage\", default: [] },\n Status: { type: \"int\", default: -3 },\n DeletePending: { type: \"bool\", default: false },\n Hash: { type: \"string\", default: \"\", optional: true },\n Protected: { type: \"bool\", default: false },\n },\n };\n}\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmFile extends Realm.Object<RealmFile> {\n Hash?: string;\n\n static schema: ObjectSchema = {\n name: \"File\",\n primaryKey: \"Hash\",\n properties: {\n Hash: { type: \"string\", default: \"\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\n\nexport class RealmUser extends Realm.Object<RealmUser> {\n OnlineID!: number;\n Username?: string;\n CountryCode?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmUser\",\n embedded: true,\n properties: {\n OnlineID: { type: \"int\", default: 1 },\n Username: { type: \"string\", default: \"\", optional: true },\n CountryCode: { type: \"string\", optional: true },\n },\n };\n}\n\n","import Realm from \"realm\";\nimport type { ObjectSchema } from \"realm\";\nimport { RealmFile } from \"./realmFile.js\";\n\nexport class RealmNamedFileUsage extends Realm.Object<RealmNamedFileUsage> {\n File!: RealmFile;\n Filename?: string;\n\n static embedded = true;\n\n static schema: ObjectSchema = {\n name: \"RealmNamedFileUsage\",\n embedded: true,\n properties: {\n File: \"File\",\n Filename: { type: \"string\", optional: true },\n },\n };\n}\n","import path from \"node:path\";\nimport { copyFileSync, existsSync, mkdirSync } from \"node:fs\";\n\nexport function getDataDir(): string | undefined {\n switch (process.platform) {\n case \"linux\":\n case \"openbsd\":\n case \"freebsd\": {\n const xdg = process.env[\"XDG_DATA_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".local\", \"share\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Application Support\");\n break;\n }\n\n case \"win32\":\n return process.env[\"LOCALAPPDATA\"] ?? undefined;\n }\n\n return undefined;\n}\n\nexport function getConfigDir(): string | undefined {\n switch (process.platform) {\n case \"openbsd\":\n case \"freebsd\":\n case \"linux\": {\n const xdg = process.env[\"XDG_CONFIG_HOME\"];\n if (xdg) return xdg;\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \".config\");\n break;\n }\n\n case \"darwin\": {\n const home = process.env[\"HOME\"];\n if (home) return path.join(home, \"Library\", \"Preferences\");\n break;\n }\n\n case \"win32\":\n return process.env[\"APPDATA\"] ?? undefined;\n }\n\n return undefined;\n}\n\n/**\n * Get Realm for the app, import to the config if it doesn't exist\n */\nexport function getRealmDBPath(\n appConfigDir: string,\n options: {\n osuDataDir: string;\n reload: boolean;\n } = { reload: false, osuDataDir: getDataDir() || \".\" },\n) {\n const localDBPath = path.join(appConfigDir, \"client.realm\");\n if (!options.reload && existsSync(localDBPath)) return localDBPath;\n\n const osuDBPath = path.join(options.osuDataDir, \"client.realm\");\n if (existsSync(osuDBPath)) {\n console.log( `[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`);\n mkdirSync(appConfigDir, { recursive: true });\n copyFileSync(osuDBPath, localDBPath );\n return localDBPath;\n } else {\n console.log(`[getRealmDBPath]: ${osuDBPath} not found`);\n return null;\n }\n}\n","import Realm from \"realm\";\nimport path from \"node:path\";\nimport { getDataDir } from \"../utils/mod.js\";\nimport {\n Beatmap,\n BeatmapMetadata,\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n RealmUser,\n} from \"./schema/mod.js\";\n\nexport const getLazerDB = async (realmDBPath: string) => {\n const realm = await Realm.open({\n schema: [\n BeatmapSet,\n RealmFile,\n RealmNamedFileUsage,\n Beatmap,\n BeatmapMetadata,\n RealmUser,\n ],\n path: realmDBPath,\n schemaVersion: 36,\n onMigration: (oldRealm, newRealm) => {\n console.log(\n `[onMigration]: Migrating ${oldRealm.path} - ${oldRealm.schemaVersion} -> ${newRealm.path} - ${newRealm.schemaVersion}`,\n );\n },\n });\n\n return realm;\n};\n\nexport const hashedFilePath = (hash: string) => {\n const dataDir = getDataDir();\n if (!dataDir) return null;\n return path.join(\n dataDir,\n \"osu\",\n \"files\",\n hash.slice(0, 1),\n hash.slice(0, 2),\n hash,\n );\n};\n\nexport const getNamedFileHash = (fileName: string, beatmapSet: BeatmapSet) => {\n const files = beatmapSet.Files;\n for (const file of files) {\n if (file.Filename == fileName) return file.File.Hash;\n }\n return undefined;\n};\n"],"mappings":";AAAA,OAAOA,WAAU;AACjB,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,oBAAoB;AAE7B,OAAOC,YAAW;AAClB,OAAO,aAAa;;;ACLpB,OAAO,WAAW;AAIX,IAAM,UAAN,cAAsB,MAAM,OAAgB;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,OAAO,SAAuB;AAAA,IAC5B,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,YAAY;AAAA,MACV,IAAI,EAAE,MAAM,QAAQ,SAAS,GAAG;AAAA,MAChC,gBAAgB,EAAE,MAAM,UAAU,SAAS,IAAI,UAAU,KAAK;AAAA;AAAA;AAAA,MAG9D,UAAU;AAAA,QACR,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,SAAS;AAAA,MACX;AAAA;AAAA,MAEA,YAAY,EAAE,MAAM,UAAU,YAAY,cAAc,SAAS,KAAK;AAAA,MACtE,QAAQ,EAAE,MAAM,OAAO,SAAS,GAAG;AAAA,MACnC,UAAU,EAAE,MAAM,OAAO,SAAS,GAAG;AAAA,MACrC,QAAQ,EAAE,MAAM,UAAU,SAAS,EAAE;AAAA,MACrC,KAAK,EAAE,MAAM,UAAU,SAAS,EAAE;AAAA,MAClC,MAAM,EAAE,MAAM,UAAU,SAAS,IAAI,UAAU,KAAK;AAAA,MACpD,YAAY,EAAE,MAAM,UAAU,S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AG;AAEjC,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAI,CAAC;AAAA,IAC1D,WAAW,KAAK,MAAM;AACpB,cAAQ,IAAI,yBAAyB;AACrC,UAAI;AAAA,IACN,OAAO;AACL,cAAQ,IAAI,8CAA8C;AAAA,IAC5D;AAAA,EACF;AAEA,QAAM,MAAM;AACZ,UAAQ,IAAI,mBAAmB,MAAM,QAAQ,EAAE;AAGjD;","names":["path","existsSync","Realm","Realm","Realm","Realm","Realm","Realm","Realm","path","Realm","path","path","Realm","existsSync"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "osu-play",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Play music from your osu!lazer beatmaps from the terminal.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "bin/osu-play.js",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"typescript": "^5.2.2"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
+
"@types/yargs": "^17.0.29",
|
|
38
39
|
"prompts": "^2.4.2",
|
|
39
40
|
"realm": "^12.2.1",
|
|
40
41
|
"yargs": "^17.7.2"
|
package/src/cli/main.ts
CHANGED
|
@@ -1,19 +1,65 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { execFileSync } from "node:child_process";
|
|
4
4
|
|
|
5
5
|
import Realm from "realm";
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
import { BeatmapSet } from "../realm/schema/mod.js";
|
|
8
|
-
import { getConfigDir, getRealmDBPath } from "../utils/mod.js";
|
|
8
|
+
import { getConfigDir, getDataDir, getRealmDBPath } from "../utils/mod.js";
|
|
9
9
|
import { getLazerDB, getNamedFileHash, hashedFilePath } from "../realm/mod.js";
|
|
10
10
|
|
|
11
|
+
import yargs from "yargs/yargs";
|
|
12
|
+
import { hideBin } from "yargs/helpers";
|
|
13
|
+
|
|
14
|
+
export function getArgs() {
|
|
15
|
+
const argv = yargs(hideBin(process.argv))
|
|
16
|
+
.usage("Play music from your osu!lazer beatmaps from the terminal\nUsage: $0 [options]")
|
|
17
|
+
.options({
|
|
18
|
+
reload: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
default: false,
|
|
21
|
+
alias: "r",
|
|
22
|
+
describe: "Reload lazer database",
|
|
23
|
+
},
|
|
24
|
+
osuDataDir: {
|
|
25
|
+
type: "string",
|
|
26
|
+
default: path.join(getDataDir() || ".", "osu"),
|
|
27
|
+
alias: "d",
|
|
28
|
+
describe: "Osu!lazer data directory",
|
|
29
|
+
},
|
|
30
|
+
configDir: {
|
|
31
|
+
type: "string",
|
|
32
|
+
default: path.join(getConfigDir() || ".", "osu-play"),
|
|
33
|
+
alias: "c",
|
|
34
|
+
describe: "Config directory",
|
|
35
|
+
},
|
|
36
|
+
loop: {
|
|
37
|
+
type: "boolean",
|
|
38
|
+
default: false,
|
|
39
|
+
alias: "l",
|
|
40
|
+
describe: "Loop the playlist on end",
|
|
41
|
+
},
|
|
42
|
+
}).argv;
|
|
43
|
+
return argv;
|
|
44
|
+
}
|
|
45
|
+
|
|
11
46
|
export async function main() {
|
|
47
|
+
const argv = await getArgs();
|
|
12
48
|
console.log("[INFO] OSU!list");
|
|
13
49
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
50
|
+
let reload = false;
|
|
51
|
+
let osuDataDir = argv.osuDataDir;
|
|
52
|
+
|
|
53
|
+
if (argv.reload) {
|
|
54
|
+
console.log("[INFO] Reloading lazer database");
|
|
55
|
+
reload = true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (argv.osuDataDir !== getDataDir()) {
|
|
59
|
+
console.log(`[INFO] Using osu!lazer data directory: ${argv.osuDataDir}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const realmDBPath = getRealmDBPath(argv.configDir, { reload, osuDataDir });
|
|
17
63
|
|
|
18
64
|
if (realmDBPath == null) {
|
|
19
65
|
console.log("[ERROR] Realm DB not found");
|
|
@@ -31,40 +77,67 @@ export async function main() {
|
|
|
31
77
|
|
|
32
78
|
const beatmapSets = realm.objects(BeatmapSet);
|
|
33
79
|
|
|
34
|
-
|
|
80
|
+
const songSet = new Set<string>();
|
|
81
|
+
const uniqueBeatmaps: {
|
|
82
|
+
title: string;
|
|
83
|
+
path: string | null;
|
|
84
|
+
}[] = [];
|
|
85
|
+
|
|
86
|
+
for (const beatmapSet of beatmapSets) {
|
|
87
|
+
for (const beatmap of beatmapSet.Beatmaps) {
|
|
88
|
+
const fileName = beatmap.Metadata.AudioFile;
|
|
89
|
+
const hash = getNamedFileHash(fileName ?? "", beatmapSet);
|
|
90
|
+
if (!hash) continue;
|
|
91
|
+
if (songSet.has(hash)) continue;
|
|
92
|
+
songSet.add(hash);
|
|
93
|
+
const meta = beatmap.Metadata;
|
|
94
|
+
const path = hashedFilePath(hash);
|
|
95
|
+
const title = `${meta.Title} : ${meta.Artist} - ${meta.TitleUnicode} : ${meta.ArtistUnicode}`;
|
|
96
|
+
uniqueBeatmaps.push({ title, path });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log(`beatmap songs: ${beatmapSets.length}`);
|
|
35
101
|
|
|
36
102
|
// Get the map index from the user
|
|
37
|
-
|
|
103
|
+
let selectedBeatmap: number = (
|
|
38
104
|
await prompts({
|
|
39
105
|
type: "autocomplete",
|
|
40
|
-
name: "
|
|
106
|
+
name: "beatmap",
|
|
41
107
|
message: "Which map do you want to play:",
|
|
42
|
-
choices:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`${meta.Title} : ${meta.Artist} - ${meta.TitleUnicode} : ${meta.ArtistUnicode}`,
|
|
47
|
-
value: beatmapSet,
|
|
48
|
-
};
|
|
49
|
-
}),
|
|
108
|
+
choices: uniqueBeatmaps.map((mp, index) => ({
|
|
109
|
+
title: mp.title,
|
|
110
|
+
value: index,
|
|
111
|
+
})),
|
|
50
112
|
})
|
|
51
|
-
).
|
|
52
|
-
|
|
53
|
-
console.log(`Map : ${selectedBeatmapSet.Beatmaps[0].Metadata.Title}`);
|
|
54
|
-
const fileName = selectedBeatmapSet.Beatmaps[0].Metadata.AudioFile;
|
|
55
|
-
const fileHash = fileName
|
|
56
|
-
? getNamedFileHash(fileName, selectedBeatmapSet)
|
|
57
|
-
: undefined;
|
|
58
|
-
const filePath = fileHash ? hashedFilePath(fileHash) : undefined;
|
|
59
|
-
if (filePath && existsSync(filePath)) {
|
|
60
|
-
console.log(`File exists: ${filePath}`);
|
|
61
|
-
} else {
|
|
62
|
-
console.log(`File does not exist: ${filePath}`);
|
|
63
|
-
}
|
|
113
|
+
).beatmap;
|
|
64
114
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
115
|
+
for (let i = selectedBeatmap; i < uniqueBeatmaps.length; ++i) {
|
|
116
|
+
const beatmap = uniqueBeatmaps[i];
|
|
117
|
+
console.log(`Map : ${beatmap.title}`);
|
|
118
|
+
if (beatmap.path && existsSync(beatmap.path)) {
|
|
119
|
+
// Open file using exo-open.
|
|
120
|
+
console.log(`File exists: ${beatmap.path}`);
|
|
121
|
+
console.log(`Playing ${beatmap.title}`);
|
|
122
|
+
try {
|
|
123
|
+
execFileSync("exo-open", [beatmap.path]);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.log(`Error: ${err}`);
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
console.log(`File does not exist: ${beatmap.path}`);
|
|
130
|
+
}
|
|
131
|
+
if (i < uniqueBeatmaps.length - 1) {
|
|
132
|
+
// Wait 1 second between
|
|
133
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
134
|
+
} else if (argv.loop) {
|
|
135
|
+
console.log('[INFO] Looping playlist');
|
|
136
|
+
i = 0;
|
|
137
|
+
} else {
|
|
138
|
+
console.log('[INFO] Done. Use --loop to loop the playlist');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
68
141
|
|
|
69
142
|
realm.close();
|
|
70
143
|
console.log(`realm.isClosed: ${realm.isClosed}`);
|
package/src/utils/mod.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { copyFileSync, existsSync, mkdirSync } from "node:fs";
|
|
3
3
|
|
|
4
|
-
export function getDataDir(): string |
|
|
4
|
+
export function getDataDir(): string | undefined {
|
|
5
5
|
switch (process.platform) {
|
|
6
6
|
case "linux":
|
|
7
7
|
case "openbsd":
|
|
@@ -20,13 +20,13 @@ export function getDataDir(): string | null {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
case "win32":
|
|
23
|
-
return process.env["LOCALAPPDATA"] ??
|
|
23
|
+
return process.env["LOCALAPPDATA"] ?? undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
return
|
|
26
|
+
return undefined;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function getConfigDir(): string |
|
|
29
|
+
export function getConfigDir(): string | undefined {
|
|
30
30
|
switch (process.platform) {
|
|
31
31
|
case "openbsd":
|
|
32
32
|
case "freebsd":
|
|
@@ -45,10 +45,10 @@ export function getConfigDir(): string | null {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
case "win32":
|
|
48
|
-
return process.env["APPDATA"] ??
|
|
48
|
+
return process.env["APPDATA"] ?? undefined;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
return
|
|
51
|
+
return undefined;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -56,23 +56,19 @@ export function getConfigDir(): string | null {
|
|
|
56
56
|
*/
|
|
57
57
|
export function getRealmDBPath(
|
|
58
58
|
appConfigDir: string,
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
options: {
|
|
60
|
+
osuDataDir: string;
|
|
61
|
+
reload: boolean;
|
|
62
|
+
} = { reload: false, osuDataDir: getDataDir() || "." },
|
|
61
63
|
) {
|
|
62
64
|
const localDBPath = path.join(appConfigDir, "client.realm");
|
|
63
|
-
if (!reload && existsSync(localDBPath)) return localDBPath;
|
|
65
|
+
if (!options.reload && existsSync(localDBPath)) return localDBPath;
|
|
64
66
|
|
|
65
|
-
const osuDBPath = path.join(
|
|
66
|
-
osuDataDir || getDataDir()! || ".",
|
|
67
|
-
"osu",
|
|
68
|
-
"client.realm",
|
|
69
|
-
);
|
|
67
|
+
const osuDBPath = path.join(options.osuDataDir, "client.realm");
|
|
70
68
|
if (existsSync(osuDBPath)) {
|
|
71
|
-
console.log(
|
|
72
|
-
|
|
73
|
-
);
|
|
74
|
-
mkdirSync(appConfigDir);
|
|
75
|
-
copyFileSync(osuDBPath, localDBPath);
|
|
69
|
+
console.log( `[getRealmDBPath]: ${osuDBPath} is being imported from osu!lazer to ${localDBPath}`);
|
|
70
|
+
mkdirSync(appConfigDir, { recursive: true });
|
|
71
|
+
copyFileSync(osuDBPath, localDBPath );
|
|
76
72
|
return localDBPath;
|
|
77
73
|
} else {
|
|
78
74
|
console.log(`[getRealmDBPath]: ${osuDBPath} not found`);
|