diff --git a/README.md b/README.md index e0aac44..1f5a8ca 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ SyncLyrics allows you to get the plain, line synced and word synced lyrics of an **Installation**: `npm i @stef-0012/synclyrics`. +![NPM Version](https://img.shields.io/npm/v/%40stef-0012%2Fsynclyrics?style=flat&labelColor=%23CC3534) + # Usage ```js diff --git a/__tests__/test3.js b/__tests__/test3.js new file mode 100644 index 0000000..cbebced --- /dev/null +++ b/__tests__/test3.js @@ -0,0 +1,17 @@ +const { SyncLyrics } = require('../dist/index.js') + +const LyricsManager = new SyncLyrics() + +LyricsManager.getLyrics({ + artist: "Matt Hansen", + track: "something to remember", + album: "something to remember" +}).then(song => { + const lyrics = song.lyrics.lineSynced.lyrics + + console.log(lyrics) + + const parsed = LyricsManager.parseLyrics(lyrics) + + console.log(parsed) +}) \ No newline at end of file diff --git a/docs/classes/SyncLyrics.html b/docs/classes/SyncLyrics.html index 61d4de0..bbb367c 100644 --- a/docs/classes/SyncLyrics.html +++ b/docs/classes/SyncLyrics.html @@ -1,4 +1,4 @@ -SyncLyrics | SyncLyrics - v2.5.8

Class SyncLyrics

Constructors

constructor +SyncLyrics | SyncLyrics - v2.5.9

Class SyncLyrics

Constructors

Properties

_fetching _trackId cache @@ -38,20 +38,20 @@

Returns SyncLyrics

let mxmToken;

const LyricsManager = new SyncLyrics({
cache: new Map(), // Anything that can store data and has a .set(K, V), .get(K) and .has(K) values
logLevel: 'none', // One of "none" | "info" | "warn" | "error" | "debug"
instrumentalLyricsIndicator: "", // Any string
sources: ["musixmatch", "lrclib", "netease"], // An array with atleast one of those sources
saveMusixmatchToken: (tokenData) => { // A custom function to save the Musixmatch token, otherwise it'll skip Musixmatch fetch
mxmToken = tokenData;
},
getMusixmatchToken: () => { // A custom function to save the Musixmatch token, otherwise it'll skip Musixmatch fetch
return mxmToken;
},
})
-

Properties

_fetching: boolean

Whetever it is fetching a song currently

-
_trackId: null | string

Used for the logging within the different functions and to fetch the track's data from the cache if avaible

-
cache: Cache<undefined | null | string, undefined | null | CacheLyrics>

Any method that can store data and has .set(), .get() and .has() functions

-
getMusixmatchToken: undefined | null | (() =>
    | undefined
    | null
    | TokenData
    | Promise<undefined | null | TokenData>)

Function used to fetch the Musixmatch token (required to fetch the lyrics data from Musixmatch)

-
instrumentalLyricsIndicator: string

The character to use for instrumental lyrics (more than 3 seconds of music without any voice)

-
logLevel: LogLevel

The level of the logging

-
lyrics: undefined | null | string

The fetched lyrics, used for the .parse() method in the LineSyncedLyricsData

-
saveMusixmatchToken: undefined | null | ((tokenData: TokenData) => void | Promise<void>)

Function used to save the Musixmatch token (required to fetch the lyrics data from Musixmatch)

-
sources: Sources

Array of sources to use, in the order they have to be fetched

-

Methods

  • Fetches the line synced lyrics of the song from Musixmatch, only if the search result specifies the song has line synced lyrics

    +

Properties

_fetching: boolean

Whetever it is fetching a song currently

+
_trackId: null | string

Used for the logging within the different functions and to fetch the track's data from the cache if avaible

+
cache: Cache<undefined | null | string, undefined | null | CacheLyrics>

Any method that can store data and has .set(), .get() and .has() functions

+
getMusixmatchToken: undefined | null | (() =>
    | undefined
    | null
    | TokenData
    | Promise<undefined | null | TokenData>)

Function used to fetch the Musixmatch token (required to fetch the lyrics data from Musixmatch)

+
instrumentalLyricsIndicator: string

The character to use for instrumental lyrics (more than 3 seconds of music without any voice)

+
logLevel: LogLevel

The level of the logging

+
lyrics: undefined | null | string

The fetched lyrics, used for the .parse() method in the LineSyncedLyricsData

+
saveMusixmatchToken: undefined | null | ((tokenData: TokenData) => void | Promise<void>)

Function used to save the Musixmatch token (required to fetch the lyrics data from Musixmatch)

+
sources: Sources

Array of sources to use, in the order they have to be fetched

+

Methods

  • Fetches the line synced lyrics of the song from Musixmatch, only if the search result specifies the song has line synced lyrics

    Parameters

    Returns Promise<null | string>

    The Track's Lyrics if avaible

    -
  • Fetches the song's lyrics based on the search results

    +
  • Fetches the line synced lyrics from Netease

    +
  • Fetches the line synced lyrics from Netease

    Parameters

    Returns Promise<null | string>

    The track's line synced lyrics if avaible

    -
  • Fetches the plain lyrics of the song from Musixmatch, only if the search result specifies the song has plain lyrics

    +
  • Fetches the plain lyrics of the song from Musixmatch, only if the search result specifies the song has plain lyrics

    Parameters

    Returns Promise<null | string>

    The Track's Lyrics if avaible

    -
  • Fetches the line word lyrics of the song from Musixmatch, only if the search result specifies the song has word synced lyrics

    +
  • Removes useless metadata returned by Netease

    +
  • Removes useless metadata returned by Netease

    Parameters

    • slyrics: string

      Lyrics returned by Netease

    Returns string

    Netease returned lyrics without extra metadata

    -
  • Searchs the Netease catalog with the data provided in the metadata

    +
  • Logs the text with a purple "DEBUG: " prefix

    +
  • Logs the text with a purple "DEBUG: " prefix

    Parameters

    • Rest...args: any

      Text to log

    Returns void

    Nothing

    -
  • Logs the text with a red "ERROR: " prefix

    +
  • Logs the text with a red "ERROR: " prefix

    Parameters

    • Rest...args: any

      Text to log

    Returns void

    Nothing

    -
  • Fetches from the cache or the sources, the song based on the track's metadata or ID

    Parameters

    Returns Promise<LyricsOutput>

    The lyrics of the song when avaible

    const LyricsManager = new SyncLyrics()

    LyricsManager.getLyrics({
    track: "the old me", // Song name
    artist: "Henry Moodie", // Song artist
    album: "good old days", // Song album
    length: 175000, // Song duration, in ms
    }).then(console.log)
    -
+
diff --git a/docs/functions/normalize.html b/docs/functions/normalize.html index 1adf1a1..ec84a84 100644 --- a/docs/functions/normalize.html +++ b/docs/functions/normalize.html @@ -1,4 +1,4 @@ -normalize | SyncLyrics - v2.5.8

Function normalize

  • Parses special characters (Usually returned by Netease) into common characters

    +normalize | SyncLyrics - v2.5.9

    Function normalize

    • Parses special characters (Usually returned by Netease) into common characters

      Parameters

      • string: string

        The string to parse

      Returns string

      Parsed string with common characters

      -
    +
diff --git a/docs/index.html b/docs/index.html index 0cd1fe8..7b728a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,5 +1,6 @@ -SyncLyrics - v2.5.8

SyncLyrics - v2.5.8

@stef-0012/synclyrics (SyncLyrics)

SyncLyrics allows you to get the plain, line synced and word synced lyrics of any song avaible on Musixmatch, LrcLib.net or Netease.

+SyncLyrics - v2.5.9

SyncLyrics - v2.5.9

@stef-0012/synclyrics (SyncLyrics)

SyncLyrics allows you to get the plain, line synced and word synced lyrics of any song avaible on Musixmatch, LrcLib.net or Netease.

Installation: npm i @stef-0012/synclyrics.

+

NPM Version

Usage

const { SyncLyrics } = require("@stef-0012/synclyrics");

let mxmToken; // This is just for the custom save/get functions example

const LyricsManager = new SyncLyrics({
/* Each of those options is optional */
cache: new Map(), // Anything that can store data and has a .set(K, V), .get(K) and .has(K) values
logLevel: 'none', // One of "none" | "info" | "warn" | "error" | "debug"
instrumentalLyricsIndicator: "", // Any string
sources: ["musixmatch", "lrclib", "netease"], // An array with atleast one of those sources
saveMusixmatchToken: (tokenData) => { // A custom function to save the Musixmatch token, otherwise it'll skip Musixmatch fetch
mxmToken = tokenData;
},
getMusixmatchToken: () => { // A custom function to save the Musixmatch token, otherwise it'll skip Musixmatch fetch
return mxmToken;
},
})

LyricsManager.getLyrics({
/* Each of those options is optional but atleast one is required excluded length */
track: "the old me", // Song name
artist: "Henry Moodie", // Song artist
album: "good old days", // Song album
length: 175000, // Song duration, in ms
}).then(data => {
console.log(data)
}) // Array of objects with time as seconds and text of each line

// or

const trackId = LyricsManager.getTrackId({
/* Each of those options is optional but atleast one is required excluded length */
track: "the old me", // Song name
artist: "Henry Moodie", // Song artist
album: "good old days", // Song album
length: 175000, // Song duration, in ms
})

LyricsManager.getLyrics({
trackId: trackId
}).then(data => {
console.log(data)
})
@@ -9,4 +10,4 @@

Example Parse Output

[
{
time: 0.14,
text: 'Fifth of November, when I walked you home'
},
{
time: 8.06,
text: `That's when I nearly said it, but then said, "Forget it," and froze`
},
{
time: 15.55,
text: "Do you remember? You probably don't"
},
{
time: 23.44,
text: "'Cause the sparks in the sky took a hold of your eyes while we spoke"
},
// ..... (rest of the lyrics)
]
-
+
diff --git a/docs/interfaces/Cache.html b/docs/interfaces/Cache.html index f3097d0..7238fd4 100644 --- a/docs/interfaces/Cache.html +++ b/docs/interfaces/Cache.html @@ -1,8 +1,8 @@ -Cache | SyncLyrics - v2.5.8

Interface Cache<K, V>

Any method that can store data and has .set(), .get() and .has() functions

-
interface Cache<K, V> {
    get(key: K): undefined | null | V;
    has(key: K): boolean;
    set(key: K, value: V): void;
    [key: string]: any;
}

Type Parameters

  • K
  • V

Indexable

  • [key: string]: any

Methods

get +Cache | SyncLyrics - v2.5.9

Interface Cache<K, V>

Any method that can store data and has .set(), .get() and .has() functions

+
interface Cache<K, V> {
    get(key: K): undefined | null | V;
    has(key: K): boolean;
    set(key: K, value: V): void;
    [key: string]: any;
}

Type Parameters

  • K
  • V

Indexable

  • [key: string]: any

Methods

Methods

  • Function used to get the song's data to the cache

    -

    Parameters

    • key: K

    Returns undefined | null | V

  • Function to check if the cache has the song's data

    -

    Parameters

    • key: K

    Returns boolean

  • Function used to set the song's data to the cache

    -

    Parameters

    • key: K
    • value: V

    Returns void

+

Parameters

  • key: K

Returns undefined | null | V

  • Function to check if the cache has the song's data

    +

    Parameters

    • key: K

    Returns boolean

  • Function used to set the song's data to the cache

    +

    Parameters

    • key: K
    • value: V

    Returns void

diff --git a/docs/interfaces/CacheLineSyncedLyricsData.html b/docs/interfaces/CacheLineSyncedLyricsData.html index edcb462..dc76049 100644 --- a/docs/interfaces/CacheLineSyncedLyricsData.html +++ b/docs/interfaces/CacheLineSyncedLyricsData.html @@ -1,5 +1,5 @@ -CacheLineSyncedLyricsData | SyncLyrics - v2.5.8

Interface CacheLineSyncedLyricsDataPrivate

interface CacheLineSyncedLyricsData {
    lyrics: undefined | null | string;
    source: undefined | null | string;
}

Properties

lyrics +CacheLineSyncedLyricsData | SyncLyrics - v2.5.9

Interface CacheLineSyncedLyricsDataPrivate

interface CacheLineSyncedLyricsData {
    lyrics: undefined | null | string;
    source: undefined | null | string;
}

Properties

Properties

lyrics: undefined | null | string

Line synced lyrics in the LRC format

-
source: undefined | null | string

Lyrics source

-
+
source: undefined | null | string

Lyrics source

+
diff --git a/docs/interfaces/CacheLyrics.html b/docs/interfaces/CacheLyrics.html index b7c890a..82dbb7e 100644 --- a/docs/interfaces/CacheLyrics.html +++ b/docs/interfaces/CacheLyrics.html @@ -1,7 +1,7 @@ -CacheLyrics | SyncLyrics - v2.5.8

Interface CacheLyricsPrivate

interface CacheLyrics {
    lineSynced: CacheLineSyncedLyricsData;
    plain: PlainLyricsData;
    wordSynced: WordSyncedLyricsData;
}

Properties

lineSynced +CacheLyrics | SyncLyrics - v2.5.9

Interface CacheLyricsPrivate

interface CacheLyrics {
    lineSynced: CacheLineSyncedLyricsData;
    plain: PlainLyricsData;
    wordSynced: WordSyncedLyricsData;
}

Properties

+
diff --git a/docs/interfaces/Data.html b/docs/interfaces/Data.html index 3957273..91fd007 100644 --- a/docs/interfaces/Data.html +++ b/docs/interfaces/Data.html @@ -1,13 +1,13 @@ -Data | SyncLyrics - v2.5.8

Interface Data

interface Data {
    cache?: Cache<undefined | null | string, undefined | null | CacheLyrics>;
    getMusixmatchToken?: (() =>
        | undefined
        | null
        | TokenData
        | Promise<undefined | null | TokenData>);
    instrumentalLyricsIndicator?: string;
    logLevel?: LogLevel;
    saveMusixmatchToken?: ((tokenData: TokenData) => void | Promise<void>);
    sources?: Sources;
}

Properties

cache? +Data | SyncLyrics - v2.5.9

Interface Data

interface Data {
    cache?: Cache<undefined | null | string, undefined | null | CacheLyrics>;
    getMusixmatchToken?: (() =>
        | undefined
        | null
        | TokenData
        | Promise<undefined | null | TokenData>);
    instrumentalLyricsIndicator?: string;
    logLevel?: LogLevel;
    saveMusixmatchToken?: ((tokenData: TokenData) => void | Promise<void>);
    sources?: Sources;
}

Properties

cache?: Cache<undefined | null | string, undefined | null | CacheLyrics>

Any method that can store data and has .set(), .get() and .has() functions

-
getMusixmatchToken?: (() =>
    | undefined
    | null
    | TokenData
    | Promise<undefined | null | TokenData>)

Function used to fetch the Musixmatch token (required to fetch the lyrics data from Musixmatch)

-
instrumentalLyricsIndicator?: string

The character to use for instrumental lyrics (more than 3 seconds of music without any voice)

-
logLevel?: LogLevel

The level of the logging

-
saveMusixmatchToken?: ((tokenData: TokenData) => void | Promise<void>)

Function used to save the Musixmatch token (required to fetch the lyrics data from Musixmatch)

-
sources?: Sources

Array of sources to use, in the order they have to be fetched

-
+
getMusixmatchToken?: (() =>
    | undefined
    | null
    | TokenData
    | Promise<undefined | null | TokenData>)

Function used to fetch the Musixmatch token (required to fetch the lyrics data from Musixmatch)

+
instrumentalLyricsIndicator?: string

The character to use for instrumental lyrics (more than 3 seconds of music without any voice)

+
logLevel?: LogLevel

The level of the logging

+
saveMusixmatchToken?: ((tokenData: TokenData) => void | Promise<void>)

Function used to save the Musixmatch token (required to fetch the lyrics data from Musixmatch)

+
sources?: Sources

Array of sources to use, in the order they have to be fetched

+
diff --git a/docs/interfaces/FormattedLyric.html b/docs/interfaces/FormattedLyric.html index 735f604..eb30bbc 100644 --- a/docs/interfaces/FormattedLyric.html +++ b/docs/interfaces/FormattedLyric.html @@ -1,5 +1,5 @@ -FormattedLyric | SyncLyrics - v2.5.8

Interface FormattedLyric

interface FormattedLyric {
    text: string;
    time: number;
}

Properties

text +FormattedLyric | SyncLyrics - v2.5.9

Interface FormattedLyric

interface FormattedLyric {
    text: string;
    time: number;
}

Properties

Properties

text: string

Lyric's text

-
time: number

When the lyric starts

-
+
time: number

When the lyric starts

+
diff --git a/docs/interfaces/LineSyncedLyricsData.html b/docs/interfaces/LineSyncedLyricsData.html index 4b54517..a3c7c3e 100644 --- a/docs/interfaces/LineSyncedLyricsData.html +++ b/docs/interfaces/LineSyncedLyricsData.html @@ -1,7 +1,7 @@ -LineSyncedLyricsData | SyncLyrics - v2.5.8

Interface LineSyncedLyricsData

interface LineSyncedLyricsData {
    lyrics: undefined | null | string;
    parse: ((lyrics?: null | string) => null | FormattedLyric[]);
    source: undefined | null | string;
}

Properties

lyrics +LineSyncedLyricsData | SyncLyrics - v2.5.9

Interface LineSyncedLyricsData

interface LineSyncedLyricsData {
    lyrics: undefined | null | string;
    parse: ((lyrics?: null | string) => null | FormattedLyric[]);
    source: undefined | null | string;
}

Properties

Properties

lyrics: undefined | null | string

Line synced lyrics in the LRC format

-
parse: ((lyrics?: null | string) => null | FormattedLyric[])

Function to parse the returned lyrics into FormattedLyric

-
source: undefined | null | string

Lyrics source

-
+
parse: ((lyrics?: null | string) => null | FormattedLyric[])

Function to parse the returned lyrics into FormattedLyric

+
source: undefined | null | string

Lyrics source

+
diff --git a/docs/interfaces/LrcLibFetchResult.html b/docs/interfaces/LrcLibFetchResult.html index 6351cbf..a4adb95 100644 --- a/docs/interfaces/LrcLibFetchResult.html +++ b/docs/interfaces/LrcLibFetchResult.html @@ -1,9 +1,9 @@ -LrcLibFetchResult | SyncLyrics - v2.5.8

Interface LrcLibFetchResultPrivate

interface LrcLibFetchResult {
    lineSynced: null | string;
    plain: null | string;
    source: "lrclib.net";
    wordSynced: null;
}

Properties

lineSynced +LrcLibFetchResult | SyncLyrics - v2.5.9

Interface LrcLibFetchResultPrivate

interface LrcLibFetchResult {
    lineSynced: null | string;
    plain: null | string;
    source: "lrclib.net";
    wordSynced: null;
}

Properties

lineSynced: null | string

Line synced lyrics if avaible

-
plain: null | string

Plain lyrics if avaible

-
source
wordSynced

Always null as lrclib.net does not support word synced lyrics

-
+
plain: null | string

Plain lyrics if avaible

+
source
wordSynced

Always null as lrclib.net does not support word synced lyrics

+
diff --git a/docs/interfaces/Lyrics.html b/docs/interfaces/Lyrics.html index ef23bd2..c19f2d3 100644 --- a/docs/interfaces/Lyrics.html +++ b/docs/interfaces/Lyrics.html @@ -1,7 +1,7 @@ -Lyrics | SyncLyrics - v2.5.8

Interface Lyrics

interface Lyrics {
    lineSynced: LineSyncedLyricsData;
    plain: PlainLyricsData;
    wordSynced: WordSyncedLyricsData;
}

Properties

lineSynced +Lyrics | SyncLyrics - v2.5.9

Interface Lyrics

interface Lyrics {
    lineSynced: LineSyncedLyricsData;
    plain: PlainLyricsData;
    wordSynced: WordSyncedLyricsData;
}

Properties

+
diff --git a/docs/interfaces/LyricsOutput.html b/docs/interfaces/LyricsOutput.html index 2f6c5bf..1e691fc 100644 --- a/docs/interfaces/LyricsOutput.html +++ b/docs/interfaces/LyricsOutput.html @@ -1,13 +1,13 @@ -LyricsOutput | SyncLyrics - v2.5.8

Interface LyricsOutput

interface LyricsOutput {
    album: undefined | string;
    artist: undefined | string;
    cached: boolean;
    lyrics: Lyrics;
    track: undefined | string;
    trackId: string;
}

Properties

album +LyricsOutput | SyncLyrics - v2.5.9

Interface LyricsOutput

interface LyricsOutput {
    album: undefined | string;
    artist: undefined | string;
    cached: boolean;
    lyrics: Lyrics;
    track: undefined | string;
    trackId: string;
}

Properties

album: undefined | string

Song's album

-
artist: undefined | string

Song's artist(s)

-
cached: boolean

Whetever the song data was retrieved from the cache rather than the APIs

-
lyrics: Lyrics

Object with track's avaible lyrics

-
track: undefined | string

Song's name

-
trackId: string

Fetched track's ID

-
+
artist: undefined | string

Song's artist(s)

+
cached: boolean

Whetever the song data was retrieved from the cache rather than the APIs

+
lyrics: Lyrics

Object with track's avaible lyrics

+
track: undefined | string

Song's name

+
trackId: string

Fetched track's ID

+
diff --git a/docs/interfaces/Metadata.html b/docs/interfaces/Metadata.html index f7afa76..1b14b52 100644 --- a/docs/interfaces/Metadata.html +++ b/docs/interfaces/Metadata.html @@ -1,14 +1,14 @@ -Metadata | SyncLyrics - v2.5.8

Interface Metadata

Song's metadata

-
interface Metadata {
    album?: string;
    artist?: string;
    length?: number;
    lyricsType?: LyricType;
    track?: string;
    trackId?: string;
}

Properties

album? +Metadata | SyncLyrics - v2.5.9

Interface Metadata

Song's metadata

+
interface Metadata {
    album?: string;
    artist?: string;
    length?: number;
    lyricsType?: LyricType;
    track?: string;
    trackId?: string;
}

Properties

album?: string

Song's album

-
artist?: string

Song's artist(s)

-
length?: number

Song's duration (in ms)

-
lyricsType?: LyricType

An array of lyric types to fetch

-
track?: string

Song's name

-
trackId?: string

Song's ID (returned by getTrackId)

-
+
artist?: string

Song's artist(s)

+
length?: number

Song's duration (in ms)

+
lyricsType?: LyricType

An array of lyric types to fetch

+
track?: string

Song's name

+
trackId?: string

Song's ID (returned by getTrackId)

+
diff --git a/docs/interfaces/MusixmatchFetchResult.html b/docs/interfaces/MusixmatchFetchResult.html index 34bd267..4aea7d5 100644 --- a/docs/interfaces/MusixmatchFetchResult.html +++ b/docs/interfaces/MusixmatchFetchResult.html @@ -1,9 +1,9 @@ -MusixmatchFetchResult | SyncLyrics - v2.5.8

Interface MusixmatchFetchResultPrivate

interface MusixmatchFetchResult {
    lineSynced?: null | string;
    plain?: null | string;
    source: "Musixmatch";
    wordSynced?: null | WordSyncedLyrics[];
}

Properties

lineSynced? +MusixmatchFetchResult | SyncLyrics - v2.5.9

Interface MusixmatchFetchResultPrivate

interface MusixmatchFetchResult {
    lineSynced?: null | string;
    plain?: null | string;
    source: "Musixmatch";
    wordSynced?: null | WordSyncedLyrics[];
}

Properties

lineSynced?: null | string

Line synced lyrics if avaible

-
plain?: null | string

Plain lyrics if avaible

-
source

Musixmatch

-
wordSynced?: null | WordSyncedLyrics[]

Line synced lyrics if avaible

-
+
plain?: null | string

Plain lyrics if avaible

+
source

Musixmatch

+
wordSynced?: null | WordSyncedLyrics[]

Line synced lyrics if avaible

+
diff --git a/docs/interfaces/MusixmatchLyricsFetchResult.html b/docs/interfaces/MusixmatchLyricsFetchResult.html index f7a5197..4a0bc33 100644 --- a/docs/interfaces/MusixmatchLyricsFetchResult.html +++ b/docs/interfaces/MusixmatchLyricsFetchResult.html @@ -1,7 +1,7 @@ -MusixmatchLyricsFetchResult | SyncLyrics - v2.5.8

Interface MusixmatchLyricsFetchResultPrivate

interface MusixmatchLyricsFetchResult {
    lineSynced: null | string;
    plain: null | string;
    wordSynced: null | WordSyncedLyrics[];
}

Properties

lineSynced +MusixmatchLyricsFetchResult | SyncLyrics - v2.5.9

Interface MusixmatchLyricsFetchResultPrivate

interface MusixmatchLyricsFetchResult {
    lineSynced: null | string;
    plain: null | string;
    wordSynced: null | WordSyncedLyrics[];
}

Properties

lineSynced: null | string

Track's line synced lyrics

-
plain: null | string

Track's plain lyrics

-
wordSynced: null | WordSyncedLyrics[]

Track's word synced lyrics

-
+
plain: null | string

Track's plain lyrics

+
wordSynced: null | WordSyncedLyrics[]

Track's word synced lyrics

+
diff --git a/docs/interfaces/MusixmatchSearchResult.html b/docs/interfaces/MusixmatchSearchResult.html index 47fe625..e051a3c 100644 --- a/docs/interfaces/MusixmatchSearchResult.html +++ b/docs/interfaces/MusixmatchSearchResult.html @@ -1,11 +1,11 @@ -MusixmatchSearchResult | SyncLyrics - v2.5.8

Interface MusixmatchSearchResultPrivate

interface MusixmatchSearchResult {
    commonTrackId: string;
    hasLineSyncedLyrics: boolean;
    hasLyrics: boolean;
    hasWordSyncedLyrics: boolean;
    trackId: string;
}

Properties

commonTrackId +MusixmatchSearchResult | SyncLyrics - v2.5.9

Interface MusixmatchSearchResultPrivate

interface MusixmatchSearchResult {
    commonTrackId: string;
    hasLineSyncedLyrics: boolean;
    hasLyrics: boolean;
    hasWordSyncedLyrics: boolean;
    trackId: string;
}

Properties

commonTrackId: string

Musixmatch's commontrack_id

-
hasLineSyncedLyrics: boolean

Whetever the Musixmatch's catalogue has the song's line synced lyrics

-
hasLyrics: boolean

Whetever the Musixmatch's catalogue has the song's plain lyrics

-
hasWordSyncedLyrics: boolean

Whetever the Musixmatch's catalogue has the song's word synced lyrics

-
trackId: string

Musixmatch's track_id

-
+
hasLineSyncedLyrics: boolean

Whetever the Musixmatch's catalogue has the song's line synced lyrics

+
hasLyrics: boolean

Whetever the Musixmatch's catalogue has the song's plain lyrics

+
hasWordSyncedLyrics: boolean

Whetever the Musixmatch's catalogue has the song's word synced lyrics

+
trackId: string

Musixmatch's track_id

+
diff --git a/docs/interfaces/NeteaseFetchResult.html b/docs/interfaces/NeteaseFetchResult.html index daac5ed..2f80ca7 100644 --- a/docs/interfaces/NeteaseFetchResult.html +++ b/docs/interfaces/NeteaseFetchResult.html @@ -1,9 +1,9 @@ -NeteaseFetchResult | SyncLyrics - v2.5.8

Interface NeteaseFetchResultPrivate

interface NeteaseFetchResult {
    lineSynced: null | string;
    plain: null;
    source: "Netease";
    wordSynced: null;
}

Properties

lineSynced +NeteaseFetchResult | SyncLyrics - v2.5.9

Interface NeteaseFetchResultPrivate

interface NeteaseFetchResult {
    lineSynced: null | string;
    plain: null;
    source: "Netease";
    wordSynced: null;
}

Properties

lineSynced: null | string

Line synced lyrics if avaible

-
plain

Always null as Netease does not support word synced lyrics

-
source

Netease

-
wordSynced

Always null as Netease does not support word synced lyrics

-
+
plain

Always null as Netease does not support word synced lyrics

+
source

Netease

+
wordSynced

Always null as Netease does not support word synced lyrics

+
diff --git a/docs/interfaces/PlainLyricsData.html b/docs/interfaces/PlainLyricsData.html index b8961b6..b7d8f9b 100644 --- a/docs/interfaces/PlainLyricsData.html +++ b/docs/interfaces/PlainLyricsData.html @@ -1,5 +1,5 @@ -PlainLyricsData | SyncLyrics - v2.5.8

Interface PlainLyricsData

interface PlainLyricsData {
    lyrics: undefined | null | string;
    source: undefined | null | string;
}

Properties

lyrics +PlainLyricsData | SyncLyrics - v2.5.9

Interface PlainLyricsData

interface PlainLyricsData {
    lyrics: undefined | null | string;
    source: undefined | null | string;
}

Properties

Properties

lyrics: undefined | null | string

Lyrics as plain text

-
source: undefined | null | string

Lyrics source

-
+
source: undefined | null | string

Lyrics source

+
diff --git a/docs/interfaces/TokenData.html b/docs/interfaces/TokenData.html index fa6e5d6..ce6a88a 100644 --- a/docs/interfaces/TokenData.html +++ b/docs/interfaces/TokenData.html @@ -1,8 +1,8 @@ -TokenData | SyncLyrics - v2.5.8

Interface TokenDataPrivate

Musixmatch token data

-
interface TokenData {
    cookies: undefined | string;
    expiresAt: number;
    usertoken: string;
}

Properties

cookies +TokenData | SyncLyrics - v2.5.9

Interface TokenDataPrivate

Musixmatch token data

+
interface TokenData {
    cookies: undefined | string;
    expiresAt: number;
    usertoken: string;
}

Properties

cookies: undefined | string

Cookies used for the Musixmatch's API request

-
expiresAt: number

When the Musixmatch's usertoken expires

-
usertoken: string

Musixmatch's usertoken

-
+
expiresAt: number

When the Musixmatch's usertoken expires

+
usertoken: string

Musixmatch's usertoken

+
diff --git a/docs/interfaces/WordSyncedLyrics.html b/docs/interfaces/WordSyncedLyrics.html index bac7a8c..95946a8 100644 --- a/docs/interfaces/WordSyncedLyrics.html +++ b/docs/interfaces/WordSyncedLyrics.html @@ -1,9 +1,9 @@ -WordSyncedLyrics | SyncLyrics - v2.5.8

Interface WordSyncedLyrics

interface WordSyncedLyrics {
    end: number;
    lyric: string;
    start: number;
    syncedLyric: WordSyncedLyricsLine[];
}

Properties

end +WordSyncedLyrics | SyncLyrics - v2.5.9

Interface WordSyncedLyrics

interface WordSyncedLyrics {
    end: number;
    lyric: string;
    start: number;
    syncedLyric: WordSyncedLyricsLine[];
}

Properties

end: number

When the lyric's line ends

-
lyric: string

The lyric complete text

-
start: number

When the lyric's line starts

-
syncedLyric: WordSyncedLyricsLine[]

The lyric synced by characters

-
+
lyric: string

The lyric complete text

+
start: number

When the lyric's line starts

+
syncedLyric: WordSyncedLyricsLine[]

The lyric synced by characters

+
diff --git a/docs/interfaces/WordSyncedLyricsData.html b/docs/interfaces/WordSyncedLyricsData.html index 2970eea..b1ea0fd 100644 --- a/docs/interfaces/WordSyncedLyricsData.html +++ b/docs/interfaces/WordSyncedLyricsData.html @@ -1,5 +1,5 @@ -WordSyncedLyricsData | SyncLyrics - v2.5.8

Interface WordSyncedLyricsData

interface WordSyncedLyricsData {
    lyrics: undefined | null | WordSyncedLyrics[];
    source: undefined | null | string;
}

Properties

lyrics +WordSyncedLyricsData | SyncLyrics - v2.5.9

Interface WordSyncedLyricsData

interface WordSyncedLyricsData {
    lyrics: undefined | null | WordSyncedLyrics[];
    source: undefined | null | string;
}

Properties

Properties

lyrics: undefined | null | WordSyncedLyrics[]
source: undefined | null | string

Lyrics source

-
+
source: undefined | null | string

Lyrics source

+
diff --git a/docs/interfaces/WordSyncedLyricsLine.html b/docs/interfaces/WordSyncedLyricsLine.html index 5c39d51..8ea779d 100644 --- a/docs/interfaces/WordSyncedLyricsLine.html +++ b/docs/interfaces/WordSyncedLyricsLine.html @@ -1,5 +1,5 @@ -WordSyncedLyricsLine | SyncLyrics - v2.5.8

Interface WordSyncedLyricsLine

interface WordSyncedLyricsLine {
    character: string;
    time: number;
}

Properties

character +WordSyncedLyricsLine | SyncLyrics - v2.5.9

Interface WordSyncedLyricsLine

interface WordSyncedLyricsLine {
    character: string;
    time: number;
}

Properties

Properties

character: string

The character of the timeframe that starts at the specified time

-
time: number

When the character timeframe starts

-
+
time: number

When the character timeframe starts

+
diff --git a/docs/modules.html b/docs/modules.html index 143f334..86d9b53 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1,4 +1,4 @@ -SyncLyrics - v2.5.8

SyncLyrics - v2.5.8

Index

Classes

SyncLyrics +SyncLyrics - v2.5.9

SyncLyrics - v2.5.9

Index

Classes

Interfaces

Functions

+
diff --git a/docs/sitemap.xml b/docs/sitemap.xml index d7f0c48..6ed7a34 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -2,118 +2,118 @@ https://synclyrics.js.org/modules.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/index.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/classes/SyncLyrics.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/Cache.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/CacheLineSyncedLyricsData.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/CacheLyrics.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/Data.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/FormattedLyric.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/LineSyncedLyricsData.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/LrcLibFetchResult.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/Lyrics.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/LyricsOutput.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/Metadata.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/MusixmatchFetchResult.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/MusixmatchLyricsFetchResult.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/MusixmatchSearchResult.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/NeteaseFetchResult.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/PlainLyricsData.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/TokenData.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/WordSyncedLyrics.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/WordSyncedLyricsData.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/interfaces/WordSyncedLyricsLine.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/types/LogLevel.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/types/LyricType.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/types/Sources.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/variables/logLevels.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/variables/lyricType-1.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/variables/sources-1.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z https://synclyrics.js.org/functions/normalize.html - 2024-11-18T16:00:55.537Z + 2024-11-23T10:29:18.375Z diff --git a/docs/types/LogLevel.html b/docs/types/LogLevel.html index 0035a21..b920116 100644 --- a/docs/types/LogLevel.html +++ b/docs/types/LogLevel.html @@ -1 +1 @@ -LogLevel | SyncLyrics - v2.5.8

Type Alias LogLevel

LogLevel:
    | "none"
    | "info"
    | "warn"
    | "error"
    | "debug"
+LogLevel | SyncLyrics - v2.5.9

Type Alias LogLevel

LogLevel:
    | "none"
    | "info"
    | "warn"
    | "error"
    | "debug"
diff --git a/docs/types/LyricType.html b/docs/types/LyricType.html index e2f51d2..acebeea 100644 --- a/docs/types/LyricType.html +++ b/docs/types/LyricType.html @@ -1 +1 @@ -LyricType | SyncLyrics - v2.5.8

Type Alias LyricType

LyricType: ("plain" | "lineSynced" | "wordSynced")[]
+LyricType | SyncLyrics - v2.5.9

Type Alias LyricType

LyricType: ("plain" | "lineSynced" | "wordSynced")[]
diff --git a/docs/types/Sources.html b/docs/types/Sources.html index d968368..0f5c118 100644 --- a/docs/types/Sources.html +++ b/docs/types/Sources.html @@ -1,7 +1,7 @@ -Sources | SyncLyrics - v2.5.8

Type Alias Sources

Sources: ("musixmatch" | "lrclib" | "netease")[]

Avaible sources:

+Sources | SyncLyrics - v2.5.9

Type Alias Sources

Sources: ("musixmatch" | "lrclib" | "netease")[]

Avaible sources:

-
+
diff --git a/docs/variables/logLevels.html b/docs/variables/logLevels.html index 2983f97..dccbe96 100644 --- a/docs/variables/logLevels.html +++ b/docs/variables/logLevels.html @@ -1 +1 @@ -logLevels | SyncLyrics - v2.5.8

Variable logLevelsConst

logLevels: {
    debug: number;
    error: number;
    info: number;
    none: number;
    warn: number;
} = ...
+logLevels | SyncLyrics - v2.5.9

Variable logLevelsConst

logLevels: {
    debug: number;
    error: number;
    info: number;
    none: number;
    warn: number;
} = ...
diff --git a/docs/variables/lyricType-1.html b/docs/variables/lyricType-1.html index 50b5056..ed7e254 100644 --- a/docs/variables/lyricType-1.html +++ b/docs/variables/lyricType-1.html @@ -1 +1 @@ -lyricType | SyncLyrics - v2.5.8

Variable lyricTypeConst

lyricType: LyricType = ...
+lyricType | SyncLyrics - v2.5.9

Variable lyricTypeConst

lyricType: LyricType = ...
diff --git a/docs/variables/sources-1.html b/docs/variables/sources-1.html index aca4cb1..fa9c8dc 100644 --- a/docs/variables/sources-1.html +++ b/docs/variables/sources-1.html @@ -1 +1 @@ -sources | SyncLyrics - v2.5.8

Variable sourcesConst

sources: Sources = ...
+sources | SyncLyrics - v2.5.9

Variable sourcesConst

sources: Sources = ...
diff --git a/package-lock.json b/package-lock.json index 3df9f93..baffd2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@stef-0012/synclyrics", - "version": "2.5.8", + "version": "2.5.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@stef-0012/synclyrics", - "version": "2.5.8", + "version": "2.5.9", "license": "MIT", "dependencies": { "util": "^0.12.5" diff --git a/package.json b/package.json index 254f039..2a9f4ba 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@stef-0012/synclyrics", - "version": "2.5.8", + "version": "2.5.9", "description": "Get the plain, line synced & word synced lyrics of any song avaible on Musixmatch, LrcLib.net or Netease", "main": "dist/index.min.js", "types": "./types/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 9c05631..7f8fdc1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1643,7 +1643,7 @@ export class SyncLyrics { if (!lyricsSplit) return null; const formattedLyrics: Array = []; - let lastTime: string; + let lastTime: number; for (const index in lyricsSplit) { const lyricText = lyricsSplit[index].split(" "); @@ -1668,20 +1668,21 @@ export class SyncLyrics { }); } + // @ts-ignore + console.log(lastTime, totalSeconds, totalSeconds - lastTime) + if (text.length > 0) { - lastTime = time; + lastTime = totalSeconds; formattedLyrics.push({ time: totalSeconds, text: text, }); - - continue; } // @ts-ignore - if (instrumentalLyricIndicator && (!lastTime || lastTime - time > 3)) { - lastTime = time; + if (instrumentalLyricIndicator && (!lastTime || totalSeconds - lastTime > 3)) { + lastTime = totalSeconds; formattedLyrics.push({ time: totalSeconds,