fluncle 0.77.0 → 0.78.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 +28 -106
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -482,6 +482,20 @@ function resolveClipTracks(options) {
482
482
  startMs: member.startMs
483
483
  }));
484
484
  }
485
+ function mixcloudSections(members) {
486
+ return members.filter((member) => member.startMs != null).sort((a, b) => a.startMs - b.startMs).map((member) => ({
487
+ artist: member.artists.join(", "),
488
+ song: member.title,
489
+ start_time: Math.floor(member.startMs / 1000)
490
+ }));
491
+ }
492
+ function mixcloudSectionFields(sections) {
493
+ return sections.flatMap((section, index) => [
494
+ [`sections-${index}-artist`, section.artist],
495
+ [`sections-${index}-song`, section.song],
496
+ [`sections-${index}-start_time`, String(section.start_time)]
497
+ ]);
498
+ }
485
499
  function baseTitleMatches(findingTitle, candidateTitle) {
486
500
  const want = new Set(tokenize(stripVersionSuffix(findingTitle)));
487
501
  const have = new Set(tokenize(stripVersionSuffix(candidateTitle)));
@@ -544,7 +558,7 @@ function parseVersion(version) {
544
558
  var currentVersion;
545
559
  var init_version = __esm(() => {
546
560
  init_output();
547
- currentVersion = "0.77.0".trim() ? "0.77.0".trim() : "0.1.0";
561
+ currentVersion = "0.78.0".trim() ? "0.78.0".trim() : "0.1.0";
548
562
  });
549
563
 
550
564
  // src/update-notifier.ts
@@ -1196,9 +1210,6 @@ var exports_mixtape_mixcloud = {};
1196
1210
  __export(exports_mixtape_mixcloud, {
1197
1211
  resyncMixcloud: () => resyncMixcloud,
1198
1212
  mixtapeDescription: () => mixtapeDescription,
1199
- mixcloudSections: () => mixcloudSections,
1200
- mixcloudSectionFields: () => mixcloudSectionFields,
1201
- mixcloudEditUrl: () => mixcloudEditUrl,
1202
1213
  distributeMixcloud: () => distributeMixcloud,
1203
1214
  authMixcloudCommand: () => authMixcloudCommand
1204
1215
  });
@@ -1259,34 +1270,9 @@ async function distributeMixcloud(mixtapeId, audioPath, onProgress, unlisted = f
1259
1270
  });
1260
1271
  return { url };
1261
1272
  }
