mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 00:33:49 +03:00
feat: adding support to qiwi
This commit is contained in:
parent
76d3fead66
commit
6c24a523b7
@ -101,6 +101,7 @@ const startGameDownload = async (
|
|||||||
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
|
await downloadQueueRepository.delete({ game: { id: updatedGame!.id } });
|
||||||
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
|
await downloadQueueRepository.insert({ game: { id: updatedGame!.id } });
|
||||||
|
|
||||||
|
await DownloadManager.cancelDownload(updatedGame!.id);
|
||||||
await DownloadManager.startDownload(updatedGame!);
|
await DownloadManager.startDownload(updatedGame!);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
import { JSDOM } from "jsdom";
|
||||||
import UserAgent from "user-agents";
|
import UserAgent from "user-agents";
|
||||||
|
|
||||||
export const getSteamAppAsset = (
|
export const getSteamAppAsset = (
|
||||||
@ -48,13 +49,16 @@ export const sleep = (ms: number) =>
|
|||||||
export const requestWebPage = async (url: string) => {
|
export const requestWebPage = async (url: string) => {
|
||||||
const userAgent = new UserAgent();
|
const userAgent = new UserAgent();
|
||||||
|
|
||||||
return axios
|
const data = await axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
headers: {
|
headers: {
|
||||||
"User-Agent": userAgent.toString(),
|
"User-Agent": userAgent.toString(),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((response) => response.data);
|
.then((response) => response.data);
|
||||||
|
|
||||||
|
const { window } = new JSDOM(data);
|
||||||
|
return window.document;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const isPortableVersion = () =>
|
export const isPortableVersion = () =>
|
||||||
|
@ -6,7 +6,7 @@ import { downloadQueueRepository, gameRepository } from "@main/repository";
|
|||||||
import { publishDownloadCompleteNotification } from "../notifications";
|
import { publishDownloadCompleteNotification } from "../notifications";
|
||||||
import { RealDebridDownloader } from "./real-debrid-downloader";
|
import { RealDebridDownloader } from "./real-debrid-downloader";
|
||||||
import type { DownloadProgress } from "@types";
|
import type { DownloadProgress } from "@types";
|
||||||
import { GofileApi } from "../hosters";
|
import { GofileApi, QiwiApi } from "../hosters";
|
||||||
import { GenericHttpDownloader } from "./generic-http-downloader";
|
import { GenericHttpDownloader } from "./generic-http-downloader";
|
||||||
|
|
||||||
export class DownloadManager {
|
export class DownloadManager {
|
||||||
@ -96,26 +96,38 @@ export class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static async startDownload(game: Game) {
|
static async startDownload(game: Game) {
|
||||||
if (game.downloader === Downloader.Gofile) {
|
switch (game.downloader) {
|
||||||
const id = game!.uri!.split("/").pop();
|
case Downloader.Gofile: {
|
||||||
|
const id = game!.uri!.split("/").pop();
|
||||||
|
|
||||||
const token = await GofileApi.authorize();
|
const token = await GofileApi.authorize();
|
||||||
const downloadLink = await GofileApi.getDownloadLink(id!);
|
const downloadLink = await GofileApi.getDownloadLink(id!);
|
||||||
|
|
||||||
GenericHttpDownloader.startDownload(game, downloadLink, {
|
GenericHttpDownloader.startDownload(game, downloadLink, {
|
||||||
Cookie: `accountToken=${token}`,
|
Cookie: `accountToken=${token}`,
|
||||||
});
|
});
|
||||||
} else if (game.downloader === Downloader.PixelDrain) {
|
break;
|
||||||
const id = game!.uri!.split("/").pop();
|
}
|
||||||
|
case Downloader.PixelDrain: {
|
||||||
|
const id = game!.uri!.split("/").pop();
|
||||||
|
|
||||||
await GenericHttpDownloader.startDownload(
|
await GenericHttpDownloader.startDownload(
|
||||||
game,
|
game,
|
||||||
`https://pixeldrain.com/api/file/${id}?download`
|
`https://pixeldrain.com/api/file/${id}?download`
|
||||||
);
|
);
|
||||||
} else if (game.downloader === Downloader.Torrent) {
|
break;
|
||||||
PythonInstance.startDownload(game);
|
}
|
||||||
} else if (game.downloader === Downloader.RealDebrid) {
|
case Downloader.Qiwi: {
|
||||||
RealDebridDownloader.startDownload(game);
|
const downloadUrl = await QiwiApi.getDownloadUrl(game.uri!);
|
||||||
|
|
||||||
|
await GenericHttpDownloader.startDownload(game, downloadUrl);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Downloader.Torrent:
|
||||||
|
PythonInstance.startDownload(game);
|
||||||
|
break;
|
||||||
|
case Downloader.RealDebrid:
|
||||||
|
RealDebridDownloader.startDownload(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentDownloader = game.downloader;
|
this.currentDownloader = game.downloader;
|
||||||
|
@ -1 +1,2 @@
|
|||||||
export * from "./gofile";
|
export * from "./gofile";
|
||||||
|
export * from "./qiwi";
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { JSDOM } from "jsdom";
|
|
||||||
import { requestWebPage } from "@main/helpers";
|
import { requestWebPage } from "@main/helpers";
|
||||||
import { HowLongToBeatCategory } from "@types";
|
import { HowLongToBeatCategory } from "@types";
|
||||||
import { formatName } from "@shared";
|
import { formatName } from "@shared";
|
||||||
@ -52,10 +51,7 @@ const parseListItems = ($lis: Element[]) => {
|
|||||||
export const getHowLongToBeatGame = async (
|
export const getHowLongToBeatGame = async (
|
||||||
id: string
|
id: string
|
||||||
): Promise<HowLongToBeatCategory[]> => {
|
): Promise<HowLongToBeatCategory[]> => {
|
||||||
const response = await requestWebPage(`https://howlongtobeat.com/game/${id}`);
|
const document = await requestWebPage(`https://howlongtobeat.com/game/${id}`);
|
||||||
|
|
||||||
const { window } = new JSDOM(response);
|
|
||||||
const { document } = window;
|
|
||||||
|
|
||||||
const $ul = document.querySelector(".shadow_shadow ul");
|
const $ul = document.querySelector(".shadow_shadow ul");
|
||||||
if (!$ul) return [];
|
if (!$ul) return [];
|
||||||
|
@ -7,4 +7,5 @@ export const DOWNLOADER_NAME = {
|
|||||||
[Downloader.Torrent]: "Torrent",
|
[Downloader.Torrent]: "Torrent",
|
||||||
[Downloader.Gofile]: "Gofile",
|
[Downloader.Gofile]: "Gofile",
|
||||||
[Downloader.PixelDrain]: "PixelDrain",
|
[Downloader.PixelDrain]: "PixelDrain",
|
||||||
|
[Downloader.Qiwi]: "Qiwi",
|
||||||
};
|
};
|
||||||
|
@ -20,13 +20,16 @@ export const hintText = style({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const downloaders = style({
|
export const downloaders = style({
|
||||||
display: "flex",
|
display: "grid",
|
||||||
gap: `${SPACING_UNIT}px`,
|
gap: `${SPACING_UNIT}px`,
|
||||||
|
gridTemplateColumns: "repeat(2, 1fr)",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const downloaderOption = style({
|
export const downloaderOption = style({
|
||||||
flex: "1",
|
|
||||||
position: "relative",
|
position: "relative",
|
||||||
|
":only-child": {
|
||||||
|
gridColumn: "1 / -1",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const downloaderIcon = style({
|
export const downloaderIcon = style({
|
||||||
|
@ -3,6 +3,7 @@ export enum Downloader {
|
|||||||
Torrent,
|
Torrent,
|
||||||
Gofile,
|
Gofile,
|
||||||
PixelDrain,
|
PixelDrain,
|
||||||
|
Qiwi,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum DownloadSourceStatus {
|
export enum DownloadSourceStatus {
|
||||||
@ -75,6 +76,7 @@ export const getDownloadersForUri = (uri: string) => {
|
|||||||
if (uri.startsWith("https://gofile.io")) return [Downloader.Gofile];
|
if (uri.startsWith("https://gofile.io")) return [Downloader.Gofile];
|
||||||
|
|
||||||
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 (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