Skip to content

Commit

Permalink
Added cached map thumbnail from tmio (closes #73)
Browse files Browse the repository at this point in the history
  • Loading branch information
GreepTheSheep committed Dec 26, 2021
1 parent 5fd4430 commit fad8232
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/structures/TMMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ class TMMap {
return this._data.mapUid;
}

/**
* The map Storage Object ID.
* @returns {string}
*/
get storageId() {
return this.thumbnail.replace(/^[a-z:/.]*([^]*)\.[a-z]*$/gi, '$1');
}

/**
* The map author.
* @returns {Promise<Player>}
Expand Down Expand Up @@ -115,13 +123,21 @@ class TMMap {
}

/**
* The map thumbnail.
* The map thumbnail (from Nadeo services, direct download).
* @type {string}
*/
get thumbnail() {
return this._data.thumbnailUrl;
}

/**
* The map thumbnail (cached from trackmania.io, can show).
* @type {string}
*/
get thumbnailCached() {
return `${new ReqUtil(this.client).tmioAPIURL}/download/jpg/${this.storageId}`;
}

/**
* The map exchange id, if the map is on trackmania.exchange, else null.
* @type {?string}
Expand Down

0 comments on commit fad8232

Please sign in to comment.