{"version":3,"sources":["jsdelivr-header.js","/npm/get-azlyrics@1.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,aAEA,MAAM,QAAU,QAAQ,gBAClB,QAAU,QAAQ,WAClB,WAAa,wBAEb,aAAe,IACjB,MAAM,EAAM,EAAI,MAAM,aACtB,OAAkB,IAAf,EAAI,QACA,CAAG,EAGR,cAAgB,GAErB,GADA,EAAO,EAAK,QAAQ,MAAM,KACd,cAIP,UAAY,CAAC,EAAW,KAC7B,IAAI,EAAY,WAIhB,OADA,GAAa,UAFb,EAAa,cAAc,MAC3B,EAAW,cAAc,UAElB,CAAS,EAGjB,QAAQ,UAAY,GACZ,IAAI,SAAQ,CAAC,EAAS,KAC5B,MAAM,EAAO,aAAa,GAC1B,IAAI,EAAM,OAAO,EAAQ,sHACzB,MAAM,EAAM,UAAU,EAAK,GAAG,EAAK,IAClB,QAAQ,MAAO,GAC/B,MAAK,IACL,MACM,EADI,QAAQ,KAAK,EAAI,QAAQ,QACjB,CAAE,mCAAmC,GAAG,SAAS,IAAI,SACvE,IAAI,EAAS,GACb,IAAI,IAAI,EAAI,EAAG,EAAI,EAAU,OAAQ,IACrC,CAEC,GADa,EAAU,GAAG,KAAO,GAAG,EAAU,GAAG,KAAK,OAAO,OAAS,EAEvE,CAEA,OADA,EAAS,EAAO,MAAM,GAAG,GAClB,EAAQ,EAAO,IAEtB,OAAM,GAAO,EAAO,wDAA2E,MAAnB,EAAI,WAAqB,EAAI,WAAa,cAAgB,EAAI,4FAA2F","file":"/npm/get-azlyrics@1.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/get-azlyrics@1.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","'use strict'\r\n\r\nconst request = require('then-request');\r\nconst cheerio = require('cheerio');\r\nconst lyricsBase = 'https://azlyrics.com/';\r\n\r\nconst transformMsg = msg => {\r\n    const arr = msg.split(/\\s*\\-\\s*/g);\r\n    if(arr.length !== 2) return false;\r\n    return arr;\r\n}\r\n\r\nconst transformLink = data => {\r\n\tdata = data.replace(/\\W/g,'');\t\r\n\tdata = data.toLowerCase();\r\n\treturn data;\r\n}\r\n\r\nconst lyricsUrl = (artistName,songName) => {\r\n\tlet returnUrl = lyricsBase;\t\r\n\tartistName = transformLink(artistName);\r\n\tsongName = transformLink(songName);\r\n\treturnUrl += `lyrics/${artistName}/${songName}.html`;\r\n\treturn returnUrl;\r\n}\r\n\r\nexports.getLyrics = msg => {\r\n\treturn new Promise((resolve, reject) => {\r\n\t\tconst song = transformMsg(msg);\r\n\t\tif(!song) return resolve(`Too much or too little hyphens dumbass.\\nFormat: Artist - Song.\\nAdditional hyphens in the title should be omitted`);\r\n\t\tconst URI = lyricsUrl(song[0],song[1]);\r\n\t\tconst Response = request('GET', URI)\r\n\t\t.then(res => {\r\n\t\t\tconst $ = cheerio.load(res.getBody('utf8'));\r\n\t\t\tconst lyricsDiv = $('.col-xs-12.col-lg-8.text-center')[0].children[16].children;\r\n\t\t\tlet lyrics = '';\r\n\t\t\tfor(let i = 2; i < lyricsDiv.length; i++)\r\n\t\t\t{\r\n\t\t\t\tconst line = lyricsDiv[i].data ? `${lyricsDiv[i].data.substr(1)}\\n` : ``;\r\n\t\t\t\tlyrics += line;\r\n\t\t\t}\r\n\t\t\tlyrics = lyrics.slice(0,-2);\r\n\t\t\treturn resolve(lyrics);\r\n\t\t})\r\n\t\t.catch(err => reject(`You're doing it wrong!\\nServer responded with status ${err.statusCode === 404 ? err.statusCode + ' not found!' : err.statusCode}\\n\\nFormat: Artist - Song.\\nAdditional hyphens in the title should be omitted`));\r\n\t});\r\n}\r\n"]}