playlist-admin 2.6.76 → 2.6.78

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/cli/lib/podcast.js +19 -5
  2. package/package.json +2 -2
@@ -16,14 +16,22 @@ function parseRss(xml) {
16
16
  const block = m[1];
17
17
  const title = (block.match(/<title>([\s\S]*?)<\/title>/) || [])[1] || '';
18
18
  const pubDate = (block.match(/<pubDate>([\s\S]*?)<\/pubDate>/) || [])[1] || '';
19
- const enclosure = block.match(/<enclosure[^>]*url="([^"]*)"[^>]*type="([^"]*)"[^>]*\/?>/);
19
+ const enclosure = block.match(/<enclosure[^>]*\/?>/);
20
+ let audioUrl = '';
21
+ let audioType = '';
22
+ if (enclosure) {
23
+ const u = enclosure[0].match(/url="\s*([^"]+)"/);
24
+ const t = enclosure[0].match(/type="([^"]+)"/);
25
+ if (u) audioUrl = decodeXml(u[1]);
26
+ if (t) audioType = t[1];
27
+ }
20
28
  const duration = (block.match(/<itunes:duration>([\s\S]*?)<\/itunes:duration>/) || [])[1] || '';
21
29
  const description = (block.match(/<description>([\s\S]*?)<\/description>/) || [])[1] || '';
22
30
  items.push({
23
31
  title: decodeXml(title),
24
32
  pub_date: decodeXml(pubDate),
25
- audio_url: enclosure ? decodeXml(enclosure[1]) : '',
26
- audio_type: enclosure ? enclosure[2] : '',
33
+ audio_url: audioUrl,
34
+ audio_type: audioType,
27
35
  duration: decodeXml(duration),
28
36
  description: decodeXml(description),
29
37
  });
@@ -94,6 +102,7 @@ export class PodcastService {
94
102
  if (!resp.ok) throw new Error(`Download HTTP ${resp.status}`);
95
103
  const total = parseInt(resp.headers.get('content-length') || '0', 10);
96
104
  let downloaded = 0;
105
+ let lastPct = -1;
97
106
  const ws = fs.createWriteStream(outputPath + '.part');
98
107
  const reader = resp.body.getReader();
99
108
  while (true) {
@@ -102,11 +111,16 @@ export class PodcastService {
102
111
  ws.write(value);
103
112
  downloaded += value.length;
104
113
  if (total > 0) {
105
- process.stdout.write(`\r ⬇️ ${(downloaded / total * 100).toFixed(1)}%`);
114
+ const pct = Math.trunc(downloaded / total * 100);
115
+ if (pct !== lastPct) {
116
+ lastPct = pct;
117
+ process.stdout.write(`\r ⬇️ ${pct}%`);
118
+ }
106
119
  }
107
120
  }
108
121
  ws.end();
109
- if (total > 0) process.stdout.write('\n');
122
+ if (total > 0 && lastPct !== 100) process.stdout.write('\r ⬇️ 100%');
123
+ process.stdout.write('\n');
110
124
  await new Promise((r) => ws.on('finish', r));
111
125
  fs.renameSync(outputPath + '.part', outputPath);
112
126
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "playlist-admin",
3
- "version": "2.6.76",
3
+ "version": "2.6.78",
4
4
  "description": "Playlist Administrator CLI - music library pipeline, podcast pipeline and Spotube automation (Node.js)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -35,4 +35,4 @@
35
35
  "node": ">=20"
36
36
  },
37
37
  "private": false
38
- }
38
+ }