@pulso/companion 0.2.1 → 0.2.2

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/dist/index.js +26 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -195,6 +195,9 @@ async function spotifySearch(query) {
195
195
  } catch {
196
196
  }
197
197
  let trackIds = await searchBraveForSpotifyTracks(query);
198
+ if (trackIds.length === 0) {
199
+ trackIds = await searchDDGForSpotifyTracks(query);
200
+ }
198
201
  if (trackIds.length === 0) {
199
202
  trackIds = await searchStartpageForSpotifyTracks(query);
200
203
  }
@@ -232,6 +235,28 @@ async function searchBraveForSpotifyTracks(query) {
232
235
  return [];
233
236
  }
234
237
  }
238
+ async function searchDDGForSpotifyTracks(query) {
239
+ try {
240
+ const searchQuery = `spotify track ${query} site:open.spotify.com`;
241
+ const url = `https://html.duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}`;
242
+ const controller = new AbortController();
243
+ const timeout = setTimeout(() => controller.abort(), 8e3);
244
+ const res = await fetch(url, {
245
+ headers: { "User-Agent": UA, Accept: "text/html" },
246
+ signal: controller.signal
247
+ });
248
+ clearTimeout(timeout);
249
+ if (!res.ok) return [];
250
+ const html = await res.text();
251
+ const trackIds = /* @__PURE__ */ new Set();
252
+ for (const m of html.matchAll(/open\.spotify\.com(?:\/intl-[a-z]+)?\/track\/([a-zA-Z0-9]{22})/g)) {
253
+ trackIds.add(m[1]);
254
+ }
255
+ return [...trackIds];
256
+ } catch {
257
+ return [];
258
+ }
259
+ }
235
260
  async function searchStartpageForSpotifyTracks(query) {
236
261
  try {
237
262
  const searchQuery = `${query} spotify open.spotify.com`;
@@ -1404,7 +1429,7 @@ function scheduleReconnect() {
1404
1429
  }
1405
1430
  console.log("");
1406
1431
  console.log(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
1407
- console.log(" \u2551 \u{1FAC0} Pulso Mac Companion v0.2.1 \u2551");
1432
+ console.log(" \u2551 \u{1FAC0} Pulso Mac Companion v0.2.2 \u2551");
1408
1433
  console.log(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D");
1409
1434
  console.log("");
1410
1435
  setupPermissions().then(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulso/companion",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "Pulso Companion — gives your AI agent real control over your computer",
6
6
  "bin": {