@vicyangorg/dsh-music 0.3.0 → 0.4.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/client/index.js +201 -22
- package/host/history.js +65 -22
- package/host/likes.js +203 -59
- package/host/main.js +2 -2
- package/host/reco/discover.js +155 -72
- package/host/reco/index.js +36 -6
- package/host/reco/pools.js +28 -0
- package/icon.png +0 -0
- package/package.json +3 -3
- package/icon.svg +0 -16
package/host/reco/index.js
CHANGED
|
@@ -51,6 +51,24 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
51
51
|
await rename(tmp, file)
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/** 不喜欢标记(八期④):只读 likes.json v2 的 dislikes,不进播放画像(口味事件不参与历史统计)。
|
|
55
|
+
* 返回归一后的「歌手::歌名」集合 + 小写歌手集合(歌手级软降权用)。文件不存在视为零。 */
|
|
56
|
+
async function readDislikes() {
|
|
57
|
+
const saved = await readJson(join(storage.dataDir, 'likes.json'), null)
|
|
58
|
+
const dislikes = saved && typeof saved.dislikes === 'object' && saved.dislikes !== null ? saved.dislikes : {}
|
|
59
|
+
const keys = new Set()
|
|
60
|
+
const artists = new Set()
|
|
61
|
+
for (const d of Object.values(dislikes)) {
|
|
62
|
+
if (!d || typeof d !== 'object') continue
|
|
63
|
+
const artist = typeof d.artist === 'string' ? d.artist : ''
|
|
64
|
+
const title = typeof d.title === 'string' ? d.title : ''
|
|
65
|
+
if (!artist || !title) continue
|
|
66
|
+
keys.add(normKey(artist, title))
|
|
67
|
+
artists.add(artist.trim().toLowerCase())
|
|
68
|
+
}
|
|
69
|
+
return { keys, artists }
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
/** 生成一批推荐(10 首 = 7 相近 + 3 探索,逐首已核实)。纯算法 + MusicBrainz,无 LLM。
|
|
55
73
|
* 可选 options.taste(v7 批2:客户端首启偏好 {genres[],languages[]})仅软偏置探索轴,不传时行为不变。 */
|
|
56
74
|
async function generate(options = {}) {
|
|
@@ -301,12 +319,14 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
301
319
|
const recs = await discover.browseRecordings(a.mbid, a.name)
|
|
302
320
|
const songs = []
|
|
303
321
|
const seen = new Set()
|
|
322
|
+
const { keys: dislikedKeys } = await readDislikes()
|
|
304
323
|
// 去括号版本后缀去重(Live/Remix 版不重复占位)
|
|
305
324
|
const baseKey = (artist, title) => normKey(artist, String(title).replace(/[((].*?[))]/g, ''))
|
|
306
325
|
for (const r of recs) {
|
|
307
326
|
if (songs.length >= 20) break
|
|
308
327
|
const key = baseKey(r.artist, r.title)
|
|
309
328
|
if (!key || seen.has(key)) continue
|
|
329
|
+
if (dislikedKeys.has(normKey(r.artist, r.title))) continue
|
|
310
330
|
seen.add(key)
|
|
311
331
|
const v = await verifier.verify({ artist: r.artist, title: r.title, durationMs: r.durationMs })
|
|
312
332
|
if (!v) continue
|
|
@@ -339,6 +359,7 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
339
359
|
}
|
|
340
360
|
const tracks = snap?.tracks ?? []
|
|
341
361
|
const { seedArtists, topArtistSet, profileValues, profile, libraryKeys, recentKeys } = await buildProfile(events, tracks)
|
|
362
|
+
const { keys: dislikedKeys, artists: dislikedArtists } = await readDislikes()
|
|
342
363
|
|
|
343
364
|
// ---- 探索轴轮换(quota.js,批间轮转 + 固定意外之喜位)----
|
|
344
365
|
const state = await readJson(stateFile, {})
|
|
@@ -352,9 +373,15 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
352
373
|
const exploreResult = await discover.buildExploreCandidates({
|
|
353
374
|
slots: plan.slots, profileValues, cursors: state.cursors ?? {}, taste,
|
|
354
375
|
})
|
|
355
|
-
const
|
|
376
|
+
const deduped = [
|
|
356
377
|
...similar,
|
|
357
378
|
...exploreResult.candidates.filter((c) => !recentRecommended.has(normKey(c.artist, c.title))),
|
|
379
|
+
].filter((c) => !dislikedKeys.has(normKey(c.artist, c.title)))
|
|
380
|
+
// ④ 避开不喜欢:标记过的歌直接排除;同歌手的其余曲目软降权(排到最后,仅在候选不足时补位)
|
|
381
|
+
const isDislikedArtist = (c) => dislikedArtists.has(String(c.artist ?? '').trim().toLowerCase())
|
|
382
|
+
const candidates = [
|
|
383
|
+
...deduped.filter((c) => !isDislikedArtist(c)),
|
|
384
|
+
...deduped.filter((c) => isDislikedArtist(c)),
|
|
358
385
|
]
|
|
359
386
|
const needSimilar = bootstrap ? 0 : SIMILAR_SLOTS
|
|
360
387
|
if (candidates.length < needSimilar + EXPLORE_SLOTS) {
|
|
@@ -475,7 +502,7 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
475
502
|
if (typeof library.ensureScanned === 'function') await library.ensureScanned()
|
|
476
503
|
const snap = library.snapshot()
|
|
477
504
|
const tracks = snap?.tracks ?? []
|
|
478
|
-
const { seedArtists, libraryKeys, recentKeys } = await buildProfile(events, tracks)
|
|
505
|
+
const { seedArtists, libraryKeys, recentKeys, profile } = await buildProfile(events, tracks)
|
|
479
506
|
|
|
480
507
|
// today:同一自然日「且数量达标(>= 14+6)」才复用最近一批;否则生成新批次(推进探索轴轮换)。
|
|
481
508
|
// 旧版本(二期 10 首/批)的当日批次不足 20,必须重生成,否则活体会显示 10 首。
|
|
@@ -534,11 +561,14 @@ export function createReco({ history, library, storage, config = {}, logger, ver
|
|
|
534
561
|
const imgMap = await images.artistImages(artistResult.artists.map((a) => a.name))
|
|
535
562
|
const artist = artistResult.artists.map((a) => ({ ...a, imageUrl: imgMap.get(a.name)?.thumbnail ?? null }))
|
|
536
563
|
|
|
537
|
-
// new
|
|
564
|
+
// new:真正的新发行(近 180 天,八期①)——高频歌手/相似歌手/口味流派来源;本地刚入库不算新歌
|
|
565
|
+
const disliked = await readDislikes()
|
|
566
|
+
const tasteGenres = (taste?.genres?.length ? taste.genres : profile.genres).slice(0, 4)
|
|
538
567
|
const usedForNew = new Set(usedKeys)
|
|
539
|
-
const newCands = await discover.buildNewCandidates({
|
|
540
|
-
tracks, getRecord: (id) => library.getRecord(id), seedArtists, libraryKeys, recentKeys, extraKeys: usedForNew,
|
|
541
|
-
|
|
568
|
+
const newCands = (await discover.buildNewCandidates({
|
|
569
|
+
tracks, getRecord: (id) => library.getRecord(id), seedArtists, libraryKeys, recentKeys, extraKeys: usedForNew,
|
|
570
|
+
tasteGenres, dislikedKeys: disliked.keys, dislikedArtists: disliked.artists, limit: 20,
|
|
571
|
+
})).filter((c) => !disliked.keys.has(normKey(c.artist, c.title)))
|
|
542
572
|
const fresh = await verifyToItems(newCands, { limit: 20, category: 'new', usedKeys: usedForNew })
|
|
543
573
|
|
|
544
574
|
// 持久化歌手轮换游标(merge 现有 state,不覆盖其余字段)
|
package/host/reco/pools.js
CHANGED
|
@@ -55,6 +55,34 @@ export const GENRE_POOLS = {
|
|
|
55
55
|
ambient: [
|
|
56
56
|
{ artist: 'Brian Eno', title: 'An Ending (Ascent)' },
|
|
57
57
|
{ artist: 'Sigur Rós', title: 'Hoppípolla' },
|
|
58
|
+
{ artist: 'Moby', title: 'Porcelain' },
|
|
59
|
+
],
|
|
60
|
+
// 八期②:对齐欢迎页 genreOptions 15 个流派(织音 client 已扩到 15)。
|
|
61
|
+
// 'hip hop' 保留空格键名,与 style.js / MB tag 口径一致(客户端传 'hip hop')。
|
|
62
|
+
rock: [
|
|
63
|
+
{ artist: 'The Rolling Stones', title: 'Paint It Black' },
|
|
64
|
+
{ artist: 'Led Zeppelin', title: 'Stairway to Heaven' },
|
|
65
|
+
{ artist: 'Nirvana', title: 'Smells Like Teen Spirit' },
|
|
66
|
+
],
|
|
67
|
+
pop: [
|
|
68
|
+
{ artist: 'Michael Jackson', title: 'Billie Jean' },
|
|
69
|
+
{ artist: 'Madonna', title: 'Like a Prayer' },
|
|
70
|
+
{ artist: 'Taylor Swift', title: 'Shake It Off' },
|
|
71
|
+
],
|
|
72
|
+
'hip hop': [
|
|
73
|
+
{ artist: 'Kendrick Lamar', title: 'HUMBLE.' },
|
|
74
|
+
{ artist: 'Wu-Tang Clan', title: 'C.R.E.A.M.' },
|
|
75
|
+
{ artist: 'Lauryn Hill', title: 'Doo Wop (That Thing)' },
|
|
76
|
+
],
|
|
77
|
+
punk: [
|
|
78
|
+
{ artist: 'The Clash', title: 'London Calling' },
|
|
79
|
+
{ artist: 'Ramones', title: 'Blitzkrieg Bop' },
|
|
80
|
+
{ artist: 'Sex Pistols', title: 'Anarchy in the U.K.' },
|
|
81
|
+
],
|
|
82
|
+
country: [
|
|
83
|
+
{ artist: 'Johnny Cash', title: 'Ring of Fire' },
|
|
84
|
+
{ artist: 'Dolly Parton', title: 'Jolene' },
|
|
85
|
+
{ artist: 'Willie Nelson', title: 'On the Road Again' },
|
|
58
86
|
],
|
|
59
87
|
}
|
|
60
88
|
|
package/icon.png
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
7
7
|
"private": false,
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"author": "vicyangworld",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
".": "./index.js",
|
|
36
36
|
"./client": "./client/index.js",
|
|
37
37
|
"./locale/*.json": "./locale/*.json",
|
|
38
|
-
"./icon": "./icon.
|
|
38
|
+
"./icon": "./icon.png"
|
|
39
39
|
},
|
|
40
40
|
"files": [
|
|
41
41
|
"index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"client/index.js",
|
|
44
44
|
"cordis.patch.yml",
|
|
45
45
|
"locale/*.json",
|
|
46
|
-
"icon.
|
|
46
|
+
"icon.png",
|
|
47
47
|
"docs/DETAIL.md",
|
|
48
48
|
"docs/assets/*"
|
|
49
49
|
],
|
package/icon.svg
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="256" height="256">
|
|
2
|
-
<defs>
|
|
3
|
-
<linearGradient id="dshm-bg" x1="0" y1="0" x2="1" y2="1">
|
|
4
|
-
<stop offset="0" stop-color="#4f46e5"/>
|
|
5
|
-
<stop offset="1" stop-color="#8b5cf6"/>
|
|
6
|
-
</linearGradient>
|
|
7
|
-
</defs>
|
|
8
|
-
<rect x="8" y="8" width="240" height="240" rx="56" fill="url(#dshm-bg)"/>
|
|
9
|
-
<g fill="#ffffff">
|
|
10
|
-
<polygon points="98,78 196,60 196,76 98,94"/>
|
|
11
|
-
<rect x="98" y="86" width="10" height="88" rx="3"/>
|
|
12
|
-
<rect x="186" y="68" width="10" height="88" rx="3"/>
|
|
13
|
-
<ellipse cx="88" cy="174" rx="21" ry="15" transform="rotate(-14 88 174)"/>
|
|
14
|
-
<ellipse cx="176" cy="156" rx="21" ry="15" transform="rotate(-14 176 156)"/>
|
|
15
|
-
</g>
|
|
16
|
-
</svg>
|