File size: 1,931 Bytes
ab0d392
f9bc4a9
 
 
985a903
f9bc4a9
985a903
 
f9bc4a9
985a903
 
 
 
 
 
 
 
f9bc4a9
985a903
 
 
 
 
 
 
f9bc4a9
985a903
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f9bc4a9
 
985a903
 
 
 
 
 
f9bc4a9
985a903
 
 
 
 
 
 
 
f9bc4a9
 
985a903
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
KKconst express = require('express');
const axios = require('axios');

const app = express();
const PORT = 7860;

// JSON parsing enable karein
app.use(express.json());

async function getTeraboxLink(userUrl) {
    try {
        // Short URL se ID nikalne ke liye logic
        const match = userUrl.match(/s\/([^\/]+)/i);
        if (!match) throw new Error("Invalid Terabox Link");
        
        const shortId = match[1];
        const cleanUrl = `https://www.1024terabox.com/s/${shortId}`;

        // Nayi working API (Arman API)
        const apiRes = await axios.get(`https://terabox-dl-arman.vercel.app/api?url=${cleanUrl}`, {
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
            },
            timeout: 10000
        });

        const data = apiRes.data;
        
        // Response format ko check karein aur sahi data return karein
        return {
            file_name: data.file_name || "video.mp4",
            size: data.size || "Unknown",
            download: data.download_url || data.link || data.dlink,
            status: "Success"
        };
    } catch (err) {
        return { 
            status: "Error", 
            message: "API Blocked or Link Expired",
            details: err.message 
        };
    }
}

// Home Page par message dikhane ke liye
app.get('/', (req, res) => {
    res.send("<h1>Terabox API is Running!</h1><p>Use: <code>/dl?url=YOUR_LINK</code></p>");
});

// Download Route
app.all('/dl', async (req, res) => {
    const url = req.query.url || req.body.url;
    
    if (!url || !url.includes('tera')) {
        return res.status(400).json({ error: "Please provide a valid Terabox link" });
    }

    const result = await getTeraboxLink(url);
    res.json(result);
});

app.listen(PORT, () => {
    console.log(`Server started on port ${PORT}`);
});