fluncle 0.137.0 → 0.138.0

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.
Files changed (2) hide show
  1. package/bin/fluncle.mjs +81 -3
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -561,7 +561,7 @@ function parseVersion(version) {
561
561
  var currentVersion;
562
562
  var init_version = __esm(() => {
563
563
  init_output();
564
- currentVersion = "0.137.0".trim() ? "0.137.0".trim() : "0.1.0";
564
+ currentVersion = "0.138.0".trim() ? "0.138.0".trim() : "0.1.0";
565
565
  });
566
566
 
567
567
  // src/update-notifier.ts
@@ -2189,7 +2189,7 @@ function parseVersion2(version) {
2189
2189
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2190
2190
  var init_version2 = __esm(() => {
2191
2191
  init_output();
2192
- currentVersion2 = "0.137.0".trim() ? "0.137.0".trim() : "0.1.0";
2192
+ currentVersion2 = "0.138.0".trim() ? "0.138.0".trim() : "0.1.0";
2193
2193
  });
2194
2194
 
2195
2195
  // ../../packages/registry/src/index.ts
@@ -3654,7 +3654,8 @@ __export(exports_admin_tracks, {
3654
3654
  contextQueueCommand: () => contextQueueCommand,
3655
3655
  captureQueueCommand: () => captureQueueCommand,
3656
3656
  backfillLastfmCommand: () => backfillLastfmCommand,
3657
- backfillDiscogsCommand: () => backfillDiscogsCommand
3657
+ backfillDiscogsCommand: () => backfillDiscogsCommand,
3658
+ backfillAppleMusicCommand: () => backfillAppleMusicCommand
3658
3659
  });
3659
3660
  async function fetchAdminTracks(options) {
3660
3661
  const {
@@ -3827,6 +3828,13 @@ async function backfillDiscogsCommand(limit, dryRun, cursor) {
3827
3828
  }
3828
3829
  return adminApiPost(`/api/admin/backfill/discogs?${params.toString()}`);
3829
3830
  }
3831
+ async function backfillAppleMusicCommand(limit, dryRun, cursor) {
3832
+ const params = new URLSearchParams({ dryRun: String(dryRun), limit: String(limit) });
3833
+ if (cursor) {
3834
+ params.set("cursor", cursor);
3835
+ }
3836
+ return adminApiPost(`/api/admin/backfill/apple-music?${params.toString()}`);
3837
+ }
3830
3838
  async function vehiclesCommand(limit) {
3831
3839
  const tracks = await fetchAdminTracks({ hasVideo: true, max: limit, order: "desc" });
3832
3840
  return tracks.map((track) => ({
@@ -8770,6 +8778,10 @@ function addAdminCommands(program2) {
8770
8778
  const { backfillDiscogsCommand: backfillDiscogsCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
8771
8779
  await runBackfillDiscogs(options, backfillDiscogsCommand2);
8772
8780
  });
8781
+ backfill.command("apple-music").description("Resolve missing Apple Music URLs for published findings (exact ISRC match)").option("--dry-run", "Report the eligible set without resolving or writing", false).option("--limit <limit>", "Max findings to resolve", "50").option("--json", "Print JSON", false).action(async (options) => {
8782
+ const { backfillAppleMusicCommand: backfillAppleMusicCommand2 } = await Promise.resolve().then(() => (init_admin_tracks(), exports_admin_tracks));
8783
+ await runBackfillAppleMusic(options, backfillAppleMusicCommand2);
8784
+ });
8773
8785
  backfill.command("artists").description("Back-fill the artist entity (artists + track_artists) for existing findings").option("--dry-run", "Report which findings would be upserted without touching the DB", false).option("--limit <limit>", "Max findings to process", "50").option("--json", "Print JSON", false).action(async (options) => {
8774
8786
  const { backfillArtistsCommand: backfillArtistsCommand2 } = await Promise.resolve().then(() => (init_admin_artists(), exports_admin_artists));
8775
8787
  await runBackfillArtists(options, backfillArtistsCommand2);
@@ -9181,6 +9193,72 @@ async function runBackfillDiscogs(options, backfillDiscogsCommand2) {
9181
9193
  console.log(` ${item.logId}: release ${item.releaseId}${master}`);
9182
9194
  }
9183
9195
  }
9196
+ async function runBackfillAppleMusic(options, backfillAppleMusicCommand2) {
9197
+ const limit = parseListLimit(options.limit);
9198
+ const resolved = [];
9199
+ const unresolved = [];
9200
+ const failed = [];
9201
+ const skipped = [];
9202
+ let cursor;
9203
+ let dryRun = options.dryRun;
9204
+ let throttled = false;
9205
+ let configured = true;
9206
+ while (resolved.length + unresolved.length + failed.length < limit) {
9207
+ const remaining = limit - (resolved.length + unresolved.length + failed.length);
9208
+ const result = await backfillAppleMusicCommand2(remaining, options.dryRun, cursor);
9209
+ dryRun = result.dryRun;
9210
+ configured = result.configured;
9211
+ resolved.push(...result.resolved);
9212
+ unresolved.push(...result.unresolved);
9213
+ failed.push(...result.failed);
9214
+ skipped.push(...result.skipped);
9215
+ if (!options.json) {
9216
+ const verb2 = result.dryRun ? "would resolve" : "resolved";
9217
+ console.log(` \u2026${verb2} ${result.resolvedCount}; ${result.unresolvedCount} unresolved; ${result.failedCount} failed; ${result.skippedCount} skipped`);
9218
+ }
9219
+ if (!result.configured) {
9220
+ break;
9221
+ }
9222
+ if (result.rateLimited) {
9223
+ throttled = true;
9224
+ break;
9225
+ }
9226
+ if (result.nextCursor === null) {
9227
+ break;
9228
+ }
9229
+ cursor = result.nextCursor;
9230
+ }
9231
+ if (options.json) {
9232
+ printSweepJson({
9233
+ configured,
9234
+ dryRun,
9235
+ failed,
9236
+ rateLimited: throttled,
9237
+ resolved,
9238
+ resolvedCount: resolved.length,
9239
+ skipped,
9240
+ skippedCount: skipped.length,
9241
+ unresolved,
9242
+ unresolvedCount: unresolved.length
9243
+ }, failed.length);
9244
+ return;
9245
+ }
9246
+ if (!configured) {
9247
+ console.log("Apple Music backfill is not configured (the Worker's MusicKit secrets are unset) \u2014 nothing resolved.");
9248
+ return;
9249
+ }
9250
+ const verb = dryRun ? "Would resolve" : "Resolved";
9251
+ console.log(`${verb} ${resolved.length} Apple Music URL(s); ${unresolved.length} unresolved; ${failed.length} failed; ${skipped.length} skipped.`);
9252
+ for (const item of resolved) {
9253
+ console.log(` ${item.logId}: ${item.url}`);
9254
+ }
9255
+ for (const item of failed) {
9256
+ console.log(` ${item.logId}: ${item.error}`);
9257
+ }
9258
+ if (failed.length > 0) {
9259
+ process.exitCode = 1;
9260
+ }
9261
+ }
9184
9262
  async function runBackfillArtists(options, backfillArtistsCommand2) {
9185
9263
  const limit = parseListLimit(options.limit);
9186
9264
  const upserted = [];
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.137.0"
34
+ "version": "0.138.0"
35
35
  }