File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -6,8 +6,16 @@ import * as logger from './logger'
6
6
7
7
export async function download ( apiPath : string , dest : string ) : Promise < void > {
8
8
logger . Assets . info ( 'DOWNLOAD' , apiPath )
9
- const { data} = await axios . get < fs . ReadStream > ( apiPath , { responseType : 'stream' } )
9
+ const { data} = await axios . get < fs . ReadStream > ( apiPath , {
10
+ headers : { 'Accept' : 'image/*' } ,
11
+ responseType : 'stream' ,
12
+ } )
10
13
. catch ( err => {
14
+ // Sometimes Crafatar responds with 500 AND the correct image. If this is
15
+ // the case, just return the body which is enough of use.
16
+ if ( err . response . headers [ 'content-length' ] && err . response . headers [ 'content-type' ] . startsWith ( 'image/' ) ) {
17
+ return { data : err . response . data }
18
+ }
11
19
logger . Assets . error ( 'DOWNLOAD' , apiPath , err . toJSON ( ) )
12
20
return { data : null }
13
21
} )
@@ -38,7 +46,7 @@ export function mergeStats (data: McPlayerStatsJson): McPlayerStatsJson {
38
46
}
39
47
40
48
export function defaultSkin ( uuid : LongUuid ) : 'Alex' | 'Steve' {
41
- // great thanks to Minecrell for research into Minecraft and Java's UUID hashing!
49
+ // Great thanks to Minecrell for research into Minecraft and Java's UUID hashing!
42
50
// https://git.io/xJpV
43
51
// MC uses `uuid.hashCode() & 1` for alex
44
52
// that can be compacted to counting the LSBs of every 4th byte in the UUID
You can’t perform that action at this time.
0 commit comments