File size: 1,830 Bytes
a2b2aac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
import axios from "axios";
import fetch from "node-fetch";
import formData from "form-data";
import cheerio from "cheerio";

async function igdl(url) {
    try {
        const resp = await axios.post("https://saveig.app/api/ajaxSearch", new URLSearchParams({
            q: url,
            t: "media",
            lang: "id"
        }), {
            headers: {
                accept: "*/*",
                "user-agent": "PostmanRuntime/7.32.2"
            }
        })
        let result = {
            status: true,
            data: []
        }
        const $ = cheerio.load(resp.data.data)
        $(".download-box > li > .download-items").each(function () {
            result.data.push($(this).find(".download-items__btn > a").attr("href"))
        })
        return result
    } catch {
        const result = {
            status: false,
            message: "Couldn't fetch data of url"
        }
        console.log(result)
        return result
    }
}

async function igdl2(url) {
    try {
        let result = {
            status: true,
            media: []
        }
        const {
            data
        } = await axios(`https://www.y2mate.com/mates/analyzeV2/ajax`, {
            method: "post",
            data: {
                k_query: url,
                k_page: "Instagram",
                hl: "id",
                q_auto: 0
            },
            headers: {
                "content-type": "application/x-www-form-urlencoded",
                "user-agent": "PostmanRuntime/7.32.2"
            }
        })
        await data.links.video.map((video) => result.media.push(video.url))
        return result
    } catch (err) {
        const result = {
            status: false,
            message: `Media not found`
        }
        return result
    }
}

export {
    igdl,
    igdl2
};