Compare commits
No commits in common. "976dbbda4aaed3de8cd4ce4e35ecbf92ba056190" and "53c95f1a4ec43945be9276f12e5f9d1ac8fe277d" have entirely different histories.
976dbbda4a
...
53c95f1a4e
2 changed files with 13 additions and 12 deletions
|
@ -17,19 +17,19 @@ export abstract class Provider {
|
|||
public hashFormat: string,
|
||||
) {}
|
||||
|
||||
abstract get downloadUrl(): Resource;
|
||||
abstract getDownloadUrl(): Promise<Resource>;
|
||||
}
|
||||
|
||||
export class UrlProvider extends Provider {
|
||||
constructor(
|
||||
public hash: string,
|
||||
public hashFormat: string,
|
||||
private url: string,
|
||||
public url: string,
|
||||
) {
|
||||
super(hash, hashFormat);
|
||||
}
|
||||
|
||||
get downloadUrl(): Resource {
|
||||
async getDownloadUrl(): Promise<Resource> {
|
||||
return new Resource(this.url);
|
||||
}
|
||||
}
|
||||
|
@ -71,10 +71,11 @@ export class CurseForgeProvider extends Provider {
|
|||
super(hash, hashFormat);
|
||||
}
|
||||
|
||||
get downloadUrl(): Resource {
|
||||
return new Resource(
|
||||
`https://www.curseforge.com/api/v1/mods/${this.projectId}/files/${this.fileId}/download`,
|
||||
);
|
||||
async getDownloadUrl(): Promise<Resource> {
|
||||
// const mod = await CURSE_CLIENT.getMod(this.projectId);
|
||||
// const file = await mod.getFile(this.fileId);
|
||||
// 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 {
|
||||
constructor(public readonly path: string) {}
|
||||
|
||||
toString(): string {
|
||||
toString() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
get isUrl(): boolean {
|
||||
get isUrl() {
|
||||
try {
|
||||
new URL(this.path);
|
||||
return true;
|
||||
|
@ -18,13 +18,13 @@ export default class Resource {
|
|||
}
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
get name() {
|
||||
return this.isUrl
|
||||
? new URL(this.path).pathname.split("/").pop() || ""
|
||||
: path.basename(this.path);
|
||||
}
|
||||
|
||||
get parent(): Resource {
|
||||
get parent() {
|
||||
if (this.isUrl) {
|
||||
const url = new URL(this.path);
|
||||
url.pathname = path.dirname(url.pathname);
|
||||
|
@ -33,7 +33,7 @@ export default class Resource {
|
|||
return new Resource(path.dirname(this.path));
|
||||
}
|
||||
|
||||
get ext(): string {
|
||||
get ext() {
|
||||
return this.isUrl
|
||||
? path.extname(new URL(this.path).pathname)
|
||||
: path.extname(this.path);
|
||||
|
|
Loading…
Add table
Reference in a new issue