mirror of
https://git.stupid.fish/teidesu/scripts.git
synced 2025-07-28 02:32:11 +10:00
chore: update public repo
This commit is contained in:
parent
874e1952e3
commit
ce9f435ef2
3 changed files with 70 additions and 26 deletions
|
@ -5,7 +5,7 @@ import { join } from 'node:path'
|
|||
import kuromoji from 'kuromoji'
|
||||
import { isKana, toRomaji } from 'wanakana'
|
||||
|
||||
import { fetchSongs, navidromeFfetch as ffetch } from '../../utils/navidrome.ts'
|
||||
import { fetchSongs, fetchSongsIter } from '../../utils/navidrome.ts'
|
||||
|
||||
const WHITELIST_KEYS = new Set([
|
||||
// actual different tracks with the same title
|
||||
|
@ -53,8 +53,6 @@ function clean(s: string) {
|
|||
return str
|
||||
}
|
||||
|
||||
const CHUNK_SIZE = 1000
|
||||
|
||||
function getSongKey(song: NavidromeSong) {
|
||||
return JSON.stringify([
|
||||
clean(song.artist),
|
||||
|
@ -64,23 +62,20 @@ function getSongKey(song: NavidromeSong) {
|
|||
|
||||
const seen = new Map<string, NavidromeSong[]>()
|
||||
|
||||
for (let offset = 0; ; offset += CHUNK_SIZE) {
|
||||
const songs = await fetchSongs(offset, CHUNK_SIZE)
|
||||
if (songs.length === 0) break
|
||||
|
||||
for (const song of songs) {
|
||||
const key = getSongKey(song)
|
||||
if (WHITELIST_KEYS.has(key)) continue
|
||||
let arr = seen.get(key)
|
||||
if (!arr) {
|
||||
arr = []
|
||||
seen.set(key, arr)
|
||||
}
|
||||
|
||||
arr.push(song)
|
||||
for await (const song of fetchSongsIter({
|
||||
onChunkProcessed: (page, items) => {
|
||||
console.log('⌛ fetched chunk %d (%d items)', page, items)
|
||||
},
|
||||
})) {
|
||||
const key = getSongKey(song)
|
||||
if (WHITELIST_KEYS.has(key)) continue
|
||||
let arr = seen.get(key)
|
||||
if (!arr) {
|
||||
arr = []
|
||||
seen.set(key, arr)
|
||||
}
|
||||
|
||||
console.log('⌛ fetched chunk %d (%d items)', Math.floor(offset / CHUNK_SIZE), songs.length)
|
||||
arr.push(song)
|
||||
}
|
||||
|
||||
const keysSorted = Array.from(seen.keys()).sort()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue