Compare commits
2 commits
53c95f1a4e
...
976dbbda4a
Author | SHA1 | Date | |
---|---|---|---|
976dbbda4a | |||
f4a9e82f4b |
2 changed files with 12 additions and 13 deletions
|
@ -17,19 +17,19 @@ export abstract class Provider {
|
||||||
public hashFormat: string,
|
public hashFormat: string,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
abstract getDownloadUrl(): Promise<Resource>;
|
abstract get downloadUrl(): Resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UrlProvider extends Provider {
|
export class UrlProvider extends Provider {
|
||||||
constructor(
|
constructor(
|
||||||
public hash: string,
|
public hash: string,
|
||||||
public hashFormat: string,
|
public hashFormat: string,
|
||||||
public url: string,
|
private url: string,
|
||||||
) {
|
) {
|
||||||
super(hash, hashFormat);
|
super(hash, hashFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDownloadUrl(): Promise<Resource> {
|
get downloadUrl(): Resource {
|
||||||
return new Resource(this.url);
|
return new Resource(this.url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,10 @@ export class CurseForgeProvider extends Provider {
|
||||||
super(hash, hashFormat);
|
super(hash, hashFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDownloadUrl(): Promise<Resource> {
|
get downloadUrl(): Resource {
|
||||||
// const mod = await CURSE_CLIENT.getMod(this.projectId);
|
return new Resource(
|
||||||
// const file = await mod.getFile(this.fileId);
|
`https://www.curseforge.com/api/v1/mods/${this.projectId}/files/${this.fileId}/download`,
|
||||||
// return new Resource(await file.getDownloadURL());
|
);
|
||||||
return new Resource("https://google.com/search?q=curseforge+sucks"); // TODO: figure this out, i hate curseforge
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@ import * as path from "path";
|
||||||
export default class Resource {
|
export default class Resource {
|
||||||
constructor(public readonly path: string) {}
|
constructor(public readonly path: string) {}
|
||||||
|
|
||||||
toString() {
|
toString(): string {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
get isUrl() {
|
get isUrl(): boolean {
|
||||||
try {
|
try {
|
||||||
new URL(this.path);
|
new URL(this.path);
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,13 +18,13 @@ export default class Resource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name(): string {
|
||||||
return this.isUrl
|
return this.isUrl
|
||||||
? new URL(this.path).pathname.split("/").pop() || ""
|
? new URL(this.path).pathname.split("/").pop() || ""
|
||||||
: path.basename(this.path);
|
: path.basename(this.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
get parent() {
|
get parent(): Resource {
|
||||||
if (this.isUrl) {
|
if (this.isUrl) {
|
||||||
const url = new URL(this.path);
|
const url = new URL(this.path);
|
||||||
url.pathname = path.dirname(url.pathname);
|
url.pathname = path.dirname(url.pathname);
|
||||||
|
@ -33,7 +33,7 @@ export default class Resource {
|
||||||
return new Resource(path.dirname(this.path));
|
return new Resource(path.dirname(this.path));
|
||||||
}
|
}
|
||||||
|
|
||||||
get ext() {
|
get ext(): string {
|
||||||
return this.isUrl
|
return this.isUrl
|
||||||
? path.extname(new URL(this.path).pathname)
|
? path.extname(new URL(this.path).pathname)
|
||||||
: path.extname(this.path);
|
: path.extname(this.path);
|
||||||
|
|
Loading…
Add table
Reference in a new issue