mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-15 16:33:02 -03:00
refactor: update download ID extraction and improve optional chaining in download services
This commit is contained in:
@@ -450,9 +450,9 @@ export class DownloadManager {
|
||||
} | null> {
|
||||
switch (download.downloader) {
|
||||
case Downloader.Gofile: {
|
||||
const id = download.uri.split("/").pop()!;
|
||||
const id = download.uri.split("/").pop();
|
||||
const token = await GofileApi.authorize();
|
||||
const downloadLink = await GofileApi.getDownloadLink(id);
|
||||
const downloadLink = await GofileApi.getDownloadLink(id as string);
|
||||
await GofileApi.checkDownloadUrl(downloadLink);
|
||||
|
||||
return {
|
||||
@@ -462,8 +462,8 @@ export class DownloadManager {
|
||||
};
|
||||
}
|
||||
case Downloader.PixelDrain: {
|
||||
const id = download.uri.split("/").pop()!;
|
||||
const downloadUrl = await PixelDrainApi.getDownloadUrl(id);
|
||||
const id = download.uri.split("/").pop();
|
||||
const downloadUrl = await PixelDrainApi.getDownloadUrl(id as string);
|
||||
|
||||
return {
|
||||
url: downloadUrl,
|
||||
@@ -576,9 +576,9 @@ export class DownloadManager {
|
||||
|
||||
switch (download.downloader) {
|
||||
case Downloader.Gofile: {
|
||||
const id = download.uri.split("/").pop()!;
|
||||
const id = download.uri.split("/").pop();
|
||||
const token = await GofileApi.authorize();
|
||||
const downloadLink = await GofileApi.getDownloadLink(id);
|
||||
const downloadLink = await GofileApi.getDownloadLink(id as string);
|
||||
await GofileApi.checkDownloadUrl(downloadLink);
|
||||
|
||||
return {
|
||||
@@ -592,8 +592,8 @@ export class DownloadManager {
|
||||
};
|
||||
}
|
||||
case Downloader.PixelDrain: {
|
||||
const id = download.uri.split("/").pop()!;
|
||||
const downloadUrl = await PixelDrainApi.getDownloadUrl(id);
|
||||
const id = download.uri.split("/").pop();
|
||||
const downloadUrl = await PixelDrainApi.getDownloadUrl(id as string);
|
||||
|
||||
return {
|
||||
action: "start",
|
||||
|
||||
@@ -134,7 +134,7 @@ export class JsHttpDownloader {
|
||||
): Promise<void> {
|
||||
const response = await fetch(url, {
|
||||
headers: requestHeaders,
|
||||
signal: this.abortController!.signal,
|
||||
signal: this.abortController?.signal,
|
||||
});
|
||||
|
||||
if (!response.ok && response.status !== 206) {
|
||||
|
||||
@@ -61,7 +61,7 @@ export class JsMultiLinkDownloader {
|
||||
});
|
||||
|
||||
const status = this.downloader.getDownloadStatus();
|
||||
if (status && status.status === "complete") {
|
||||
if (status?.status === "complete") {
|
||||
this.completedDownloads.push({
|
||||
name: status.folderName,
|
||||
size: status.fileSize,
|
||||
@@ -105,7 +105,7 @@ export class JsMultiLinkDownloader {
|
||||
});
|
||||
|
||||
const status = this.downloader.getDownloadStatus();
|
||||
if (status && status.status === "complete") {
|
||||
if (status?.status === "complete") {
|
||||
this.completedDownloads.push({
|
||||
name: status.folderName,
|
||||
size: status.fileSize,
|
||||
|
||||
Reference in New Issue
Block a user