refactor: real debrid types

This commit is contained in:
lilezek 2024-04-30 11:09:53 +02:00
parent 6d36db5446
commit c5693e94af
2 changed files with 5 additions and 17 deletions

View file

@ -1,4 +1,4 @@
interface RealDebridUnrestrictLink {
export interface RealDebridUnrestrictLink {
id: string;
filename: string;
mimeType: string;
@ -12,13 +12,13 @@ interface RealDebridUnrestrictLink {
streamable: number;
}
interface RealDebridAddMagnet {
export interface RealDebridAddMagnet {
"id": string,
// URL of the created ressource
"uri": string
}
interface RealDebridTorrentInfo {
export interface RealDebridTorrentInfo {
"id": string,
"filename": string,
"original_filename": string, // Original name of the torrent
@ -50,16 +50,4 @@ interface RealDebridTorrentInfo {
"ended": string, // !! Only present when finished, jsonDate
"speed": number, // !! Only present in "downloading", "compressing", "uploading" status
"seeders": number // !! Only present in "downloading", "magnet_conversion" status
}
declare module 'real-debrid-api' {
interface Torrent {
addMagnet(magnet: string): Promise<RealDebridAddMagnet>;
info(id: string): Promise<RealDebridTorrentInfo[]>;
}
export default class {
constructor(token: string);
torrents: Torrent;
}
}

View file

@ -1,6 +1,6 @@
/// <reference path="./real-debrid.d.ts" />
import { userPreferencesRepository } from "@main/repository";
import fetch from "node-fetch";
import { RealDebridAddMagnet, RealDebridTorrentInfo, RealDebridUnrestrictLink } from "./real-debrid-types";
const base = "https://api.real-debrid.com/rest/1.0";
@ -50,6 +50,6 @@ export class RealDebridClient {
}
static getApiToken() {
return userPreferencesRepository.findOne({ where: { id: 1 } }).then(userPreferences => userPreferences.realDebridApiToken);
return userPreferencesRepository.findOne({ where: { id: 1 } }).then(userPreferences => userPreferences!.realDebridApiToken);
}
}