feat: updates

This commit is contained in:
qier222 2023-02-05 03:36:33 +08:00
parent ccebe0a67a
commit 9a52681687
No known key found for this signature in database
37 changed files with 160 additions and 55332 deletions

View file

@ -3,12 +3,12 @@ import AutoLoad, { AutoloadPluginOptions } from '@fastify/autoload'
import { FastifyPluginAsync } from 'fastify'
const app: FastifyPluginAsync<AutoloadPluginOptions> = async (fastify, opts) => {
void fastify.register(AutoLoad, {
fastify.register(AutoLoad, {
dir: join(__dirname, 'plugins'),
options: opts,
})
void fastify.register(AutoLoad, {
fastify.register(AutoLoad, {
dir: join(__dirname, 'routes'),
options: opts,
})

View file

@ -82,7 +82,6 @@ const album: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
method: 'GET',
url: `/albums/${album.id}`,
params: {
'fields[albums]': 'editorialNotes',
'omit[resource:albums]': 'relationships',
l: lang === 'zh-CN' ? 'en-US' : 'zh-CN',
},
@ -114,7 +113,12 @@ const album: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
.create({
data: {
...data,
editorialNote: { create: editorialNote },
editorialNote: {
connectOrCreate: {
where: { id: data.id },
create: editorialNote,
},
},
},
})
.catch(e => console.error(e))

View file

@ -102,7 +102,12 @@ const artist: FastifyPluginAsync = async (fastify, opts): Promise<void> => {
.create({
data: {
...data,
artistBio: { create: artistBio },
artistBio: {
connectOrCreate: {
where: { id: data.id },
create: artistBio,
},
},
},
})
.catch(e => console.error(e))

View file

@ -1,17 +1,11 @@
import axios, {
AxiosError,
AxiosInstance,
AxiosRequestConfig,
AxiosResponse,
} from 'axios'
import axios, { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios'
export const baseURL = 'https://amp-api.music.apple.com/v1/catalog/us'
export const headers = {
Authority: 'amp-api.music.apple.com',
Accept: '*/*',
Authorization:
'Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IldlYlBsYXlLaWQifQ.eyJpc3MiOiJBTVBXZWJQbGF5IiwiaWF0IjoxNjYxNDQwNDMyLCJleHAiOjE2NzY5OTI0MzIsInJvb3RfaHR0cHNfb3JpZ2luIjpbImFwcGxlLmNvbSJdfQ.z4BMv9_O4MpMK2iFhYkDqPsx53soPSnlXXK3jm99pHqGOrZADvTgEUw2U7_B1W0MAtFiWBYhYcGvWrzaOig6Bw',
Authorization: process.env.APPLE_MUSIC_TOKEN || '',
Referer: 'https://music.apple.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',