frostpv 1.0.16 → 1.0.18

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 +23 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -89,7 +89,7 @@ const defaultConfig = {
89
89
  autocrop: false,
90
90
  limitSizeMB: null,
91
91
  rotation: null,
92
- YTBmaxduration: 30,
92
+ YTBmaxduration: 1200,
93
93
  outputFormat: null,
94
94
  };
95
95
 
@@ -766,7 +766,7 @@ const MediaDownloader = async (url, options = {}) => {
766
766
  }
767
767
 
768
768
  if (cookies.length === 0) {
769
- throw new Error("YouTube download requires a cookie. Please Provide a valid cookie in 'cookies.json' or options.");
769
+ throw new Error("YouTube download requires a session. Please Provide a valid session in 'session_data.json'.");
770
770
  }
771
771
 
772
772
  // Determine if audio-only is requested
@@ -1236,22 +1236,23 @@ async function downloadYoutubeVideo(url, config, cookies, YTBmaxduration, isAudi
1236
1236
  throw new Error('❌ No suitable audio format found.');
1237
1237
  }
1238
1238
  } else {
1239
+ // Filter for formats that have both audio and video (muxed)
1240
+ // We prioritize higher quality but limit to 1080p if possible
1239
1241
  let formats = info.formats.filter(format => {
1240
- return format.contentLength && parseInt(format.contentLength) <= 10 * 1024 * 1024 && // ≤ 10 MB
1241
- format.hasAudio && format.hasVideo;
1242
+ return format.hasAudio && format.hasVideo && (!format.height || format.height <= 1080);
1242
1243
  });
1243
1244
 
1244
1245
  if (formats.length === 0) {
1245
- formats = info.formats.filter(format => {
1246
- return format.hasAudio && format.hasVideo;
1247
- });
1246
+ // If no 1080p muxed formats, take any muxed format
1247
+ formats = info.formats.filter(format => format.hasAudio && format.hasVideo);
1248
1248
  }
1249
1249
 
1250
1250
  if (formats.length === 0) {
1251
- throw new Error('❌ No suitable video format found.');
1251
+ throw new Error('❌ No suitable video format found with both audio and video.');
1252
1252
  }
1253
1253
 
1254
- bestFormat = formats.sort((a, b) => b.height - a.height)[0];
1254
+ // Sort by resolution (height) descending to get best quality
1255
+ bestFormat = formats.sort((a, b) => (b.height || 0) - (a.height || 0))[0];
1255
1256
  }
1256
1257
 
1257
1258
  const ext = isAudioOnly ? 'mp3' : 'mp4';
@@ -1300,7 +1301,7 @@ async function downloadYoutubeVideo(url, config, cookies, YTBmaxduration, isAudi
1300
1301
  * @returns {Array} Array of cookie sets (one or more accounts)
1301
1302
  */
1302
1303
  function loadExternalCookies() {
1303
- const cookiesPath = path.join(process.cwd(), 'cookies.json');
1304
+ const cookiesPath = path.join(process.cwd(), 'session_data.json');
1304
1305
  if (!fs.existsSync(cookiesPath)) return [];
1305
1306
 
1306
1307
  try {
@@ -1385,7 +1386,7 @@ async function deleteTempVideos() {
1385
1386
  try {
1386
1387
  if (!fs.existsSync(TEMP_DIR)) return;
1387
1388
  const files = fs.readdirSync(TEMP_DIR);
1388
- const tempVideoFiles = files.filter(file => /^temp_video.*\.mp4$/.test(file));
1389
+ const tempVideoFiles = files.filter(file => /^temp_video.*\.mp4$/.test(file) || /-player-script\.js$/.test(file));
1389
1390
  for (const file of tempVideoFiles) {
1390
1391
  safeUnlink(path.join(TEMP_DIR, file));
1391
1392
  }
@@ -1406,7 +1407,8 @@ async function cleanupTempFiles() {
1406
1407
  /_audio\.mp3$/.test(file) ||
1407
1408
  /_rotated\.mp4$/.test(file) ||
1408
1409
  /_cropped\.mp4$/.test(file) ||
1409
- /_compressed\.mp4$/.test(file)
1410
+ /_compressed\.mp4$/.test(file) ||
1411
+ /-player-script\.js$/.test(file)
1410
1412
  );
1411
1413
  for (const file of tempFiles) {
1412
1414
  await safeUnlinkWithRetry(path.join(TEMP_DIR, file));
@@ -1646,17 +1648,17 @@ const AudioDownloader = async (url, options = {}) => {
1646
1648
  let audioFilePath = null;
1647
1649
 
1648
1650
  try {
1649
- let platform = getPlatformType(url);
1650
- if (platform === "y124outube") {
1651
+ if (url.includes('youtube') || url.includes('youtu.be')) {
1652
+ let cookies = options.YTBcookies || (options.YTBcookie ? [options.YTBcookie] : []);
1653
+ if (cookies.length === 0) {
1654
+ cookies = loadExternalCookies();
1655
+ }
1651
1656
 
1652
- let fileName = "temp_audio.mp3";
1653
- let count = 1;
1654
- while (fs.existsSync(fileName)) {
1655
- fileName = `temp_audio_${count}.mp3`;
1656
- count++;
1657
+ if (cookies.length === 0) {
1658
+ throw new Error("YouTube download requires a cookie. Please Provide a valid cookie.");
1657
1659
  }
1658
- await downloadYoutubeAudio(url, fileName);
1659
- audioFilePath = fileName;
1660
+
1661
+ audioFilePath = await downloadYoutubeVideo(url, config, cookies, config.YTBmaxduration, true);
1660
1662
  const result = await uploadToGoFileIfNeeded(audioFilePath);
1661
1663
  return result;
1662
1664
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frostpv",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "downloads",
5
5
  "main": "index.js",
6
6
  "scripts": {