1262
- async function resyncMixcloud(mixtapeId, onProgress) {
1263
- const token = await fetchMixcloudToken();
1264
- const mixtape = await mixtapeGetCommand(mixtapeId);
1265
- const sections = mixcloudSections(mixtape.members);
1266
- if (sections.length === 0) {
1267
- throw new CliError2("mixcloud_no_cues", "No cued members to sync — mark cues on the mixtape first.");
1268
- }
1269
- const social = await adminApiGet(`/api/admin/mixtapes/${encodeURIComponent(mixtapeId)}/social`);
1270
- const mixcloud = social.posts.find((post) => post.platform === "mixcloud");
1271
- const key = mixcloud?.externalId;
1272
- if (!key) {
1273
- throw new CliError2("mixcloud_not_distributed", "No Mixcloud cloudcast to re-sync — distribute the mixtape first.");
1274
- }
1275
- const form = new FormData;
1276
- for (const [name, value] of mixcloudSectionFields(sections)) {
1277
- form.append(name, value);
1278
- }
1279
- onProgress?.(`Mixcloud: re-syncing ${sections.length} sections (no re-upload)…`);
1280
- const response = await fetch(`${mixcloudEditUrl(key)}?access_token=${encodeURIComponent(token)}`, { body: form, method: "POST" });
1281
- const text = await response.text();
1282
- if (!response.ok) {
1283
- throwMixcloudError(response.status, text);
1284
- }
1285
- const result = parseUploadResult(text);
1286
- if (!result.success) {
1287
- throw new CliError2("mixcloud_edit_rejected", `Mixcloud rejected the section edit: ${result.message ?? text.slice(0, 300)}`);
1288
- }
1289
- return { url: mixcloud?.url ?? `https://www.mixcloud.com${key}` };
1273
+ async function resyncMixcloud(mixtapeId) {
1274
+ const response = await adminApiPost(`/api/admin/mixtapes/${encodeURIComponent(mixtapeId)}/mixcloud/resync`);
1275
+ return { url: response.url };
1290
1276
  }
1291
1277
  async function authMixcloudCommand() {
1292
1278
  const response = await adminApiGet("/api/admin/mixcloud/auth/start");
@@ -1311,25 +1297,6 @@ ${breadcrumb}` : breadcrumb;
1311
1297
 
1312
1298
  ${breadcrumb}` : breadcrumb;
1313
1299
  }
1314
- function mixcloudSections(members) {
1315
- return members.filter((member) => typeof member.startMs === "number").sort((a, b) => a.startMs - b.startMs).map((member) => ({
1316
- artist: member.artists.join(", "),
1317
- song: member.title,
1318
- start_time: Math.floor(member.startMs / 1000)
1319
- }));
1320
- }
1321
- function mixcloudSectionFields(sections) {
1322
- return sections.flatMap((section, index) => [
1323
- [`sections-${index}-artist`, section.artist],
1324
- [`sections-${index}-song`, section.song],
1325
- [`sections-${index}-start_time`, String(section.start_time)]
1326
- ]);
1327
- }
1328
- function mixcloudEditUrl(key) {
1329
- const withLeading = key.startsWith("/") ? key : `/${key}`;
1330
- const path2 = withLeading.endsWith("/") ? withLeading : `${withLeading}/`;
1331
- return `${MIXCLOUD_API}/upload${path2}edit/`;
1332
- }
1333
1300
  function mixtapeTags(_mixtape) {
1334
1301
  return ["Drum & Bass", "Fluncle"];
1335
1302
  }
@@ -1374,6 +1341,7 @@ function throwMixcloudError(status, body) {
1374
1341
  }
1375
1342
  var MIXCLOUD_API = "https://api.mixcloud.com", DESCRIPTION_MAX = 1000, PICTURE_MAX_BYTES, COVER_BASE = "https://www.fluncle.com/api/mixtape-cover";
1376
1343
  var init_mixtape_mixcloud = __esm(() => {
1344
+ init_util();
1377
1345
  init_api();
1378
1346
  init_output();
1379
1347
  init_mixtape_api();
@@ -1695,7 +1663,7 @@ async function mixtapeResyncCommand(idOrLogId, options, onProgress = () => {}) {
1695
1663
  if (doMixcloud) {
1696
1664
  onProgress("Mixcloud: re-syncing sections…");
1697
1665
  const { resyncMixcloud: resyncMixcloud2 } = await Promise.resolve().then(() => (init_mixtape_mixcloud(), exports_mixtape_mixcloud));
1698
- const result = await resyncMixcloud2(mixtapeId, onProgress);
1666
+ const result = await resyncMixcloud2(mixtapeId);
1699
1667
  results.push({ platform: "mixcloud", url: result.url });
1700
1668
  onProgress(`Mixcloud: ${result.url}`);
1701
1669
  }
@@ -2487,7 +2455,7 @@ function parseVersion2(version) {
2487
2455
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
2488
2456
  var init_version2 = __esm(() => {
2489
2457
  init_output();
2490
- currentVersion2 = "0.77.0".trim() ? "0.77.0".trim() : "0.1.0";
2458
+ currentVersion2 = "0.78.0".trim() ? "0.78.0".trim() : "0.1.0";
2491
2459
  });
2492
2460
 
2493
2461
  // ../../packages/registry/src/index.ts
@@ -4018,7 +3986,7 @@ async function mixtapeResyncCommand2(idOrLogId, options, onProgress = () => {})
4018
3986
  if (doMixcloud) {
4019
3987
  onProgress("Mixcloud: re-syncing sections…");
4020
3988
  const { resyncMixcloud: resyncMixcloud2 } = await Promise.resolve().then(() => (init_mixtape_mixcloud(), exports_mixtape_mixcloud));
4021
- const result = await resyncMixcloud2(mixtapeId, onProgress);
3989
+ const result = await resyncMixcloud2(mixtapeId);
4022
3990
  results.push({ platform: "mixcloud", url: result.url });
4023
3991
  onProgress(`Mixcloud: ${result.url}`);
4024
3992
  }
@@ -4612,9 +4580,6 @@ var exports_mixtape_mixcloud2 = {};
4612
4580
  __export(exports_mixtape_mixcloud2, {
4613
4581
  resyncMixcloud: () => resyncMixcloud2,
4614
4582
  mixtapeDescription: () => mixtapeDescription2,
4615
- mixcloudSections: () => mixcloudSections2,
4616
- mixcloudSectionFields: () => mixcloudSectionFields2,
4617
- mixcloudEditUrl: () => mixcloudEditUrl2,
4618
4583
  distributeMixcloud: () => distributeMixcloud2,
4619
4584
  authMixcloudCommand: () => authMixcloudCommand2
4620
4585
  });
@@ -4641,8 +4606,8 @@ async function distributeMixcloud2(mixtapeId, audioPath, onProgress, unlisted =
4641
4606
  for (const [index, tag] of mixtapeTags2(mixtape).entries()) {
4642
4607
  form.append(`tags-${index}-tag`, tag);
4643
4608
  }
4644
- const sections = mixcloudSections2(mixtape.members);
4645
- for (const [name, value] of mixcloudSectionFields2(sections)) {
4609
+ const sections = mixcloudSections(mixtape.members);
4610
+ for (const [name, value] of mixcloudSectionFields(sections)) {
4646
4611
  form.append(name, value);
4647
4612
  }
4648
4613
  if (unlisted) {
@@ -4675,34 +4640,9 @@ async function distributeMixcloud2(mixtapeId, audioPath, onProgress, unlisted =
4675
4640
  });
4676
4641
  return { url };
4677
4642
  }
4678
- async function resyncMixcloud2(mixtapeId, onProgress) {
4679
- const token = await fetchMixcloudToken2();
4680
- const mixtape = await mixtapeGetCommand(mixtapeId);
4681
- const sections = mixcloudSections2(mixtape.members);
4682
- if (sections.length === 0) {
4683
- throw new CliError2("mixcloud_no_cues", "No cued members to sync — mark cues on the mixtape first.");
4684
- }
4685
- const social = await adminApiGet(`/api/admin/mixtapes/${encodeURIComponent(mixtapeId)}/social`);
4686
- const mixcloud = social.posts.find((post) => post.platform === "mixcloud");
4687
- const key = mixcloud?.externalId;
4688
- if (!key) {
4689
- throw new CliError2("mixcloud_not_distributed", "No Mixcloud cloudcast to re-sync — distribute the mixtape first.");
4690
- }
4691
- const form = new FormData;
4692
- for (const [name, value] of mixcloudSectionFields2(sections)) {
4693
- form.append(name, value);
4694
- }
4695
- onProgress?.(`Mixcloud: re-syncing ${sections.length} sections (no re-upload)…`);
4696
- const response = await fetch(`${mixcloudEditUrl2(key)}?access_token=${encodeURIComponent(token)}`, { body: form, method: "POST" });
4697
- const text = await response.text();
4698
- if (!response.ok) {
4699
- throwMixcloudError2(response.status, text);
4700
- }
4701
- const result = parseUploadResult2(text);
4702
- if (!result.success) {
4703
- throw new CliError2("mixcloud_edit_rejected", `Mixcloud rejected the section edit: ${result.message ?? text.slice(0, 300)}`);
4704
- }
4705
- return { url: mixcloud?.url ?? `https://www.mixcloud.com${key}` };
4643
+ async function resyncMixcloud2(mixtapeId) {
4644
+ const response = await adminApiPost(`/api/admin/mixtapes/${encodeURIComponent(mixtapeId)}/mixcloud/resync`);
4645
+ return { url: response.url };
4706
4646
  }
4707
4647
  async function authMixcloudCommand2() {
4708
4648
  const response = await adminApiGet("/api/admin/mixcloud/auth/start");
@@ -4727,25 +4667,6 @@ ${breadcrumb}` : breadcrumb;
4727
4667
 
4728
4668
  ${breadcrumb}` : breadcrumb;
4729
4669
  }
4730
- function mixcloudSections2(members) {
4731
- return members.filter((member) => typeof member.startMs === "number").sort((a, b) => a.startMs - b.startMs).map((member) => ({
4732
- artist: member.artists.join(", "),
4733
- song: member.title,
4734
- start_time: Math.floor(member.startMs / 1000)
4735
- }));
4736
- }
4737
- function mixcloudSectionFields2(sections) {
4738
- return sections.flatMap((section, index) => [
4739
- [`sections-${index}-artist`, section.artist],
4740
- [`sections-${index}-song`, section.song],
4741
- [`sections-${index}-start_time`, String(section.start_time)]
4742
- ]);
4743
- }
4744
- function mixcloudEditUrl2(key) {
4745
- const withLeading = key.startsWith("/") ? key : `/${key}`;
4746
- const path2 = withLeading.endsWith("/") ? withLeading : `${withLeading}/`;
4747
- return `${MIXCLOUD_API2}/upload${path2}edit/`;
4748
- }
4749
4670
  function mixtapeTags2(_mixtape) {
4750
4671
  return ["Drum & Bass", "Fluncle"];
4751
4672
  }
@@ -4790,6 +4711,7 @@ function throwMixcloudError2(status, body) {
4790
4711
  }
4791
4712
  var MIXCLOUD_API2 = "https://api.mixcloud.com", DESCRIPTION_MAX2 = 1000, PICTURE_MAX_BYTES2, COVER_BASE2 = "https://www.fluncle.com/api/mixtape-cover";
4792
4713
  var init_mixtape_mixcloud2 = __esm(() => {
4714
+ init_util();
4793
4715
  init_api();
4794
4716
  init_output();
4795
4717
  init_mixtape_api();
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.77.0"
34
+ "version": "0.78.0"
35
35
  }