Skip to content

Commit

Permalink
Merge pull request #133 from mebtte/beta
Browse files Browse the repository at this point in the history
improve music-creating
  • Loading branch information
mebtte committed Jul 25, 2024
2 parents 678bec0 + fa5fb93 commit 5b98c73
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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(
Expand All @@ -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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 0 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -203,13 +202,6 @@ UPDATE user SET twoFASecret = NULL WHERE username = <username>;

</details>

<details>
<summary>Why can't play next music on iOS/iPadOS automatically ?</summary>

Because compatibility of PWA is broken on iOS/iPadOS, there is a plan to develop a App for iOS/iPadOS but it is uncertain.

</details>

## License

[GPL](./license)
Expand Down
10 changes: 1 addition & 9 deletions shared/utils/get_music_file_metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import jsmediatags from 'jsmediatags';

interface Metadata {
// lyric?: string;
title?: string;
artist?: string;
picture?: {
Expand All @@ -21,18 +20,11 @@ function getMusicFileMetadata(file: File | string) {
return new Promise<Metadata>((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),
Expand Down

0 comments on commit 5b98c73

Please sign in to comment.