mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-01-23 13:34:54 +03:00
feat: few adjustments
This commit is contained in:
parent
db2e31b8cc
commit
b1dde446b2
@ -10,19 +10,19 @@ import type {
|
|||||||
export class TorBoxClient {
|
export class TorBoxClient {
|
||||||
private static instance: AxiosInstance;
|
private static instance: AxiosInstance;
|
||||||
private static readonly baseURL = "https://api.torbox.app/v1/api";
|
private static readonly baseURL = "https://api.torbox.app/v1/api";
|
||||||
public static apiToken: string;
|
private static apiToken: string;
|
||||||
|
|
||||||
static authorize(apiToken: string) {
|
static authorize(apiToken: string) {
|
||||||
|
this.apiToken = apiToken;
|
||||||
this.instance = axios.create({
|
this.instance = axios.create({
|
||||||
baseURL: this.baseURL,
|
baseURL: this.baseURL,
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${apiToken}`,
|
Authorization: `Bearer ${apiToken}`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
this.apiToken = apiToken;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async addMagnet(magnet: string) {
|
private static async addMagnet(magnet: string) {
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("magnet", magnet);
|
form.append("magnet", magnet);
|
||||||
|
|
||||||
@ -31,6 +31,10 @@ export class TorBoxClient {
|
|||||||
form
|
form
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!response.data.success) {
|
||||||
|
throw new Error(response.data.detail);
|
||||||
|
}
|
||||||
|
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +78,7 @@ export class TorBoxClient {
|
|||||||
return response.data.data;
|
return response.data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getTorrentIdAndName(magnetUri: string) {
|
private static async getTorrentIdAndName(magnetUri: string) {
|
||||||
const userTorrents = await this.getAllTorrentsFromUser();
|
const userTorrents = await this.getAllTorrentsFromUser();
|
||||||
|
|
||||||
const { infoHash } = await parseTorrent(magnetUri);
|
const { infoHash } = await parseTorrent(magnetUri);
|
||||||
|
@ -163,7 +163,7 @@ export interface UserPreferences {
|
|||||||
repackUpdatesNotificationsEnabled: boolean;
|
repackUpdatesNotificationsEnabled: boolean;
|
||||||
achievementNotificationsEnabled: boolean;
|
achievementNotificationsEnabled: boolean;
|
||||||
realDebridApiToken: string | null;
|
realDebridApiToken: string | null;
|
||||||
torboxApiToken: string | null;
|
torBoxApiToken: string | null;
|
||||||
preferQuitInsteadOfHiding: boolean;
|
preferQuitInsteadOfHiding: boolean;
|
||||||
runAtStartup: boolean;
|
runAtStartup: boolean;
|
||||||
startMinimized: boolean;
|
startMinimized: boolean;
|
||||||
|
@ -54,14 +54,14 @@ export interface TorBoxTorrentInfo {
|
|||||||
export interface TorBoxTorrentInfoRequest {
|
export interface TorBoxTorrentInfoRequest {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
detail: string;
|
detail: string;
|
||||||
error: string;
|
error: string | null;
|
||||||
data: TorBoxTorrentInfo[];
|
data: TorBoxTorrentInfo[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TorBoxAddTorrentRequest {
|
export interface TorBoxAddTorrentRequest {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
detail: string;
|
detail: string;
|
||||||
error: string;
|
error: string | null;
|
||||||
data: {
|
data: {
|
||||||
torrent_id: number;
|
torrent_id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user