From cf53ed76f353190ae2128198e8115a6175fda49f Mon Sep 17 00:00:00 2001 From: mebtte Date: Fri, 21 Jun 2024 21:58:02 +0800 Subject: [PATCH 1/3] upgrade react-lrc --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index ab20c418..95a6a5ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -121,7 +121,7 @@ "react-icons": "^4.9.0", "react-json-view": "^1.21.3", "react-list": "^0.8.17", - "react-lrc": "^3.1.2", + "react-lrc": "^3.2.1", "react-router-dom": "^6.3.0", "react-select": "^5.7.7", "react-slider": "^1.1.4", @@ -17205,9 +17205,9 @@ } }, "node_modules/react-lrc": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/react-lrc/-/react-lrc-3.1.2.tgz", - "integrity": "sha512-94vyz0kqQWnP2KcWKWHubGD2FNaMfAMqGvlYUxajhJwTVM1tKs2h9DP6kGGCblL20Y6jgFK3hl0lVexhvaOYjg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/react-lrc/-/react-lrc-3.2.1.tgz", + "integrity": "sha512-CRmjtFjjL6Y4RLGSgBxpP7RD9rAJqLLJeRKbC7TYzBFxWFQysOzc2j1dtjGc8rOsOMz6Pfeh4352qUh97dBhZA==", "dev": true, "dependencies": { "clrc": "^3.1.4", diff --git a/package.json b/package.json index 7b822a8e..99f439e6 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "react-icons": "^4.9.0", "react-json-view": "^1.21.3", "react-list": "^0.8.17", - "react-lrc": "^3.1.2", + "react-lrc": "^3.2.1", "react-router-dom": "^6.3.0", "react-select": "^5.7.7", "react-slider": "^1.1.4", From 1243aac1f9fa11a4318a63fbaff6c4f07c74e6e5 Mon Sep 17 00:00:00 2001 From: mebtte Date: Sun, 21 Jul 2024 22:51:27 +0800 Subject: [PATCH 2/3] feat: get music name from filename automatically --- .../my_music/create_music_dialog/index.tsx | 20 ++++--------------- .../my_music/create_music_dialog/utils.ts | 9 +++++++++ shared/utils/get_music_file_metadata.ts | 10 +--------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/index.tsx b/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/index.tsx index f779ab76..7156f700 100644 --- a/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/index.tsx +++ b/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/index.tsx @@ -40,7 +40,7 @@ import playerEventemitter, { } from '../../../eventemitter'; import { Singer } from './constants'; import upperCaseFirstLetter from '#/utils/upper_case_first_letter'; -import { base64ToCover, canAudioPlay } from './utils'; +import { base64ToCover, canAudioPlay, getMusicNameFromFilename } from './utils'; const maskProps: { style: CSSProperties } = { style: { zIndex: ZIndex.DIALOG }, @@ -103,8 +103,8 @@ function CreateMusicDialog() { getMusicFileMetadata(a) .then((metadata) => { const { title, artist } = metadata; - if (!name && title) { - setName(title); + if (!name) { + setName(title || getMusicNameFromFilename(a.name)); } if (!singerList.length && artist) { searchSingerRequest({ @@ -155,11 +155,7 @@ function CreateMusicDialog() { }); try { - const { - // lyric, - picture, - year, - } = await getMusicFileMetadata(asset); + const { picture, year } = await getMusicFileMetadata(asset); const updateCover = async (pb: string) => { const coverBlob = await base64ToCover(pb); const { id: assetId } = await uploadAsset( @@ -175,14 +171,6 @@ function CreateMusicDialog() { }; await Promise.all([ - // musicType === MusicType.SONG && lyric - // ? await updateMusic({ - // id, - // key: AllowUpdateKey.LYRIC, - // value: [lyric], - // requestMinimalDuration: 0, - // }) - // : null, picture ? updateCover(picture.dataURI) : null, year ? updateMusic({ diff --git a/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/utils.ts b/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/utils.ts index 025e2d8a..335e02bc 100644 --- a/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/utils.ts +++ b/apps/pwa/src/pages/player/pages/my_music/create_music_dialog/utils.ts @@ -40,3 +40,12 @@ export function canAudioPlay(file: File) { URL.revokeObjectURL(url); }); } + +export function getMusicNameFromFilename(filename: string) { + const lastIndex = filename.lastIndexOf('.'); + return lastIndex === -1 + ? filename + : lastIndex === 0 + ? '' + : filename.slice(0, lastIndex); +} diff --git a/shared/utils/get_music_file_metadata.ts b/shared/utils/get_music_file_metadata.ts index 64c563ce..ba09cc77 100644 --- a/shared/utils/get_music_file_metadata.ts +++ b/shared/utils/get_music_file_metadata.ts @@ -1,7 +1,6 @@ import jsmediatags from 'jsmediatags'; interface Metadata { - // lyric?: string; title?: string; artist?: string; picture?: { @@ -21,18 +20,11 @@ function getMusicFileMetadata(file: File | string) { return new Promise((resolve, reject) => { jsmediatags.read(file, { onSuccess: async (metadata) => { - const { - // lyrics, - picture, - title, - artist, - year, - } = metadata.tags; + const { picture, title, artist, year } = metadata.tags; return resolve({ title, artist, - // lyric: lyrics, picture: picture ? { dataURI: pictureToDataURI(picture), From fa5fb932dc283c2c5c15a95484e4ecfb4742bedc Mon Sep 17 00:00:00 2001 From: mebtte Date: Mon, 22 Jul 2024 23:37:10 +0800 Subject: [PATCH 3/3] update readme --- readme.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/readme.md b/readme.md index 88321f4b..f545877b 100644 --- a/readme.md +++ b/readme.md @@ -19,7 +19,6 @@ A multi-user music service for self-hosting. - Search of music, singer, musicbill and lyric - Support of Two-Factor Authentication - [PWA](https://developer.mozilla.org/docs/Web/Progressive_web_apps) supports both desktop and mobile -- [Native client for iPhone/iPad/macOS](https://github.com/mebtte/cicada-swift)(under development) - Support of building APP from [HTTP API](https://www.postman.com/cicada-player/workspace/cicada-v2) ## Deployment @@ -203,13 +202,6 @@ UPDATE user SET twoFASecret = NULL WHERE username = ; -
- Why can't play next music on iOS/iPadOS automatically ? - -Because compatibility of PWA is broken on iOS/iPadOS, there is a plan to develop a App for iOS/iPadOS but it is uncertain. - -
- ## License [GPL](./license)