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
96426d01c1
commit
68a2d17239
5 changed files with 50 additions and 7 deletions
42
scripts/infra/navidrome/find-broken.ts
Normal file
42
scripts/infra/navidrome/find-broken.ts
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { $, ProcessOutput } from 'zx'
|
||||||
|
import { fetchSongsIter } from '../../../utils/navidrome.ts'
|
||||||
|
import { asyncPool } from '@fuman/utils'
|
||||||
|
import { join } from 'path/posix'
|
||||||
|
|
||||||
|
// async function checkIfBroken(path: string) {
|
||||||
|
// const r = await $`ffprobe -v error -show_entries stream=codec_type,codec_name,index:stream_tags=title,language -of json ${path}`.json()
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for await (const song of fetchSongsIter()) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
const broken: string[] = []
|
||||||
|
|
||||||
|
await asyncPool(fetchSongsIter({
|
||||||
|
onChunkProcessed: (page, items) => {
|
||||||
|
console.log(`Processed page ${page} with ${items} items`)
|
||||||
|
},
|
||||||
|
}), async (song) => {
|
||||||
|
const fullPath = join(song.libraryPath, song.path)
|
||||||
|
const path = fullPath.replace('/music/s3/', '/mnt/tank/enc/media/music/')
|
||||||
|
try {
|
||||||
|
const r = await $`ffmpeg -v error -i ${path} -f null -`.quiet()
|
||||||
|
if (r.exitCode !== 0 || r.stderr.trim() !== '') throw r
|
||||||
|
} catch (e) {
|
||||||
|
if (!(e instanceof ProcessOutput)) throw e
|
||||||
|
|
||||||
|
console.log('%s - %s (%s) seems broken:', song.artist, song.title, path)
|
||||||
|
console.log(e.stderr)
|
||||||
|
broken.push(path)
|
||||||
|
}
|
||||||
|
}, { limit: 8 })
|
||||||
|
|
||||||
|
|
||||||
|
if (broken.length > 0) {
|
||||||
|
console.log('Found %d broken files:', broken.length)
|
||||||
|
for (const path of broken) {
|
||||||
|
console.log(' %s', path)
|
||||||
|
}
|
||||||
|
process.exit(1)
|
||||||
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
import type { NavidromeSong } from '../../utils/navidrome.ts'
|
import type { NavidromeSong } from '../../../utils/navidrome.ts'
|
||||||
import { createRequire } from 'node:module'
|
import { createRequire } from 'node:module'
|
||||||
|
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import kuromoji from 'kuromoji'
|
import kuromoji from 'kuromoji'
|
||||||
import { isKana, toRomaji } from 'wanakana'
|
import { isKana, toRomaji } from 'wanakana'
|
||||||
|
|
||||||
import { fetchSongs, fetchSongsIter } from '../../utils/navidrome.ts'
|
import { fetchSongsIter } from '../../../utils/navidrome.ts'
|
||||||
|
|
||||||
const WHITELIST_KEYS = new Set([
|
const WHITELIST_KEYS = new Set([
|
||||||
// actual different tracks with the same title
|
// actual different tracks with the same title
|
|
@ -1,10 +1,10 @@
|
||||||
import { readFile, rm } from 'node:fs/promises'
|
import { readFile, rm } from 'node:fs/promises'
|
||||||
import { join } from 'node:path'
|
import { join } from 'node:path'
|
||||||
import { $ } from 'zx'
|
import { $ } from 'zx'
|
||||||
import { downloadStream } from '../../utils/fetch.ts'
|
import { downloadStream } from '../../../utils/fetch.ts'
|
||||||
import { getEnv } from '../../utils/misc.ts'
|
import { getEnv } from '../../../utils/misc.ts'
|
||||||
import { fetchSongs } from '../../utils/navidrome.ts'
|
import { fetchSongs } from '../../../utils/navidrome.ts'
|
||||||
import { WebdavClient } from '../../utils/webdav.ts'
|
import { WebdavClient } from '../../../utils/webdav.ts'
|
||||||
|
|
||||||
const webdav = new WebdavClient({
|
const webdav = new WebdavClient({
|
||||||
baseUrl: getEnv('NAVIDROME_WEBDAV_ENDPOINT'),
|
baseUrl: getEnv('NAVIDROME_WEBDAV_ENDPOINT'),
|
|
@ -1,4 +1,4 @@
|
||||||
import { fetchSongs, fetchSongsIter } from '../../utils/navidrome.ts'
|
import { fetchSongs, fetchSongsIter } from '../../../utils/navidrome.ts'
|
||||||
|
|
||||||
let count = 0
|
let count = 0
|
||||||
let totalSize = 0
|
let totalSize = 0
|
|
@ -30,6 +30,7 @@ export const NavidromeSong = z.object({
|
||||||
albumArtist: z.string(),
|
albumArtist: z.string(),
|
||||||
artist: z.string(),
|
artist: z.string(),
|
||||||
path: z.string(),
|
path: z.string(),
|
||||||
|
libraryPath: z.string(),
|
||||||
duration: z.number(),
|
duration: z.number(),
|
||||||
size: z.number(),
|
size: z.number(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue