@@ -32,6 +32,7 @@ export class BanchoClient extends BaseClient {
3232 abilities : [
3333 ClientAbilities . GetBeatmapById ,
3434 ClientAbilities . GetBeatmapByHash ,
35+ ClientAbilities . GetBeatmapByFilename ,
3536 ClientAbilities . GetBeatmapSetById ,
3637 ClientAbilities . GetBeatmaps ,
3738 ClientAbilities . DownloadOsuBeatmap ,
@@ -49,6 +50,7 @@ export class BanchoClient extends BaseClient {
4950 abilities : [
5051 ClientAbilities . GetBeatmapById ,
5152 ClientAbilities . GetBeatmapByHash ,
53+ ClientAbilities . GetBeatmapByFilename ,
5254 ClientAbilities . GetBeatmapSetById ,
5355 ClientAbilities . GetBeatmaps ,
5456 ClientAbilities . DownloadOsuBeatmap ,
@@ -85,6 +87,9 @@ export class BanchoClient extends BaseClient {
8587 else if ( ctx . beatmapHash ) {
8688 return await this . getBeatmapByHash ( ctx . beatmapHash ) ;
8789 }
90+ else if ( ctx . beatmapFilename ) {
91+ return await this . getBeatmapByFilename ( ctx . beatmapFilename ) ;
92+ }
8893
8994 throw new Error ( "Invalid arguments" ) ;
9095 }
@@ -293,6 +298,30 @@ export class BanchoClient extends BaseClient {
293298 } ;
294299 }
295300
301+ private async getBeatmapByFilename (
302+ beatmapHash : string ,
303+ ) : Promise < ResultWithStatus < Beatmap > > {
304+ const result = await this . api . get < BanchoBeatmap > ( `api/v2/beatmaps/lookup` , {
305+ config : {
306+ headers : {
307+ Authorization : `Bearer ${ await this . osuApiKey } ` ,
308+ } ,
309+ params : {
310+ filename : beatmapHash ,
311+ } ,
312+ } ,
313+ } ) ;
314+
315+ if ( ! result || result . status !== 200 || ! result . data ) {
316+ return { result : null , status : result ?. status ?? 500 } ;
317+ }
318+
319+ return {
320+ result : this . convertService . convertBeatmap ( result . data ) ,
321+ status : result . status ,
322+ } ;
323+ }
324+
296325 private get osuApiKey ( ) {
297326 return this . banchoService . getBanchoClientToken ( ) ;
298327 }
0 commit comments