@totalaudiopromo/spotcheck 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +160 -2
- package/dist/bot-scorer.d.ts +75 -0
- package/dist/bot-scorer.js +174 -0
- package/dist/check.d.ts +65 -0
- package/dist/check.js +169 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +89 -0
- package/dist/format.d.ts +4 -0
- package/dist/format.js +56 -0
- package/dist/history.d.ts +42 -0
- package/dist/history.js +55 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +6 -0
- package/dist/jev.d.ts +32 -0
- package/dist/jev.js +107 -0
- package/dist/link-scanner.d.ts +2 -0
- package/dist/link-scanner.js +56 -0
- package/dist/mcp.d.ts +9 -0
- package/dist/mcp.js +54 -0
- package/dist/playlist-verdict.d.ts +27 -0
- package/dist/playlist-verdict.js +75 -0
- package/dist/spotify.d.ts +118 -0
- package/dist/spotify.js +191 -0
- package/dist/stream-farm-signals.d.ts +32 -0
- package/dist/stream-farm-signals.js +50 -0
- package/dist/warning-scan.d.ts +60 -0
- package/dist/warning-scan.js +102 -0
- package/package.json +55 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Total Audio Promo Ltd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,161 @@
|
|
|
1
|
-
#
|
|
1
|
+
# SpotCheck
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
SpotCheck checks a Spotify playlist for bot-farm patterns before you pitch to it or pay for a placement. It reads public playlist data only, scores it, and shows which signals it found.
|
|
4
|
+
|
|
5
|
+
A result means a playlist shows bot-farm patterns. It does not say why a distributor or Spotify flagged anything, and it cannot see inside Spotify. Treat a high score as a reason to look closer, and a low score as the absence of the signals below, not as proof a playlist is real.
|
|
6
|
+
|
|
7
|
+
SpotCheck is made by [Total Audio Promo](https://totalaudiopromo.com), which uses it as Playlist check inside TAP. This repository holds the same scorer under the MIT licence, with a command line tool and a local MCP server that run on your own Spotify credentials.
|
|
8
|
+
|
|
9
|
+
## What it checks
|
|
10
|
+
|
|
11
|
+
- **Check:** one playlist, scored from 0 to 100 with the signals behind the score.
|
|
12
|
+
- **Warning scan:** up to 50 playlists at once, for example the playlists on your Spotify for Artists page after a distributor warns you about artificial streams. They come back ranked, with the flagged ones first.
|
|
13
|
+
|
|
14
|
+
Limits worth knowing:
|
|
15
|
+
|
|
16
|
+
- Spotify-owned editorial and algorithmic playlists (Today's Top Hits, New Music Friday, Discover Weekly) cannot be scored. Spotify does not release them to outside tools. SpotCheck says so rather than blaming your link.
|
|
17
|
+
- Private and deleted playlists cannot be read.
|
|
18
|
+
- It samples the first 100 tracks of a playlist.
|
|
19
|
+
- Without stored follower history, it scores the playlist as it is today. Spike and drop signals need a follower series, which you can pass in through the library.
|
|
20
|
+
|
|
21
|
+
## Browser extension
|
|
22
|
+
|
|
23
|
+
The `extension/` folder holds the SpotCheck extension for Chrome, Firefox and Safari. On any open.spotify.com playlist page it adds a Check button, and its toolbar popup checks a pasted playlist link. Both show the full report: the 0 to 100 score and every signal behind it. The popup can export the report as a one-row CSV.
|
|
24
|
+
|
|
25
|
+
It has no accounts, plans or payments. Each check goes to the free checker at spotcheck.cc, which allows 3 checks a day for each visitor. When you reach that limit the extension shows the checker's message and a link to [Total Audio Promo](https://totalaudiopromo.com), where a full campaign of playlists can be checked.
|
|
26
|
+
|
|
27
|
+
Privacy: the extension reads only the address of the public playlist page you are on, or the link you paste. It sends that address to spotcheck.cc and shows what comes back. It does not read your Spotify account, listening history or cookies, and it stores nothing.
|
|
28
|
+
|
|
29
|
+
Load it unpacked in Chrome:
|
|
30
|
+
|
|
31
|
+
1. Run `cd extension && npm install && npm test` if you want to check it first.
|
|
32
|
+
2. Open `chrome://extensions` and switch on Developer mode.
|
|
33
|
+
3. Choose Load unpacked and select the `extension/` folder.
|
|
34
|
+
|
|
35
|
+
For Firefox, open `about:debugging`, choose Load Temporary Add-on and select `extension/manifest.firefox.json`. `npm run build` inside `extension/` writes the store zip to `extension/dist/`.
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
Node 22 or later. You also need a Spotify developer app, which is free: create one at [developer.spotify.com/dashboard](https://developer.spotify.com/dashboard) and copy its client ID and client secret. SpotCheck uses the client credentials flow, so it never asks you to sign in to Spotify.
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
export SPOTIFY_CLIENT_ID=your-client-id
|
|
43
|
+
export SPOTIFY_CLIENT_SECRET=your-client-secret
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Command line
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx github:chrisschouk/spotcheck-oss https://open.spotify.com/playlist/1PmwMQY86pJuAm7veFt3u2
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
A bare playlist id works too. Add `--json` for the full report as JSON.
|
|
53
|
+
|
|
54
|
+
To score several playlists from a warning:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx github:chrisschouk/spotcheck-oss scan 1PmwMQY86pJuAm7veFt3u2 <another-link> <another-link>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or pipe a list of links in with `scan -`.
|
|
61
|
+
|
|
62
|
+
## MCP server
|
|
63
|
+
|
|
64
|
+
The MCP server runs on your machine over stdio. It exposes two tools, `check_playlist` and `scan_warning_playlists`, and sends nothing anywhere except to Spotify (and to TypeSafe, only if you set the optional Jev key below).
|
|
65
|
+
|
|
66
|
+
Claude Code:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
claude mcp add spotcheck \
|
|
70
|
+
-e SPOTIFY_CLIENT_ID=your-client-id \
|
|
71
|
+
-e SPOTIFY_CLIENT_SECRET=your-client-secret \
|
|
72
|
+
-- npx -y github:chrisschouk/spotcheck-oss mcp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Claude Desktop (`claude_desktop_config.json`), or any client that takes the same format:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"spotcheck": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "github:chrisschouk/spotcheck-oss", "mcp"],
|
|
83
|
+
"env": {
|
|
84
|
+
"SPOTIFY_CLIENT_ID": "your-client-id",
|
|
85
|
+
"SPOTIFY_CLIENT_SECRET": "your-client-secret"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The server starts without credentials and lists its tools. A call without credentials returns a message telling you which variables to set.
|
|
93
|
+
|
|
94
|
+
## Library
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
import { checkPlaylist, scanWarningPlaylists } from '@totalaudiopromo/spotcheck'
|
|
98
|
+
|
|
99
|
+
const credentials = {
|
|
100
|
+
spotifyClientId: process.env.SPOTIFY_CLIENT_ID,
|
|
101
|
+
spotifyClientSecret: process.env.SPOTIFY_CLIENT_SECRET,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const report = await checkPlaylist('1PmwMQY86pJuAm7veFt3u2', credentials)
|
|
105
|
+
console.log(report.level, report.score, report.factors)
|
|
106
|
+
|
|
107
|
+
const scan = await scanWarningPlaylists(['<link>', '<link>'], credentials)
|
|
108
|
+
console.log(scan.report.flagged, 'of', scan.report.scanned, 'flagged')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The package is not published to npm yet. Install it from GitHub:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
npm install github:chrisschouk/spotcheck-oss
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Bad links, missing playlists and Spotify-owned playlists throw a `CheckError` with a `code` (`invalid_url`, `not_found`, `spotify_owned`, `unverifiable`, `spotify_unavailable`). Missing credentials throw a `SpotifyConfigError`.
|
|
118
|
+
|
|
119
|
+
## How scoring works
|
|
120
|
+
|
|
121
|
+
Each signal that fires adds points. The total is capped at 100. 50 or more is high, 25 to 49 is medium, and below 25 is low.
|
|
122
|
+
|
|
123
|
+
| Signal | Fires when | Points |
|
|
124
|
+
| --- | --- | --- |
|
|
125
|
+
| Followers don't seem to listen | 10,000 or more followers and the median track popularity is 5 or below (at least 20 tracks sampled) | 25 |
|
|
126
|
+
| Suspiciously high ratio | More than 10,000 followers per track | 25 |
|
|
127
|
+
| Generic name pattern | A name such as "chill", "vibes" or "lofi" with more than 50,000 followers | 10 |
|
|
128
|
+
| No description | A description under 10 characters | 10 |
|
|
129
|
+
| Round follower count | An exact multiple of 1,000 above 1,000 | 15 |
|
|
130
|
+
| Recent follower spike | Up 20% or by 5,000 followers against about 24 hours ago (needs follower history) | 25 |
|
|
131
|
+
| Sustained follower drop | Down 10% or more against about 7 days ago (needs follower history) | 15 |
|
|
132
|
+
|
|
133
|
+
Track popularity is Spotify's own 0 to 100 measure of recent plays. A playlist with a real following lifts the plays of what it carries, so a large playlist whose typical track sits near zero has followers who do not listen. A median popularity of 20 or more is direct evidence of an engaged audience, so it overrides the ratio and generic name signals, which only guess from a playlist's shape.
|
|
134
|
+
|
|
135
|
+
**Stream-farm signals** are measured and reported next to a warning scan and a check: how many tracks are played far beyond what their artist's following explains, and how many were added in the last 30 days. They do not change the score yet. They are there to be calibrated against playlists from real warnings.
|
|
136
|
+
|
|
137
|
+
The thresholds are constants in `src/bot-scorer.ts`, and the tests in `test` pin them against a labelled corpus. The corpus is constructed, not observed, so it checks that the scorer does what it was designed to do. It says nothing about accuracy on real playlists.
|
|
138
|
+
|
|
139
|
+
### Jev, optional
|
|
140
|
+
|
|
141
|
+
Jev is TypeSafe's decision model. It is off by default and the heuristic works alone. To turn it on, set your own TypeSafe key:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
export TYPESAFE_API_KEY=your-key
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Jev can raise a score to a floor (25 for a likely-inorganic audience when the heuristic has seen at least one warning sign, 50 for a very likely one) and never lowers one. It does nothing for playlists under 1,000 followers. When you set a key, the playlist's name, description, follower and track counts and track popularity summary are sent to TypeSafe.
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm ci
|
|
153
|
+
npm test
|
|
154
|
+
npm run build
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
The compiled `dist` folder is committed so `npx github:` starts in seconds without a build step. Run `npm run build` and commit `dist` with any change to `src`; CI fails if they differ.
|
|
158
|
+
|
|
159
|
+
## Licence
|
|
160
|
+
|
|
161
|
+
MIT. Copyright Total Audio Promo Ltd.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History-aware bot risk scoring.
|
|
3
|
+
*
|
|
4
|
+
* Static heuristics (high follower/track ratio, generic name, missing
|
|
5
|
+
* description, round follower count) and a listening signal from track
|
|
6
|
+
* popularity, then follower-history signals layered on top using verdict() and
|
|
7
|
+
* trend() from history.ts over a snapshot series. A recent spike pushes toward
|
|
8
|
+
* 'high'; a steady weekly drop adds a medium factor.
|
|
9
|
+
*
|
|
10
|
+
* Pure and IO-free: callers pass the snapshot series and track popularity in.
|
|
11
|
+
* `historical` is true only when at least two snapshots are supplied. The
|
|
12
|
+
* command line tool and MCP server have no stored history, so they score the
|
|
13
|
+
* static profile and the listening signal only.
|
|
14
|
+
*/
|
|
15
|
+
import { type Snap } from './history.js';
|
|
16
|
+
/**
|
|
17
|
+
* Spotify's track popularity (0-100) reflects how much a track has been played
|
|
18
|
+
* recently across all of Spotify. A playlist with a real following lifts the
|
|
19
|
+
* plays of what it carries, so a large playlist whose typical track sits near
|
|
20
|
+
* zero has followers who do not listen: the bought-follower pattern.
|
|
21
|
+
*
|
|
22
|
+
* Calibrated on 23 Sep 2026 against 56 live playlists from Spotify search. Three
|
|
23
|
+
* large lofi and study playlists (54k to 191k followers) had a median
|
|
24
|
+
* first-page popularity of 0, with 54% to 95% of tracks at 5 or below. Every
|
|
25
|
+
* other playlist above 10,000 followers had a median of 7 or more, most of them
|
|
26
|
+
* 24 to 80. Small personal playlists of obscure tracks also sit at a median of
|
|
27
|
+
* 5 to 8, which is why the follower floor matters.
|
|
28
|
+
*/
|
|
29
|
+
export declare const LISTENING_MIN_FOLLOWERS = 10000;
|
|
30
|
+
export declare const LISTENING_MAX_MEDIAN_POPULARITY = 5;
|
|
31
|
+
export declare const LISTENING_MIN_TRACKS_SAMPLED = 20;
|
|
32
|
+
/**
|
|
33
|
+
* A median track popularity at or above this means the playlist's audience
|
|
34
|
+
* plays what it carries. The high ratio and generic name rules only guess at
|
|
35
|
+
* inflated followers from a playlist's shape, so this direct evidence overrides
|
|
36
|
+
* them. Lofi Girl's official playlist (7.1M followers, 500 tracks, median 52 on
|
|
37
|
+
* 23 Sep 2026) scored medium on those two guesses alone.
|
|
38
|
+
*/
|
|
39
|
+
export declare const ENGAGED_MIN_MEDIAN_POPULARITY = 20;
|
|
40
|
+
export type ScoreLevel = 'low' | 'medium' | 'high';
|
|
41
|
+
export declare const NO_RED_FLAGS_LABEL = "No red flags detected";
|
|
42
|
+
export declare const LOW_LISTENING_LABEL = "Followers don't seem to listen";
|
|
43
|
+
export type ScoreFactor = {
|
|
44
|
+
label: string;
|
|
45
|
+
level: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
export type ScoreInput = {
|
|
49
|
+
name?: string;
|
|
50
|
+
description?: string | null;
|
|
51
|
+
followers: number;
|
|
52
|
+
tracks: number;
|
|
53
|
+
snapshots?: Snap[];
|
|
54
|
+
/** Popularity of the playable tracks on the playlist's first page of items. */
|
|
55
|
+
trackPopularity?: number[];
|
|
56
|
+
};
|
|
57
|
+
export type ScoreResult = {
|
|
58
|
+
score: number;
|
|
59
|
+
level: ScoreLevel;
|
|
60
|
+
factors: ScoreFactor[];
|
|
61
|
+
historical: boolean;
|
|
62
|
+
};
|
|
63
|
+
export type TrackListening = {
|
|
64
|
+
medianPopularity: number;
|
|
65
|
+
nearZeroShare: number;
|
|
66
|
+
sampled: number;
|
|
67
|
+
};
|
|
68
|
+
export declare function bandFor(score: number): ScoreLevel;
|
|
69
|
+
/** Null when too few tracks were sampled for a median to mean anything. */
|
|
70
|
+
export declare function trackListening(popularity?: number[]): TrackListening | null;
|
|
71
|
+
/**
|
|
72
|
+
* Score a playlist from its static profile, its track popularity and an
|
|
73
|
+
* optional follower-history series.
|
|
74
|
+
*/
|
|
75
|
+
export declare function scoreWithHistory(input: ScoreInput): ScoreResult;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* History-aware bot risk scoring.
|
|
3
|
+
*
|
|
4
|
+
* Static heuristics (high follower/track ratio, generic name, missing
|
|
5
|
+
* description, round follower count) and a listening signal from track
|
|
6
|
+
* popularity, then follower-history signals layered on top using verdict() and
|
|
7
|
+
* trend() from history.ts over a snapshot series. A recent spike pushes toward
|
|
8
|
+
* 'high'; a steady weekly drop adds a medium factor.
|
|
9
|
+
*
|
|
10
|
+
* Pure and IO-free: callers pass the snapshot series and track popularity in.
|
|
11
|
+
* `historical` is true only when at least two snapshots are supplied. The
|
|
12
|
+
* command line tool and MCP server have no stored history, so they score the
|
|
13
|
+
* static profile and the listening signal only.
|
|
14
|
+
*/
|
|
15
|
+
import { trend, verdict } from './history.js';
|
|
16
|
+
const GENERIC_NAMES = ['chill', 'vibes', 'lofi', 'study', 'sleep', 'workout'];
|
|
17
|
+
/**
|
|
18
|
+
* Spotify's track popularity (0-100) reflects how much a track has been played
|
|
19
|
+
* recently across all of Spotify. A playlist with a real following lifts the
|
|
20
|
+
* plays of what it carries, so a large playlist whose typical track sits near
|
|
21
|
+
* zero has followers who do not listen: the bought-follower pattern.
|
|
22
|
+
*
|
|
23
|
+
* Calibrated on 23 Sep 2026 against 56 live playlists from Spotify search. Three
|
|
24
|
+
* large lofi and study playlists (54k to 191k followers) had a median
|
|
25
|
+
* first-page popularity of 0, with 54% to 95% of tracks at 5 or below. Every
|
|
26
|
+
* other playlist above 10,000 followers had a median of 7 or more, most of them
|
|
27
|
+
* 24 to 80. Small personal playlists of obscure tracks also sit at a median of
|
|
28
|
+
* 5 to 8, which is why the follower floor matters.
|
|
29
|
+
*/
|
|
30
|
+
export const LISTENING_MIN_FOLLOWERS = 10_000;
|
|
31
|
+
export const LISTENING_MAX_MEDIAN_POPULARITY = 5;
|
|
32
|
+
export const LISTENING_MIN_TRACKS_SAMPLED = 20;
|
|
33
|
+
const NEAR_ZERO_POPULARITY = 5;
|
|
34
|
+
/**
|
|
35
|
+
* A median track popularity at or above this means the playlist's audience
|
|
36
|
+
* plays what it carries. The high ratio and generic name rules only guess at
|
|
37
|
+
* inflated followers from a playlist's shape, so this direct evidence overrides
|
|
38
|
+
* them. Lofi Girl's official playlist (7.1M followers, 500 tracks, median 52 on
|
|
39
|
+
* 23 Sep 2026) scored medium on those two guesses alone.
|
|
40
|
+
*/
|
|
41
|
+
export const ENGAGED_MIN_MEDIAN_POPULARITY = 20;
|
|
42
|
+
export const NO_RED_FLAGS_LABEL = 'No red flags detected';
|
|
43
|
+
export const LOW_LISTENING_LABEL = "Followers don't seem to listen";
|
|
44
|
+
export function bandFor(score) {
|
|
45
|
+
if (score >= 50)
|
|
46
|
+
return 'high';
|
|
47
|
+
if (score >= 25)
|
|
48
|
+
return 'medium';
|
|
49
|
+
return 'low';
|
|
50
|
+
}
|
|
51
|
+
/** Null when too few tracks were sampled for a median to mean anything. */
|
|
52
|
+
export function trackListening(popularity = []) {
|
|
53
|
+
if (popularity.length < LISTENING_MIN_TRACKS_SAMPLED)
|
|
54
|
+
return null;
|
|
55
|
+
const sorted = [...popularity].sort((a, b) => a - b);
|
|
56
|
+
const mid = Math.floor(sorted.length / 2);
|
|
57
|
+
const medianPopularity = sorted.length % 2 ? sorted[mid] : (sorted[mid - 1] + sorted[mid]) / 2;
|
|
58
|
+
const nearZero = sorted.filter(p => p <= NEAR_ZERO_POPULARITY).length;
|
|
59
|
+
return {
|
|
60
|
+
medianPopularity,
|
|
61
|
+
nearZeroShare: Math.round((nearZero / sorted.length) * 100) / 100,
|
|
62
|
+
sampled: sorted.length,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function hasEngagedAudience(trackPopularity) {
|
|
66
|
+
const listening = trackListening(trackPopularity);
|
|
67
|
+
return listening !== null && listening.medianPopularity >= ENGAGED_MIN_MEDIAN_POPULARITY;
|
|
68
|
+
}
|
|
69
|
+
const highRatio = ({ followers, tracks, trackPopularity }) => tracks > 0 && followers / tracks > 10000 && !hasEngagedAudience(trackPopularity)
|
|
70
|
+
? {
|
|
71
|
+
label: 'Suspiciously high ratio',
|
|
72
|
+
level: 'danger',
|
|
73
|
+
description: 'Over 10,000 followers per track. Often a sign of inflated numbers from bot networks.',
|
|
74
|
+
points: 25,
|
|
75
|
+
}
|
|
76
|
+
: null;
|
|
77
|
+
const genericName = ({ name, followers, trackPopularity }) => GENERIC_NAMES.some(n => (name ?? '').toLowerCase().includes(n)) &&
|
|
78
|
+
followers > 50000 &&
|
|
79
|
+
!hasEngagedAudience(trackPopularity)
|
|
80
|
+
? {
|
|
81
|
+
label: 'Generic name pattern',
|
|
82
|
+
level: 'warning',
|
|
83
|
+
description: 'Names like "chill vibes" or "lofi study" are common with bulk bot-driven playlists.',
|
|
84
|
+
points: 10,
|
|
85
|
+
}
|
|
86
|
+
: null;
|
|
87
|
+
const noDescription = ({ description }) => (description ?? '').length < 10
|
|
88
|
+
? {
|
|
89
|
+
label: 'No description',
|
|
90
|
+
level: 'warning',
|
|
91
|
+
description: 'Real curators usually write a description. Empty descriptions are typical of automated playlists.',
|
|
92
|
+
points: 10,
|
|
93
|
+
}
|
|
94
|
+
: null;
|
|
95
|
+
const roundCount = ({ followers }) => followers > 1000 && followers % 1000 === 0
|
|
96
|
+
? {
|
|
97
|
+
label: 'Round follower count',
|
|
98
|
+
level: 'warning',
|
|
99
|
+
description: 'Exact thousands (10,000 / 25,000) often indicate purchased follower packages.',
|
|
100
|
+
points: 15,
|
|
101
|
+
}
|
|
102
|
+
: null;
|
|
103
|
+
const lowListening = ({ followers, trackPopularity }) => {
|
|
104
|
+
const listening = trackListening(trackPopularity);
|
|
105
|
+
if (followers < LISTENING_MIN_FOLLOWERS || !listening)
|
|
106
|
+
return null;
|
|
107
|
+
if (listening.medianPopularity > LISTENING_MAX_MEDIAN_POPULARITY)
|
|
108
|
+
return null;
|
|
109
|
+
return {
|
|
110
|
+
label: LOW_LISTENING_LABEL,
|
|
111
|
+
level: 'danger',
|
|
112
|
+
description: 'Over 10,000 followers, yet the typical track here has a Spotify popularity of 5 or less out of 100. A real following plays what it follows, so this pattern usually means bought followers.',
|
|
113
|
+
points: 25,
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
// A low follower-to-track ratio is deliberately not a rule: small, new and
|
|
117
|
+
// personal playlists all have one, and they are almost always organic.
|
|
118
|
+
const STATIC_RULES = [highRatio, genericName, noDescription, roundCount, lowListening];
|
|
119
|
+
function historySignals(snapshots) {
|
|
120
|
+
const v = verdict(snapshots);
|
|
121
|
+
const signals = [];
|
|
122
|
+
if (v.spike) {
|
|
123
|
+
signals.push({
|
|
124
|
+
label: 'Recent follower spike',
|
|
125
|
+
level: 'danger',
|
|
126
|
+
description: 'A sharp follower jump in the last 24 hours with no editorial placement. This pattern is consistent with purchased followers.',
|
|
127
|
+
points: 25,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (v.drop) {
|
|
131
|
+
signals.push({
|
|
132
|
+
label: 'Sustained follower drop',
|
|
133
|
+
level: 'warning',
|
|
134
|
+
description: 'Followers have fallen week on week. Steady decline can follow a purchased-follower batch being culled by Spotify.',
|
|
135
|
+
points: 15,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const change7d = trend(snapshots).change7d;
|
|
139
|
+
if (signals.length === 0 && change7d != null && Math.abs(change7d) < 1) {
|
|
140
|
+
signals.push({
|
|
141
|
+
label: 'Flat follower history',
|
|
142
|
+
level: '',
|
|
143
|
+
description: 'Follower count has been broadly stable over the past week. No anomaly signals from the monitored history.',
|
|
144
|
+
points: 0,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return signals;
|
|
148
|
+
}
|
|
149
|
+
const NO_RED_FLAGS = {
|
|
150
|
+
label: NO_RED_FLAGS_LABEL,
|
|
151
|
+
level: '',
|
|
152
|
+
description: 'None of the automated signals fired. Worth pitching, but always cross-check the curator.',
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* Score a playlist from its static profile, its track popularity and an
|
|
156
|
+
* optional follower-history series.
|
|
157
|
+
*/
|
|
158
|
+
export function scoreWithHistory(input) {
|
|
159
|
+
const normalised = { ...input, followers: input.followers || 0, tracks: input.tracks || 0 };
|
|
160
|
+
const snapshots = input.snapshots ?? [];
|
|
161
|
+
const historical = snapshots.length >= 2;
|
|
162
|
+
const signals = [
|
|
163
|
+
...STATIC_RULES.map(rule => rule(normalised)).filter((s) => s !== null),
|
|
164
|
+
...(historical ? historySignals(snapshots) : []),
|
|
165
|
+
];
|
|
166
|
+
const score = signals.reduce((sum, s) => sum + s.points, 0);
|
|
167
|
+
const factors = signals.map(({ points: _points, ...factor }) => factor);
|
|
168
|
+
return {
|
|
169
|
+
score: Math.min(score, 100),
|
|
170
|
+
level: bandFor(score),
|
|
171
|
+
factors: factors.length > 0 ? factors : [NO_RED_FLAGS],
|
|
172
|
+
historical,
|
|
173
|
+
};
|
|
174
|
+
}
|
package/dist/check.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two entry points: checkPlaylist for one playlist and scanWarningPlaylists
|
|
3
|
+
* for the set an artist pastes after a distributor's artificial streaming
|
|
4
|
+
* warning. Both fetch public data from Spotify, score it and return plain
|
|
5
|
+
* objects. The command line tool and the MCP server are thin wrappers.
|
|
6
|
+
*/
|
|
7
|
+
import type { JevResult } from './jev.js';
|
|
8
|
+
import type { ScoreFactor, ScoreLevel } from './bot-scorer.js';
|
|
9
|
+
import { type SpotifyCredentials } from './spotify.js';
|
|
10
|
+
import type { Snap } from './history.js';
|
|
11
|
+
import { type StreamFarmSignals } from './stream-farm-signals.js';
|
|
12
|
+
import { type FullReport } from './warning-scan.js';
|
|
13
|
+
export type CheckOptions = Partial<SpotifyCredentials> & {
|
|
14
|
+
/** Your own TypeSafe API key. Jev is optional and off unless this is set. */
|
|
15
|
+
jevApiKey?: string;
|
|
16
|
+
/** Follower history, newest first, if you track it. Adds the spike and drop signals. */
|
|
17
|
+
snapshots?: Snap[];
|
|
18
|
+
};
|
|
19
|
+
export type ScanOptions = Partial<SpotifyCredentials> & {
|
|
20
|
+
jevApiKey?: string;
|
|
21
|
+
};
|
|
22
|
+
export type PlaylistSummary = {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
url: string;
|
|
26
|
+
owner: string;
|
|
27
|
+
description: string | null;
|
|
28
|
+
followers: number;
|
|
29
|
+
tracks: number;
|
|
30
|
+
};
|
|
31
|
+
export type CheckReport = {
|
|
32
|
+
playlist: PlaylistSummary;
|
|
33
|
+
score: number;
|
|
34
|
+
level: ScoreLevel;
|
|
35
|
+
factors: ScoreFactor[];
|
|
36
|
+
/** True when follower history was supplied and used. */
|
|
37
|
+
historical: boolean;
|
|
38
|
+
jev: JevResult;
|
|
39
|
+
/** Measured, reported, never scored. Null when too few tracks could be sampled. */
|
|
40
|
+
streamFarm: StreamFarmSignals | null;
|
|
41
|
+
};
|
|
42
|
+
export type ScanReport = {
|
|
43
|
+
report: FullReport;
|
|
44
|
+
/** Measured, reported, never scored. Keyed by playlist id. */
|
|
45
|
+
streamFarm: Record<string, StreamFarmSignals>;
|
|
46
|
+
/** Valid, distinct links past the 50 playlist cap that were left out. */
|
|
47
|
+
overCap: number;
|
|
48
|
+
};
|
|
49
|
+
export type CheckErrorCode = 'invalid_url' | 'not_found' | 'spotify_owned' | 'unverifiable' | 'spotify_unavailable';
|
|
50
|
+
export declare class CheckError extends Error {
|
|
51
|
+
code: CheckErrorCode;
|
|
52
|
+
constructor(code: CheckErrorCode, message: string);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Check one playlist. Throws CheckError for a bad link, a playlist Spotify does
|
|
56
|
+
* not return, a Spotify-owned playlist, or an unreachable Spotify, and
|
|
57
|
+
* SpotifyConfigError when no credentials are supplied.
|
|
58
|
+
*/
|
|
59
|
+
export declare function checkPlaylist(urlOrId: string, options?: CheckOptions): Promise<CheckReport>;
|
|
60
|
+
/**
|
|
61
|
+
* Score every playlist link in `input`: free text or a list, up to 50 links.
|
|
62
|
+
* Per-playlist failures become skipped rows. Throws CheckError when no link is
|
|
63
|
+
* valid or when Spotify fails for every playlist.
|
|
64
|
+
*/
|
|
65
|
+
export declare function scanWarningPlaylists(input: string | string[], options?: ScanOptions): Promise<ScanReport>;
|
package/dist/check.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two entry points: checkPlaylist for one playlist and scanWarningPlaylists
|
|
3
|
+
* for the set an artist pastes after a distributor's artificial streaming
|
|
4
|
+
* warning. Both fetch public data from Spotify, score it and return plain
|
|
5
|
+
* objects. The command line tool and the MCP server are thin wrappers.
|
|
6
|
+
*/
|
|
7
|
+
import { scoreInputFor, scorePlaylist } from './playlist-verdict.js';
|
|
8
|
+
import { extractPlaylistId, fetchArtistFollowers, fetchPlaylist, getClientCredentialsToken, isSpotifyGeneratedPlaylistId, lookupPlaylistOwnerFromPublicPage, PLAYLIST_NOT_FOUND_MESSAGE, PLAYLIST_UNVERIFIABLE_MESSAGE, SPOTIFY_GENERATED_PLAYLIST_MESSAGE, SpotifyApiError, } from './spotify.js';
|
|
9
|
+
import { streamFarmSignals } from './stream-farm-signals.js';
|
|
10
|
+
import { buildReport, parseScanInput, reasonFor, } from './warning-scan.js';
|
|
11
|
+
export class CheckError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
constructor(code, message) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'CheckError';
|
|
16
|
+
this.code = code;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const FETCH_CONCURRENCY = 5;
|
|
20
|
+
const JEV_CONCURRENCY = 10;
|
|
21
|
+
const playlistUrl = (id) => `https://open.spotify.com/playlist/${id}`;
|
|
22
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
23
|
+
const results = new Array(items.length);
|
|
24
|
+
let next = 0;
|
|
25
|
+
async function worker() {
|
|
26
|
+
while (next < items.length) {
|
|
27
|
+
const index = next++;
|
|
28
|
+
results[index] = await fn(items[index]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
32
|
+
return results;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* A 404 on an id in Spotify's reserved namespace is only a candidate for
|
|
36
|
+
* "Spotify's own playlist". The public page confirms it before anyone is told
|
|
37
|
+
* that was the reason.
|
|
38
|
+
*/
|
|
39
|
+
async function notFoundReason(playlistId) {
|
|
40
|
+
if (!isSpotifyGeneratedPlaylistId(playlistId))
|
|
41
|
+
return 'not_found';
|
|
42
|
+
const lookup = await lookupPlaylistOwnerFromPublicPage(playlistId);
|
|
43
|
+
if (lookup.kind === 'owned_by_spotify')
|
|
44
|
+
return 'spotify_owned';
|
|
45
|
+
return lookup.kind === 'not_found' ? 'not_found' : 'unverifiable';
|
|
46
|
+
}
|
|
47
|
+
function summarise(playlist) {
|
|
48
|
+
return {
|
|
49
|
+
id: playlist.id,
|
|
50
|
+
name: playlist.name ?? 'Untitled playlist',
|
|
51
|
+
url: playlist.external_urls?.spotify ?? playlistUrl(playlist.id),
|
|
52
|
+
owner: playlist.owner.display_name ?? playlist.owner.id ?? 'Unknown curator',
|
|
53
|
+
description: playlist.description,
|
|
54
|
+
followers: playlist.followers.total,
|
|
55
|
+
tracks: playlist.tracks.total,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Best-effort: a failure here costs the report its stream-farm numbers, never the check. */
|
|
59
|
+
async function measureStreamFarm(playlists, token) {
|
|
60
|
+
const signals = new Map();
|
|
61
|
+
try {
|
|
62
|
+
const artistIds = playlists.flatMap(p => p.trackItems.flatMap(t => (t.artistId ? [t.artistId] : [])));
|
|
63
|
+
const followers = await fetchArtistFollowers(artistIds, token);
|
|
64
|
+
for (const playlist of playlists) {
|
|
65
|
+
const measured = streamFarmSignals(playlist.trackItems, followers);
|
|
66
|
+
if (measured)
|
|
67
|
+
signals.set(playlist.id, measured);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Enrichment only.
|
|
72
|
+
}
|
|
73
|
+
return signals;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check one playlist. Throws CheckError for a bad link, a playlist Spotify does
|
|
77
|
+
* not return, a Spotify-owned playlist, or an unreachable Spotify, and
|
|
78
|
+
* SpotifyConfigError when no credentials are supplied.
|
|
79
|
+
*/
|
|
80
|
+
export async function checkPlaylist(urlOrId, options = {}) {
|
|
81
|
+
const playlistId = extractPlaylistId(urlOrId);
|
|
82
|
+
if (!playlistId)
|
|
83
|
+
throw new CheckError('invalid_url', 'Enter a valid Spotify playlist link.');
|
|
84
|
+
const { access_token: token } = await getClientCredentialsToken(options);
|
|
85
|
+
let playlist;
|
|
86
|
+
try {
|
|
87
|
+
playlist = await fetchPlaylist(playlistId, token);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
if (error instanceof SpotifyApiError && error.status === 404) {
|
|
91
|
+
const reason = await notFoundReason(playlistId);
|
|
92
|
+
if (reason === 'spotify_owned')
|
|
93
|
+
throw new CheckError('spotify_owned', SPOTIFY_GENERATED_PLAYLIST_MESSAGE);
|
|
94
|
+
if (reason === 'unverifiable')
|
|
95
|
+
throw new CheckError('unverifiable', PLAYLIST_UNVERIFIABLE_MESSAGE);
|
|
96
|
+
throw new CheckError('not_found', PLAYLIST_NOT_FOUND_MESSAGE);
|
|
97
|
+
}
|
|
98
|
+
throw new CheckError('spotify_unavailable', "Spotify isn't answering right now. Try again in a few minutes.");
|
|
99
|
+
}
|
|
100
|
+
const jevOptions = { apiKey: options.jevApiKey };
|
|
101
|
+
const [verdict, signals] = await Promise.all([
|
|
102
|
+
scorePlaylist(scoreInputFor(playlist, options.snapshots ?? []), jevOptions),
|
|
103
|
+
measureStreamFarm([playlist], token),
|
|
104
|
+
]);
|
|
105
|
+
return {
|
|
106
|
+
playlist: summarise(playlist),
|
|
107
|
+
score: verdict.score,
|
|
108
|
+
level: verdict.level,
|
|
109
|
+
factors: verdict.factors,
|
|
110
|
+
historical: verdict.historical,
|
|
111
|
+
jev: verdict.jev,
|
|
112
|
+
streamFarm: signals.get(playlist.id) ?? null,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function fetchOne(playlistId, token) {
|
|
116
|
+
try {
|
|
117
|
+
return { ok: true, playlist: { ...(await fetchPlaylist(playlistId, token)), id: playlistId } };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
let why = 'error';
|
|
121
|
+
if (error instanceof SpotifyApiError && error.status === 404) {
|
|
122
|
+
const reason = await notFoundReason(playlistId);
|
|
123
|
+
why = reason === 'spotify_owned' ? 'spotify_owned' : 'not_found';
|
|
124
|
+
}
|
|
125
|
+
return { ok: false, row: { kind: 'skipped', input: playlistUrl(playlistId), playlistId, why } };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function scoredRow(playlist, verdict) {
|
|
129
|
+
const summary = summarise(playlist);
|
|
130
|
+
return {
|
|
131
|
+
kind: 'scored',
|
|
132
|
+
playlistId: summary.id,
|
|
133
|
+
url: summary.url,
|
|
134
|
+
name: summary.name,
|
|
135
|
+
owner: summary.owner,
|
|
136
|
+
followers: summary.followers,
|
|
137
|
+
tracks: summary.tracks,
|
|
138
|
+
score: verdict.score,
|
|
139
|
+
level: verdict.level,
|
|
140
|
+
reason: reasonFor(verdict.factors),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Score every playlist link in `input`: free text or a list, up to 50 links.
|
|
145
|
+
* Per-playlist failures become skipped rows. Throws CheckError when no link is
|
|
146
|
+
* valid or when Spotify fails for every playlist.
|
|
147
|
+
*/
|
|
148
|
+
export async function scanWarningPlaylists(input, options = {}) {
|
|
149
|
+
const text = Array.isArray(input) ? input.join('\n') : input;
|
|
150
|
+
const parsed = parseScanInput(text);
|
|
151
|
+
if (parsed.ids.length === 0) {
|
|
152
|
+
throw new CheckError('invalid_url', 'Provide at least one Spotify playlist link.');
|
|
153
|
+
}
|
|
154
|
+
const { access_token: token } = await getClientCredentialsToken(options);
|
|
155
|
+
const fetched = await mapWithConcurrency(parsed.ids, FETCH_CONCURRENCY, id => fetchOne(id, token));
|
|
156
|
+
if (fetched.every(f => !f.ok && f.row.why === 'error')) {
|
|
157
|
+
throw new CheckError('spotify_unavailable', "Spotify isn't answering right now. Try again in a few minutes.");
|
|
158
|
+
}
|
|
159
|
+
const jevOptions = { apiKey: options.jevApiKey };
|
|
160
|
+
const [rows, signals] = await Promise.all([
|
|
161
|
+
mapWithConcurrency(fetched, JEV_CONCURRENCY, async (f) => f.ok ? scoredRow(f.playlist, await scorePlaylist(scoreInputFor(f.playlist), jevOptions)) : f.row),
|
|
162
|
+
measureStreamFarm(fetched.flatMap(f => (f.ok ? [f.playlist] : [])), token),
|
|
163
|
+
]);
|
|
164
|
+
return {
|
|
165
|
+
report: buildReport([...rows, ...parsed.skipped]),
|
|
166
|
+
streamFarm: Object.fromEntries(signals),
|
|
167
|
+
overCap: parsed.overCap,
|
|
168
|
+
};
|
|
169
|
+
}
|
package/dist/cli.d.ts
ADDED