API-XX commited on
Commit
27e4fb5
Β·
verified Β·
1 Parent(s): 6143d0a

Upload case.js

Browse files
Files changed (1) hide show
  1. case.js +19 -10
case.js CHANGED
@@ -2987,8 +2987,8 @@ case 'animedl': {
2987
  await loading();
2988
 
2989
  try {
2990
- let [anime, episode] = q.split('|').map(x => x.trim());
2991
- let apiUrl = `https://api-xx-xi.hf.space/api/animedl?name=${anime}&episode=${episode}`;
2992
 
2993
  let response = await fetch(apiUrl);
2994
  let json = await response.json();
@@ -3002,18 +3002,27 @@ case 'animedl': {
3002
  let downloadLink = json.download_link;
3003
  let title = json.title || `${anime} - Episode ${episode}`;
3004
 
3005
- // Notify the user
3006
  await conn.sendMessage(m.chat, {
3007
  text: fontx(`πŸŽ₯ *Fetching ${title}*\n⏳ Please wait...`)
3008
  });
3009
 
3010
- // Send the episode as a file
3011
- await conn.sendMessage(m.chat, {
3012
- document: { url: downloadLink },
3013
- mimetype: 'video/mp4',
3014
- fileName: `${title}.mp4`,
3015
- caption: fontx(`🎬 *${title}*\nπŸ“₯ *Download Complete!*`)
3016
- });
 
 
 
 
 
 
 
 
 
3017
 
3018
  } catch (error) {
3019
  console.error("Error in animedl case:", error);
 
2987
  await loading();
2988
 
2989
  try {
2990
+ let [anime, episode] = q.split(',').map(x => x.trim());
2991
+ let apiUrl = `https://api-xx-xi.hf.space/api/animedl?name=${encodeURIComponent(anime)}&episode=${encodeURIComponent(episode)}`;
2992
 
2993
  let response = await fetch(apiUrl);
2994
  let json = await response.json();
 
3002
  let downloadLink = json.download_link;
3003
  let title = json.title || `${anime} - Episode ${episode}`;
3004
 
3005
+ // Notify the user that the file is being downloaded
3006
  await conn.sendMessage(m.chat, {
3007
  text: fontx(`πŸŽ₯ *Fetching ${title}*\n⏳ Please wait...`)
3008
  });
3009
 
3010
+ // **Option 1: Try sending as a document (better for large files)**
3011
+ try {
3012
+ await conn.sendMessage(m.chat, {
3013
+ document: { url: downloadLink },
3014
+ mimetype: 'video/mp4',
3015
+ fileName: `${title}.mp4`,
3016
+ caption: fontx(`🎬 *${title}*\nπŸ“₯ *Download Complete!*`)
3017
+ });
3018
+ } catch (error) {
3019
+ console.warn("WhatsApp rejected direct file send. Sending as a link instead.");
3020
+
3021
+ // **Option 2: Send as a direct download link**
3022
+ await conn.sendMessage(m.chat, {
3023
+ text: fontx(`🎬 *${title}*\nπŸ“₯ *Download it manually:*\n\nπŸ”— ${downloadLink}`)
3024
+ });
3025
+ }
3026
 
3027
  } catch (error) {
3028
  console.error("Error in animedl case:", error);