mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
Mediafire Support
This commit is contained in:
parent
18c6994df6
commit
c1d15efbc0
@ -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, DatanodesApi } from "../hosters";
|
import { GofileApi, QiwiApi, DatanodesApi, MediafireApi } from "../hosters";
|
||||||
import { PythonRPC } from "../python-rpc";
|
import { PythonRPC } from "../python-rpc";
|
||||||
import {
|
import {
|
||||||
LibtorrentPayload,
|
LibtorrentPayload,
|
||||||
@ -287,6 +287,16 @@ export class DownloadManager {
|
|||||||
save_path: game.downloadPath!,
|
save_path: game.downloadPath!,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
case Downloader.Mediafire: {
|
||||||
|
const downloadUrl = await MediafireApi.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",
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
export * from "./gofile";
|
export * from "./gofile";
|
||||||
export * from "./qiwi";
|
export * from "./qiwi";
|
||||||
export * from "./datanodes";
|
export * from "./datanodes";
|
||||||
|
export * from "./mediafire";
|
||||||
|
31
src/main/services/hosters/mediafire.ts
Normal file
31
src/main/services/hosters/mediafire.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import axios, { AxiosResponse } from "axios";
|
||||||
|
import { JSDOM } from "jsdom";
|
||||||
|
|
||||||
|
export class MediafireApi {
|
||||||
|
private static readonly session = axios.create();
|
||||||
|
|
||||||
|
public static async getDownloadUrl(mediafireUrl: string): Promise<string> {
|
||||||
|
const response: AxiosResponse<string> = await this.session.get(
|
||||||
|
mediafireUrl,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
"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",
|
||||||
|
},
|
||||||
|
maxRedirects: 0,
|
||||||
|
validateStatus: (status: number) => status === 302 || status < 400,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.status === 302) {
|
||||||
|
return response.headers["location"] || "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const dom = new JSDOM(response.data);
|
||||||
|
const downloadButton = dom.window.document.querySelector(
|
||||||
|
"a#downloadButton"
|
||||||
|
) as HTMLAnchorElement;
|
||||||
|
|
||||||
|
return downloadButton?.href || "";
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ export const DOWNLOADER_NAME = {
|
|||||||
[Downloader.PixelDrain]: "PixelDrain",
|
[Downloader.PixelDrain]: "PixelDrain",
|
||||||
[Downloader.Qiwi]: "Qiwi",
|
[Downloader.Qiwi]: "Qiwi",
|
||||||
[Downloader.Datanodes]: "Datanodes",
|
[Downloader.Datanodes]: "Datanodes",
|
||||||
|
[Downloader.Mediafire]: "Mediafire",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
export const MAX_MINUTES_TO_SHOW_IN_PLAYTIME = 120;
|
||||||
|
@ -5,6 +5,7 @@ export enum Downloader {
|
|||||||
PixelDrain,
|
PixelDrain,
|
||||||
Qiwi,
|
Qiwi,
|
||||||
Datanodes,
|
Datanodes,
|
||||||
|
Mediafire,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DownloadSourceStatus {
|
export enum DownloadSourceStatus {
|
||||||
|
@ -88,6 +88,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 (uri.startsWith("https://datanodes.to")) return [Downloader.Datanodes];
|
||||||
|
if (uri.startsWith("https://www.mediafire.com")) return [Downloader.Mediafire];
|
||||||
|
|
||||||
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