feat: mscz files are now fully on IPFS
ipns://QmSdXtvzC8v8iTTZuj5cVmiugnzbR1QATYRcGix4bBsioP/<id>.mscz
This commit is contained in:
parent
d1fc51b362
commit
d79651a751
2 changed files with 8 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
|||
|
||||
import * as recaptcha from './recaptcha'
|
||||
import { saveAs } from './utils'
|
||||
import scoreinfo from './scoreinfo'
|
||||
|
||||
|
@ -9,8 +8,7 @@ export const fetchMscz = async (): Promise<ArrayBuffer> => {
|
|||
if (!msczBufferP) {
|
||||
const url = scoreinfo.msczUrl
|
||||
msczBufferP = (async (): Promise<ArrayBuffer> => {
|
||||
const token = await recaptcha.execute()
|
||||
const r = await fetch(url + token)
|
||||
const r = await fetch(url)
|
||||
const data = await r.arrayBuffer()
|
||||
return data
|
||||
})()
|
||||
|
|
|
@ -13,6 +13,8 @@ export const ugappJsStore: Record<string, any> | null = (() => {
|
|||
}
|
||||
})()
|
||||
|
||||
const IPNS_KEY = 'QmSdXtvzC8v8iTTZuj5cVmiugnzbR1QATYRcGix4bBsioP'
|
||||
|
||||
export const scoreinfo = {
|
||||
|
||||
get playerdata (): any {
|
||||
|
@ -65,9 +67,12 @@ export const scoreinfo = {
|
|||
return origin + pathname.split('/').slice(0, -1).join('/') + '/'
|
||||
},
|
||||
|
||||
get msczIpfsRef (this: typeof scoreinfo): string {
|
||||
return `/ipns/${IPNS_KEY}/${this.id}.mscz`
|
||||
},
|
||||
|
||||
get msczUrl (this: typeof scoreinfo): string {
|
||||
// https://github.com/Xmader/cloudflare-worker-musescore-mscz
|
||||
return `https://musescore.now.sh/api/mscz?id=${this.id}&token=`
|
||||
return `https://ipfs.infura.io:5001/api/v0/cat?arg=${this.msczIpfsRef}`
|
||||
},
|
||||
|
||||
get sheetImgType (): 'svg' | 'png' {
|
||||
|
|
Loading…
Reference in a new issue