API-XX commited on
Commit
8b8eeb5
Β·
verified Β·
1 Parent(s): bf59e23

Upload case.js

Browse files
Files changed (1) hide show
  1. case.js +209 -1
case.js CHANGED
@@ -994,6 +994,10 @@ module.exports = async (conn, dev, chatUpdate, store) => {
994
  > ─────────────❐
995
 
996
  > β”€γ€Ž \`πŒπ„πƒπˆπ€ πƒπŽπ–ππ‹πŽπ€πƒπ’\` 』
 
 
 
 
997
 
998
  > ─────────────❐
999
 
@@ -1064,7 +1068,7 @@ module.exports = async (conn, dev, chatUpdate, store) => {
1064
  > ─────────────❐
1065
  > ${caption}`)
1066
  })
1067
- await sleep(2000)
1068
  sendvn(dmusic)
1069
  break;
1070
  }
@@ -2790,8 +2794,212 @@ ${listAdmin}
2790
  });
2791
  break;
2792
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2793
 
 
 
 
 
 
 
 
 
2794
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2795
 
2796
 
2797
 
 
994
  > ─────────────❐
995
 
996
  > β”€γ€Ž \`πŒπ„πƒπˆπ€ πƒπŽπ–ππ‹πŽπ€πƒπ’\` 』
997
+ > ${sign} ${prefix}play
998
+ > ${sign} ${prefix}video
999
+ > ${sign} ${prefix}animedl
1000
+
1001
 
1002
  > ─────────────❐
1003
 
 
1068
  > ─────────────❐
1069
  > ${caption}`)
1070
  })
1071
+ await sleep(1500)
1072
  sendvn(dmusic)
1073
  break;
1074
  }
 
2794
  });
2795
  break;
2796
  }
