Upload case.js
Browse files
case.js
CHANGED
@@ -2987,8 +2987,8 @@ case 'animedl': {
|
|
2987 |
await loading();
|
2988 |
|
2989 |
try {
|
2990 |
-
let [anime, episode] = q.split('
|
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 |
-
//
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
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);
|