zohlathu 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +13 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -4,7 +4,7 @@ const ytSearch = require('yt-search');
4
4
 
5
5
  /**
6
6
  * Fetch lyrics for the given song query
7
- * * @param {string} query - Song name or artist to search for
7
+ * @param {string} query - Song name or artist to search for
8
8
  * @returns {Promise<Object|null>} - Dictionary containing title and lyrics, or null if not found
9
9
  */
10
10
  async function get_lyrics(query) {
@@ -48,7 +48,6 @@ async function get_lyrics(query) {
48
48
  }
49
49
  });
50
50
 
51
-
52
51
  const feed = await parser.parseURL(feed_url);
53
52
 
54
53
  if (!feed.items || feed.items.length === 0) {
@@ -58,15 +57,23 @@ async function get_lyrics(query) {
58
57
 
59
58
  const entry = feed.items[0];
60
59
 
60
+
61
+ const htmlParts = entry.content.split(/<hr[^>]*>/i);
62
+ const lyricsHtmlOnly = htmlParts[0];
61
63
 
62
- let content = htmlToText(entry.content, {
64
+ let cleaned_content = htmlToText(lyricsHtmlOnly, {
63
65
  wordwrap: false,
64
- preserveNewlines: true
66
+ preserveNewlines: true,
67
+ selectors: [
68
+ { selector: 'p', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } },
69
+ { selector: 'br', format: 'lineBreak' },
70
+ { selector: 'a', options: { ignoreHref: true } },
71
+ { selector: 'img', format: 'skip' }
72
+ ]
65
73
  });
66
74
 
75
+ cleaned_content = cleaned_content.trim();
67
76
 
68
- const pattern = /\* \* \*[\s\S]*?\* \* \*/g;
69
- const cleaned_content = content.replace(pattern, '').trim();
70
77
 
71
78
  return {
72
79
  title: entry.title,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zohlathu",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "A Node.js package for fetching Mizo song lyrics from www.zohlathu.in",
5
5
  "main": "index.js",
6
6
  "scripts": {