2797
+ case 'animedl': {
2798
+ if (!q.includes('|')) return conn.sendMessage(m.chat, {
2799
+ text: `\`Invalid format\`\nExample: *${prefix + command} solo leveling|1*`
2800
+ });
2801
+
2802
+ await loading();
2803
+
2804
+ try {
2805
+ let [anime, episode] = q.split('|').map(x => x.trim());
2806
+ let apiUrl = `https://api-xx-xi.hf.space/api/animedl?name=${encodeURIComponent(anime)}&episode=${encodeURIComponent(episode)}`;
2807
+ let response = await fetch(apiUrl);
2808
+ let json = await response.json();
2809
+
2810
+ if (!json.success || !json.downloadLinks.length) {
2811
+ return conn.sendMessage(m.chat, {
2812
+ text: `❌ *No download links found for ${anime} Episode ${episode}*`
2813
+ });
2814
+ }
2815
+
2816
+ function parseSize(size) {
2817
+ let match = size.match(/([\d.]+)\s*(MB|GB)/i);
2818
+ if (!match) return Infinity;
2819
+ let value = parseFloat(match[1]);
2820
+ return match[2].toLowerCase() === 'gb' ? value * 1024 : value;
2821
+ }
2822
+
2823
+ let bestMatch = json.downloadLinks.reduce((prev, curr) => {
2824
+ return Math.abs(parseSize(curr.size) - 100) < Math.abs(parseSize(prev.size) - 100) ? curr : prev;
2825
+ });
2826
+
2827
+ let {
2828
+ link,
2829
+ size
2830
+ } = bestMatch;
2831
+
2832
+ conn.sendMessage(m.chat, {
2833
+ text: `πŸŽ₯ *Downloading ${anime} Episode ${episode}*\nπŸ“¦ *Size:* ${size}`
2834
+ });
2835
+
2836
+ await conn.sendMessage(m.chat, {
2837
+ document: {
2838
+ url: link
2839
+ },
2840
+ mimetype: 'video/mp4',
2841
+ fileName: `${anime} - Episode ${episode}.mp4`,
2842
+ caption: fontx(`🎬 *${anime} - Episode ${episode}*\nπŸ“₯ *Size:* ${size}`)
2843
+ });
2844
+
2845
+ } catch (error) {
2846
+ console.error("Error in animedl case:", error);
2847
+ conn.sendMessage(m.chat, {
2848
+ text: "❌ An error occurred while fetching the anime. Please try again later."
2849
+ });
2850
+ }
2851
+ break;
2852
+ }
2853
+ case 'play':
2854
+ case 'songs': {
2855
+ if (!text) {
2856
+ return reply(`\`No music title detected.\`\n*Example: ${prefix + command} Alan Walker - Faded*`);
2857
+ }
2858
+
2859
+ try {
2860
+ await loading();
2861
+ let search = await yts(text);
2862
+ let video = search.videos[0];
2863
+ if (!video) {
2864
+ return reply("No results found for the provided query.");
2865
+ }
2866
+
2867
+ let {
2868
+ title,
2869
+ timestamp,
2870
+ views,
2871
+ ago,
2872
+ url,
2873
+ thumbnail
2874
+ } = video;
2875
+
2876
+ await conn.sendMessage(m.chat, {
2877
+ image: {
2878
+ url: thumbnail
2879
+ },
2880
+ caption: fontx(`🎢 *title:* ${title}\nπŸ‘οΈ *views:* ${views}\n⏱️ *duration:* ${timestamp}\nπŸ“… *uploaded:* ${ago}\n🌐`) + (` *url:* ${url}\n`) + fontx(`\n> ${caption}`),
2881
+ });
2882
+ let apiUrl = `https://api.davidcyriltech.my.id/download/ytmp3?url=${encodeURIComponent(url)}`;
2883
+ let res;
2884
+
2885
+ try {
2886
+ res = await fetch(apiUrl);
2887
+ } catch (fetchError) {
2888
+ console.error("Error fetching API:", fetchError);
2889
+ return reply("Failed to fetch audio. Please check your connection and try again.");
2890
+ }
2891
+
2892
+ let json;
2893
+ try {
2894
+ json = await res.json();
2895
+ } catch (jsonError) {
2896
+ console.error("Error parsing JSON:", jsonError);
2897
+ return reply("Failed to process API response. Please try again later.");
2898
+ }
2899
+
2900
+ // Validate API response
2901
+ if (!json.success || !json.result || !json.result.download_url) {
2902
+ return reply("Failed to fetch audio. Please try again later.");
2903
+ }
2904
+
2905
+ let {
2906
+ download_url,
2907
+ title: audioTitle,
2908
+ quality
2909
+ } = json.result;
2910
+
2911
+ await conn.sendMessage(m.chat, {
2912
+ audio: {
2913
+ url: download_url
2914
+ },
2915
+ mimetype: "audio/mp4",
2916
+ fileName: `${audioTitle} (${quality}).mp3`,
2917
+ caption: `🎢 *Title:* ${audioTitle}\nπŸ”Š *Quality:* ${quality}\nπŸ“₯ *Downloaded successfully!*`,
2918
+ }, {
2919
+ quoted: m
2920
+ });
2921
+
2922
+ } catch (error) {
2923
+ console.error("Error in play case:", error);
2924
+ reply("An unexpected error occurred while processing your request. Please try again later.");
2925
+ }
2926
+ break;
2927
+ }
2928
+ case 'video': {
2929
+ if (!text) {
2930
+ return reply(`\`No video title detected.\`\n*Example: ${prefix + command} Alan Walker - Faded*`);
2931
+ }
2932
+
2933
+ try {
2934
+ await loading();
2935
+
2936
+ let search = await yts(text);
2937
+ let video = search.videos[0];
2938
+ if (!video) {
2939
+ return conn.sendMessage(m.chat, {
2940
+ text: "No results found for the provided query."
2941
+ }, {
2942
+ quoted: m
2943
+ });
2944
+ }
2945
 
2946
+ let {
2947
+ title,
2948
+ timestamp,
2949
+ views,
2950
+ ago,
2951
+ url,
2952
+ thumbnail
2953
+ } = video;
2954
 
2955
+ await conn.sendMessage(m.chat, {
2956
+ image: {
2957
+ url: thumbnail
2958
+ },
2959
+ caption: fontx(`🎬 *Title:* ${title}\ndownload completed a sec\n> ${caption}`),
2960
+ }, {
2961
+ quoted: m
2962
+ });
2963
+
2964
+ let apiUrl = `https://api.davidcyriltech.my.id/download/ytmp4?url=${encodeURIComponent(url)}`;
2965
+ let res = await fetch(apiUrl);
2966
+ let json = await res.json();
2967
+
2968
+ if (!json.success || !json.result || !json.result.download_url) {
2969
+ return conn.sendMessage(m.chat, {
2970
+ text: "Failed to fetch video. Please try again later."
2971
+ }, {
2972
+ quoted: m
2973
+ });
2974
+ }
2975
+
2976
+ let {
2977
+ download_url,
2978
+ title: videoTitle,
2979
+ quality
2980
+ } = json.result;
2981
+
2982
+ await conn.sendMessage(m.chat, {
2983
+ video: {
2984
+ url: download_url
2985
+ },
2986
+ caption: fontx(`> ${caption}`),
2987
+ mimetype: 'video/mp4'
2988
+ }, {
2989
+ quoted: m
2990
+ });
2991
+
2992
+ } catch (error) {
2993
+ console.error("Error in video case:", error);
2994
+ conn.sendMessage(m.chat, {
2995
+ text: "An unexpected error occurred while processing your request. Please try again later."
2996
+ }, {
2997
+ quoted: m
2998
+ });
2999
+ }
3000
+
3001
+ break;
3002
+ }
3003
 
3004
 
3005