From b1084b69e95729dd283b153a3108b065bca94fd3 Mon Sep 17 00:00:00 2001 From: Davi Nomoeh Dani Date: Fri, 10 Jun 2022 21:41:23 +0700 Subject: [PATCH] Fix source name & add lyrics title (#11) * fix source name, add title * bump version v2.4.1 --- package.json | 2 +- src/lib/songlyrics.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 75525d9..ff2450b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "songlyrics", - "version": "2.4.0", + "version": "2.4.1", "description": "Find a lyrics just enter the song title", "keywords": [ "lyrics", diff --git a/src/lib/songlyrics.ts b/src/lib/songlyrics.ts index eea5fe8..0eee308 100644 --- a/src/lib/songlyrics.ts +++ b/src/lib/songlyrics.ts @@ -6,6 +6,7 @@ import { makeSources } from '../sources' const cleanTitleRegexp = /\s(-.+|\[.+\]|\(.+\))/g const cleanTitle = (title: string) => title.replace(cleanTitleRegexp, '').trim() export type TLyrics = { + title: string lyrics: string source: { name: string @@ -29,9 +30,10 @@ export const songlyrics = async ( const html = await makeRequest(new URL(ddgResult.c)) const lyrics = await source.parse(htmlParser(html)) return { + title: ddgResult.t.replace(/\|.+/g, '').trim(), lyrics, source: { - name: ddgResult.t.replace(/\|.+/g, '').trim(), + name: source.name, url: ddgResult.i, link: ddgResult.c, },