feat: make exception for voice 043 in kr and en
This commit is contained in:
@@ -251,10 +251,16 @@ export default class Voice {
|
||||
|
||||
#nextVoice() {
|
||||
const getVoiceId = () => {
|
||||
const id =
|
||||
this.#voice.list[
|
||||
Math.floor(Math.random() * this.#voice.list.length)
|
||||
]
|
||||
let list = this.#voice.list
|
||||
if (
|
||||
this.#config.language === 'EN' ||
|
||||
this.#config.language === 'KR'
|
||||
) {
|
||||
// filter out CN_043 as this voice is not available in en and kr
|
||||
list = list.filter((item) => item !== 'CN_043')
|
||||
}
|
||||
const id = list[Math.floor(Math.random() * list.length)]
|
||||
console.log(id, list, this.#config.language)
|
||||
return id === this.#voice.id.last ? getVoiceId() : id
|
||||
}
|
||||
this.#playVoice(getVoiceId())
|
||||
|
||||
@@ -7,3 +7,6 @@ item_to_download:
|
||||
- char_128
|
||||
additional_regex:
|
||||
- ^(?!(avg|charpack))(.*)$
|
||||
servers:
|
||||
- name: cn
|
||||
url: https://ak-conf.hypergryph.com/config/prod/official/network_config
|
||||
@@ -7,21 +7,43 @@ import config from '../index.ts'
|
||||
import type { UpdateList, ItemToDownload, AbInfosItem } from '../types.ts'
|
||||
|
||||
export default async (dataDir: string) => {
|
||||
const pidSet: Set<string> = new Set()
|
||||
const versionRes: Response = await fetch(
|
||||
'https://ak-conf.hypergryph.com/config/prod/official/Android/version'
|
||||
await Promise.all(
|
||||
config.servers.map(async (server) => {
|
||||
const networkConfResp = await fetch(server.url)
|
||||
const networkConf = JSON.parse(
|
||||
(await networkConfResp.json()).content.replace('\\', '')
|
||||
)
|
||||
const funcVer = networkConf.funcVer
|
||||
const networkConfUrls = networkConf.configs[funcVer].network
|
||||
await download(dataDir, {
|
||||
hv: networkConfUrls.hv.replace('{0}', 'Android'),
|
||||
hu: networkConfUrls.hu,
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const download = async (
|
||||
dataDir: string,
|
||||
urls: {
|
||||
hv: string
|
||||
hu: string
|
||||
}
|
||||
) => {
|
||||
const pidSet: Set<string> = new Set()
|
||||
const versionRes: Response = await fetch(urls.hv)
|
||||
const version: string = (await versionRes.json()).resVersion
|
||||
const lpacksRes: Response = await fetch(
|
||||
`https://ak.hycdn.cn/assetbundle/official/Android/assets/${version}/hot_update_list.json`
|
||||
`${urls.hu}/Android/assets/${version}/hot_update_list.json`
|
||||
)
|
||||
const updateList: UpdateList = await lpacksRes.json()
|
||||
const itemToDownload: Set<ItemToDownload> = new Set(config.item_to_download)
|
||||
updateList.abInfos.map((item: AbInfosItem) => {
|
||||
if (item.name.includes(config.dynchars)) {
|
||||
const id = getOperatorId(item.name).replace('.ab', '')
|
||||
const alternativeId = getOperatorAlternativeId(id)
|
||||
itemToDownload.add(id)
|
||||
itemToDownload.add(getOperatorAlternativeId(id))
|
||||
itemToDownload.add(alternativeId)
|
||||
}
|
||||
})
|
||||
mapping.musicFiles.map((item) => {
|
||||
@@ -42,7 +64,7 @@ export default async (dataDir: string) => {
|
||||
pidSet.forEach((item) => {
|
||||
lpacksToDownload.push({
|
||||
name: item,
|
||||
url: `https://ak.hycdn.cn/assetbundle/official/Android/assets/${version}/${item}.dat`,
|
||||
url: `${urls.hu}/Android/assets/${version}/${item}.dat`,
|
||||
})
|
||||
})
|
||||
const regexs = []
|
||||
|
||||
@@ -2,6 +2,10 @@ export type Config = {
|
||||
dynchars: string
|
||||
item_to_download: ItemToDownload[]
|
||||
additional_regex: string[]
|
||||
servers: {
|
||||
name: 'cn' | 'jp' | 'en' | 'kr'
|
||||
url: string
|
||||
}[]
|
||||
}
|
||||
|
||||
export type ItemToDownload = string
|
||||
|
||||
@@ -156,10 +156,26 @@ export const build = async (namesToBuild: string[]) => {
|
||||
)
|
||||
const voiceFileList = file.readdirSync(voiceSubFolder)
|
||||
voiceList[voiceSubFolderMapping.lookup_region].map((item) => {
|
||||
if (!voiceFileList.includes(`${item}.ogg`))
|
||||
// an exception for detecting file existence
|
||||
if (
|
||||
item.endsWith('043') &&
|
||||
voiceFileList.includes(`${item}.ogg`) &&
|
||||
(voiceSubFolderMapping.name === 'kr' ||
|
||||
voiceSubFolderMapping.name === 'en')
|
||||
) {
|
||||
console.log(
|
||||
`Voice folder ${voiceSubFolderMapping.name} for ${name} has ${item}.ogg`
|
||||
)
|
||||
}
|
||||
if (
|
||||
!voiceFileList.includes(`${item}.ogg`) &&
|
||||
// make an exception
|
||||
!item.endsWith('043')
|
||||
) {
|
||||
err.push(
|
||||
`Voice folder ${voiceSubFolderMapping.name} for ${name} is missing ${item}.ogg`
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export const unzipDownload = async (
|
||||
retry.map(
|
||||
throttle(async (item) => {
|
||||
const name = item.name
|
||||
console.log(`Downloading ${name}`)
|
||||
console.log(`Downloading ${name} to ${targetDir}`)
|
||||
const zip = await fetch(item.url)
|
||||
.then((resp) => {
|
||||
const status = resp.status
|
||||
@@ -114,7 +114,9 @@ export const unzipDownload = async (
|
||||
const readStream = await entry.openReadStream()
|
||||
const writeStream = fs.createWriteStream(filePath)
|
||||
await pipeline(readStream, writeStream)
|
||||
console.log(`Finish Writing to ${entry.filename}`)
|
||||
console.log(
|
||||
`Finish Writing to ${targetDir}/${entry.filename}`
|
||||
)
|
||||
}
|
||||
} finally {
|
||||
await zip.close()
|
||||
|
||||
Reference in New Issue
Block a user