@@ -56,16 +56,16 @@ export default async () => {
5656 transform : async ( response ) => {
5757 const url = response . data . weblink ;
5858 const user = url . slice ( url . lastIndexOf ( '/' ) + 1 ) ;
59- let thumbnail =
59+ let image =
6060 `https://www.speedrun.com/themes/user/${ user } /image.png` ;
61- const imageRes = await fetch ( thumbnail , {
61+ const imageRes = await fetch ( image , {
6262 method : 'HEAD'
6363 } ) ;
64- if ( ! imageRes . ok ) { thumbnail = null ; }
64+ if ( ! imageRes . ok ) { image = null ; }
6565 return {
6666 url,
6767 name : response . data . names . international ,
68- thumbnail ,
68+ image ,
6969 } ;
7070 } ,
7171 ttl : 1000 * 60 * 60 * 24 // 1day
@@ -77,18 +77,19 @@ export default async () => {
7777 return ! ! users . filter ( u => ! ! u ) . length ;
7878 } ;
7979
80- const addMetaToVideo = async ( run , meta ) => {
80+ const addGameToVideo = async ( run , meta ) => {
8181 if ( ! run . game && meta . gameID ) {
82- const game = await util . ajax (
82+ run . game = await util . ajax (
8383 'https://www.speedrun.com/api/v1/games/' + meta . gameID , {
8484 cache : {
8585 transform : ( response ) => ( {
86- name : response . data . names . international
86+ name : response . data . names . international ,
87+ url : response . data . weblink ,
88+ image : response . data . assets [ 'cover-small' ] . uri ,
8789 } ) ,
8890 ttl : 1000 * 60 * 60 * 24 // 1day
8991 } ,
9092 } ) ;
91- run . game = game . name ;
9293 return true ;
9394 } else {
9495 return true ;
@@ -102,7 +103,7 @@ export default async () => {
102103 run . desc = meta . desc ;
103104 const results = await Promise . all ( [
104105 addUsersToRun ( run , meta ) ,
105- addMetaToVideo ( run , meta )
106+ addGameToVideo ( run , meta )
106107 ] ) ;
107108 return results [ 0 ] && results [ 1 ] ;
108109 } ;
0 commit comments