Edqe14 / AzlyricScraper

MIT License
2 stars 1 forks source link

Cannot read property split of undefined #4

Closed oscarrc closed 4 years ago

oscarrc commented 4 years ago

I'm encountering this issue while trying to fetch a lyric:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
    at String.format (@/node_modules/azlyrics-scraper/src/lyrics.js:6:31)

In order to solve this issue I've added the following line to lyrics.js line 42:

let lyrics = $('.row .col-xs-12 div').each((_, e) => {
    if($(e).attr('class')) return;
        else if(!$(e).html()) return; //I've added this line
        else {
            $(e).html().format().split('\n').forEach(t => lyric.push(t));
        };
    });

Hope that helps.

Edqe14 commented 4 years ago

Hello, Thanks for reporting this issue! Can you open a pull request for this fix? Thank you