mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-02 16:23:48 +03:00
Datanodes support
This commit is contained in:
parent
59bc23bbd8
commit
82b1d710c2
@ -8,7 +8,7 @@ import {
|
|||||||
} from "@main/repository";
|
} from "@main/repository";
|
||||||
import { publishDownloadCompleteNotification } from "../notifications";
|
import { publishDownloadCompleteNotification } from "../notifications";
|
||||||
import type { DownloadProgress } from "@types";
|
import type { DownloadProgress } from "@types";
|
||||||
import { GofileApi, QiwiApi } from "../hosters";
|
import { GofileApi, QiwiApi, DatanodesApi } from "../hosters";
|
||||||
import { PythonRPC } from "../python-rpc";
|
import { PythonRPC } from "../python-rpc";
|
||||||
import {
|
import {
|
||||||
LibtorrentPayload,
|
LibtorrentPayload,
|
||||||
@ -277,6 +277,16 @@ export class DownloadManager {
|
|||||||
save_path: game.downloadPath!,
|
save_path: game.downloadPath!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case Downloader.Datanodes: {
|
||||||
|
const downloadUrl = await DatanodesApi.getDownloadUrl(game.uri!);
|
||||||
|
|
||||||
|
return {
|
||||||
|
action: "start",
|
||||||
|
game_id: game.id,
|
||||||
|
url: downloadUrl,
|
||||||
|
save_path: game.downloadPath!,
|
||||||
|
};
|
||||||
|
}
|
||||||
case Downloader.Torrent:
|
case Downloader.Torrent:
|
||||||
return {
|
return {
|
||||||
action: "start",
|
action: "start",
|
||||||
|
51
src/main/services/hosters/datanodes.ts
Normal file
51
src/main/services/hosters/datanodes.ts
Normal file
@ -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 "";
|
||||||
|
}
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export * from "./gofile";
|
export * from "./gofile";
|
||||||
export * from "./qiwi";
|
export * from "./qiwi";
|
||||||
|
export * from "./datanodes";
|
||||||
|
@ -8,6 +8,7 @@ export const DOWNLOADER_NAME = {
|
|||||||
[Downloader.Gofile]: "Gofile",
|
[Downloader.Gofile]: "Gofile",
|
||||||
[Downloader.PixelDrain]: "PixelDrain",
|
[Downloader.PixelDrain]: "PixelDrain",
|
||||||
[Downloader.Qiwi]: "Qiwi",
|
[Downloader.Qiwi]: "Qiwi",
|
||||||
|
[Downloader.Datanodes]: "Datanodes",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
export const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
||||||
|
@ -4,6 +4,7 @@ export enum Downloader {
|
|||||||
Gofile,
|
Gofile,
|
||||||
PixelDrain,
|
PixelDrain,
|
||||||
Qiwi,
|
Qiwi,
|
||||||
|
Datanodes,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DownloadSourceStatus {
|
export enum DownloadSourceStatus {
|
||||||
|
@ -87,6 +87,7 @@ export const getDownloadersForUri = (uri: string) => {
|
|||||||
|
|
||||||
if (uri.startsWith("https://pixeldrain.com")) return [Downloader.PixelDrain];
|
if (uri.startsWith("https://pixeldrain.com")) return [Downloader.PixelDrain];
|
||||||
if (uri.startsWith("https://qiwi.gg")) return [Downloader.Qiwi];
|
if (uri.startsWith("https://qiwi.gg")) return [Downloader.Qiwi];
|
||||||
|
if (uri.startsWith("https://datanodes.to")) return [Downloader.Datanodes];
|
||||||
|
|
||||||
if (realDebridHosts.some((host) => uri.startsWith(host)))
|
if (realDebridHosts.some((host) => uri.startsWith(host)))
|
||||||
return [Downloader.RealDebrid];
|
return [Downloader.RealDebrid];
|
||||||
|
Loading…
Reference in New Issue
Block a user