feat: few adjustments

This commit is contained in:
Zamitto 2025-01-12 11:00:20 -03:00
parent db2e31b8cc
commit b1dde446b2
3 changed files with 11 additions and 7 deletions

View File

@ -10,19 +10,19 @@ import type {
export class TorBoxClient {
private static instance: AxiosInstance;
private static readonly baseURL = "https://api.torbox.app/v1/api";
public static apiToken: string;
private static apiToken: string;
static authorize(apiToken: string) {
this.apiToken = apiToken;
this.instance = axios.create({
baseURL: this.baseURL,
headers: {
Authorization: `Bearer ${apiToken}`,
},
});
this.apiToken = apiToken;
}
static async addMagnet(magnet: string) {
private static async addMagnet(magnet: string) {
const form = new FormData();
form.append("magnet", magnet);
@ -31,6 +31,10 @@ export class TorBoxClient {
form
);
if (!response.data.success) {
throw new Error(response.data.detail);
}
return response.data.data;
}
@ -74,7 +78,7 @@ export class TorBoxClient {
return response.data.data;
}
static async getTorrentIdAndName(magnetUri: string) {
private static async getTorrentIdAndName(magnetUri: string) {
const userTorrents = await this.getAllTorrentsFromUser();
const { infoHash } = await parseTorrent(magnetUri);

View File

@ -163,7 +163,7 @@ export interface UserPreferences {
repackUpdatesNotificationsEnabled: boolean;
achievementNotificationsEnabled: boolean;
realDebridApiToken: string | null;
torboxApiToken: string | null;
torBoxApiToken: string | null;
preferQuitInsteadOfHiding: boolean;
runAtStartup: boolean;
startMinimized: boolean;

View File

@ -54,14 +54,14 @@ export interface TorBoxTorrentInfo {
export interface TorBoxTorrentInfoRequest {
success: boolean;
detail: string;
error: string;
error: string | null;
data: TorBoxTorrentInfo[];
}
export interface TorBoxAddTorrentRequest {
success: boolean;
detail: string;
error: string;
error: string | null;
data: {
torrent_id: number;
name: string;