fix: unable to download - #27
This commit is contained in:
parent
3212bf3db8
commit
31a608eb52
3 changed files with 12 additions and 96 deletions
|
@ -9,7 +9,7 @@ import scoreinfo from './scoreinfo'
|
||||||
|
|
||||||
const main = (): void => {
|
const main = (): void => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!window.UGAPP || !window.UGAPP.store || !window.UGAPP.store.jmuse_settings) { return }
|
if (!window?.UGAPP?.store?.page?.data?.score) { return }
|
||||||
|
|
||||||
// init recaptcha
|
// init recaptcha
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
import { ScorePlayerData } from './types'
|
|
||||||
|
|
||||||
const scoreinfo = {
|
const scoreinfo = {
|
||||||
|
|
||||||
get playerdata (): ScorePlayerData {
|
get playerdata (): any {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
return window.UGAPP.store.page.data.score
|
||||||
return window.UGAPP.store.jmuse_settings.score_player
|
|
||||||
},
|
},
|
||||||
|
|
||||||
get id (this: typeof scoreinfo): number {
|
get id (this: typeof scoreinfo): number {
|
||||||
return this.playerdata.json.id
|
return this.playerdata.id
|
||||||
},
|
},
|
||||||
|
|
||||||
get title (this: typeof scoreinfo): string {
|
get title (this: typeof scoreinfo): string {
|
||||||
try {
|
try {
|
||||||
return this.playerdata.json.metadata.title
|
return this.playerdata.title
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
@ -27,14 +25,16 @@ const scoreinfo = {
|
||||||
|
|
||||||
get pageCount (this: typeof scoreinfo): number {
|
get pageCount (this: typeof scoreinfo): number {
|
||||||
try {
|
try {
|
||||||
return this.playerdata.json.metadata.pages
|
return this.playerdata.pages_count
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return document.querySelectorAll('img[src*=score_]').length
|
return document.querySelectorAll('img[src*=score_]').length
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get baseUrl (this: typeof scoreinfo): string {
|
get baseUrl (this: typeof scoreinfo): string {
|
||||||
return this.playerdata.urls.image_path
|
const thumbnailUrl = this.playerdata.thumbnails.original
|
||||||
|
const { origin, pathname } = new URL(thumbnailUrl)
|
||||||
|
return origin + pathname.split('/').slice(0, -1).join('/') + '/'
|
||||||
},
|
},
|
||||||
|
|
||||||
get mxlUrl (this: typeof scoreinfo): string {
|
get mxlUrl (this: typeof scoreinfo): string {
|
||||||
|
@ -42,11 +42,11 @@ const scoreinfo = {
|
||||||
},
|
},
|
||||||
|
|
||||||
get midiUrl (this: typeof scoreinfo): string {
|
get midiUrl (this: typeof scoreinfo): string {
|
||||||
return this.playerdata.urls.midi
|
return this.baseUrl + 'score.mid'
|
||||||
},
|
},
|
||||||
|
|
||||||
get mp3Url (this: typeof scoreinfo): string {
|
get mp3Url (this: typeof scoreinfo): string {
|
||||||
return this.playerdata.urls.mp3
|
return this.baseUrl + 'score.mp3'
|
||||||
},
|
},
|
||||||
|
|
||||||
get msczUrl (this: typeof scoreinfo): string {
|
get msczUrl (this: typeof scoreinfo): string {
|
||||||
|
|
84
src/types.ts
84
src/types.ts
|
@ -1,84 +0,0 @@
|
||||||
|
|
||||||
interface SourceData {
|
|
||||||
type: string; // "audio"
|
|
||||||
title: string; // "Musescore audio"
|
|
||||||
nid: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
type CommentData = any;
|
|
||||||
|
|
||||||
interface PartData {
|
|
||||||
part: {
|
|
||||||
name: string;
|
|
||||||
program: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Metadata {
|
|
||||||
title: string;
|
|
||||||
subtitle?: string;
|
|
||||||
composer?: string;
|
|
||||||
poet?: string;
|
|
||||||
pages: number;
|
|
||||||
measures: number;
|
|
||||||
lyrics: number;
|
|
||||||
chordnames: number;
|
|
||||||
keysig: number;
|
|
||||||
duration: number;
|
|
||||||
dimensions: number;
|
|
||||||
parts: PartData[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ScoreJson {
|
|
||||||
id: number;
|
|
||||||
vid: number;
|
|
||||||
dates: {
|
|
||||||
revised: number;
|
|
||||||
};
|
|
||||||
secret: string;
|
|
||||||
permalink: string;
|
|
||||||
custom_url: string;
|
|
||||||
format: string; // "0"
|
|
||||||
has_custom_audio: 0 | 1;
|
|
||||||
metadata: Metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UrlsData {
|
|
||||||
midi: string;
|
|
||||||
mp3: string;
|
|
||||||
space: string;
|
|
||||||
image_path: string;
|
|
||||||
media?: string[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface AccessControlData {
|
|
||||||
enabled: boolean;
|
|
||||||
hasAccess: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PianoKeyboardData extends AccessControlData {
|
|
||||||
midiUrl: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PianoRollData extends AccessControlData {
|
|
||||||
resourcesUrl: string;
|
|
||||||
feedbackUrl: string;
|
|
||||||
forceShow: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ScorePlayerData {
|
|
||||||
embed: boolean;
|
|
||||||
sources: SourceData[];
|
|
||||||
default_source?: SourceData;
|
|
||||||
mixer?: string;
|
|
||||||
secondaryMixer?: string;
|
|
||||||
bucket?: string; // "https://musescore.com/static/musescore/scoredata"
|
|
||||||
json: ScoreJson;
|
|
||||||
render_vector: boolean;
|
|
||||||
comments: CommentData[];
|
|
||||||
score_id: number;
|
|
||||||
urls: UrlsData;
|
|
||||||
sendEvents?: boolean;
|
|
||||||
pianoKeyboard: PianoKeyboardData;
|
|
||||||
pianoRoll: PianoRollData;
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue