@@ -18,14 +18,14 @@ export type AnimeListsSchema = Array<{
1818 anilist_id ?: number
1919 "anime-planet_id" ?: string
2020 anisearch_id ?: number
21- imdb_id ?: `tt${string } ` | ""
21+ imdb_id ?: Array < `tt${string } ` | "" >
2222 kitsu_id ?: number
2323 livechart_id ?: number
2424 mal_id ?: number
2525 animenewsnetwork_id ?: number
2626 animecountdown_id ?: number
2727 simkl_id ?: number
28- themoviedb_id ?: { [ Key in "tv" | "movie" ] ?: number | "unknown" }
28+ themoviedb_id ?: { [ Key in "tv" | "movie" ] ?: Array < number | "unknown" > }
2929 tvdb_id ?: number
3030 season ?: {
3131 tvdb ?: number
@@ -98,13 +98,13 @@ export const formatEntry = (entry: AnimeListsSchema[number]): Relation => ({
9898 animecountdown : handleBadValues ( entry . animecountdown_id ) ,
9999 animenewsnetwork : handleBadValues ( entry . animenewsnetwork_id ) ,
100100 anisearch : handleBadValues ( entry . anisearch_id ) ,
101- imdb : handleBadValues ( entry . imdb_id ) ,
101+ imdb : handleBadValues ( entry . imdb_id ?. [ 0 ] ) ,
102102 kitsu : handleBadValues ( entry . kitsu_id ) ,
103103 livechart : handleBadValues ( entry . livechart_id ) ,
104104 media : handleBadValues ( entry . type ) ,
105105 myanimelist : handleBadValues ( entry . mal_id ) ,
106106 simkl : handleBadValues ( entry . simkl_id ) ,
107- themoviedb : handleBadValues ( entry . themoviedb_id ?. tv ?? entry . themoviedb_id ?. movie ) ,
107+ themoviedb : handleBadValues ( ( entry . themoviedb_id ?. tv ?? entry . themoviedb_id ?. movie ) ?. [ 0 ] ) ,
108108 "themoviedb-season" : handleBadValues ( entry . season ?. tmdb ) ,
109109 thetvdb : handleBadValues ( entry . tvdb_id ) ,
110110 "thetvdb-season" : handleBadValues ( entry . season ?. tvdb ) ,
@@ -149,7 +149,13 @@ export const updateRelations = async () => {
149149 for ( let i = 0 ; i < goodEntries . length ; i += chunkSize ) {
150150 const chunk = goodEntries . slice ( i , i + chunkSize )
151151 for ( const entry of chunk ) {
152- await trx . insertInto ( "relations" ) . values ( entry ) . execute ( )
152+ try {
153+ await trx . insertInto ( "relations" ) . values ( entry ) . execute ( )
154+ } catch ( error ) {
155+ throw new Error ( `Inserting row failed.\n${ JSON . stringify ( entry , null , 2 ) } ` , {
156+ cause : error ,
157+ } )
158+ }
153159 }
154160 }
155161 } )
0 commit comments