-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59bc23b
commit 82b1d71
Showing
6 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import axios, { AxiosResponse } from "axios"; | ||
|
||
export class DatanodesApi { | ||
private static session = axios.create({}); | ||
|
||
public static async getDownloadUrl(downloadUrl: string): Promise<string> { | ||
const parsedUrl = new URL(downloadUrl); | ||
const pathSegments = parsedUrl.pathname.split("/"); | ||
|
||
const fileCode = decodeURIComponent(pathSegments[1]); | ||
const fileName = decodeURIComponent(pathSegments[pathSegments.length - 1]); | ||
|
||
const headers: Record<string, string> = { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
Cookie: `lang=english; file_name=${fileName}; file_code=${fileCode};`, | ||
Host: "datanodes.to", | ||
Origin: "https://datanodes.to", | ||
Referer: "https://datanodes.to/download", | ||
"User-Agent": | ||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36", | ||
}; | ||
|
||
const payload = new URLSearchParams({ | ||
op: "download2", | ||
id: fileCode, | ||
rand: "", | ||
referer: "https://datanodes.to/download", | ||
method_free: "Free Download >>", | ||
method_premium: "", | ||
adblock_detected: "", | ||
}); | ||
|
||
const config = { | ||
headers, | ||
maxRedirects: 0, | ||
validateStatus: (status: number) => status === 302 || status < 400, | ||
}; | ||
|
||
const response: AxiosResponse = await DatanodesApi.session.post( | ||
"https://datanodes.to/download", | ||
payload, | ||
config | ||
); | ||
|
||
if (response.status === 302) { | ||
return response.headers["location"]; | ||
} | ||
|
||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./gofile"; | ||
export * from "./qiwi"; | ||
export * from "./datanodes"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ export enum Downloader { | |
Gofile, | ||
PixelDrain, | ||
Qiwi, | ||
Datanodes, | ||
} | ||
|
||
export enum DownloadSourceStatus { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters