Skip to content

Commit

Permalink
Update Instagram video page and download API. (generated by blackbox…
Browse files Browse the repository at this point in the history
….ai )
  • Loading branch information
saiyamdubey committed Feb 14, 2024
1 parent e5f8bd1 commit 8325db8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 35 deletions.
5 changes: 4 additions & 1 deletion app/instagram/video/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ function Searchbar({}: Props) {
console.log(response);
const data = response.data;
console.log(data);

const response1 = await axios.get(
`/api/test?url=https://jsonplaceholder.typicode.com/posts`
);
console.log(response1.data)
if (data === "link is wrong") {
setloading(false);
toast("Check the Provided Link");
Expand Down
68 changes: 34 additions & 34 deletions pages/api/download.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@

import { NextApiRequest, NextApiResponse } from 'next';
import axios from 'axios';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let { url } = req.query;

if (typeof url === 'string') {
url = url.replace(/\?utm_source=ig_web_copy_link$/, '');
url = url.replace(/\?hl=en$/, '');
url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, '');
url = url.replace(/\/[^/]*$/, '');
url = url + process.env.SECRET_KEY;
console.log(url)
}

try {
console.log("hello1")
const response = await fetch(url as string);
console.log(response.json())
const data = response.json();
res.status(200).send(data);
} catch (error) {
res.status(500).send('error');
}
}


// import { NextApiRequest, NextApiResponse } from 'next';
// import axios from 'axios';

// export default async function handler(req: NextApiRequest, res: NextApiResponse) {
// let { url } = req.query;

Expand All @@ -36,17 +9,44 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
// url = url.replace(/\?hl=en$/, '');
// url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, '');
// url = url.replace(/\/[^/]*$/, '');
// url = url + "/?__a=1&__d=dis";
// url = url + process.env.SECRET_KEY;
// console.log(url)
// }

// try {
// const response = await axios.get(url as string);
// console.log(response.data)
// const data = response.data;
// res.status(200).json(data);
// console.log("hello1")
// const response = await fetch(url as string);
// // console.log(response.json())
// // const data = response.json();
// res.status(200).send(response.json());
// } catch (error) {
// console.error(error);
// res.status(500).json({ error: 'Internal Server Error' });
// res.status(500).send('error');
// }
// }


import { NextApiRequest, NextApiResponse } from 'next';
import axios from 'axios';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let { url } = req.query;

if (typeof url === 'string') {
url = url.replace(/\?utm_source=ig_web_copy_link$/, '');
url = url.replace(/\?hl=en$/, '');
url = url.replace(/\?igsh=MWNqM3Jkemx0ZGNpaA==$/, '');
url = url.replace(/\/[^/]*$/, '');
url = url + "/?__a=1&__d=dis";
console.log(url)
}

try {
const response = await axios.get(url as string);
console.log(response.data)
const data = response.data;
res.status(200).json(data);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Internal Server Error' });
}
}
18 changes: 18 additions & 0 deletions pages/api/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


import { NextApiRequest, NextApiResponse } from 'next';
import axios from 'axios';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
let { url } = req.query;

try {
const response = await axios.get(url as string );
console.log("response 1",response.data)
const data = response.data;
res.status(200).json(data);
} catch (error) {
console.error(error);
res.status(500).json({ error: 'Internal 2 Server Error' });
}
}

0 comments on commit 8325db8

Please sign in to comment.