@@ -16,10 +16,14 @@ export class XavierCruzLoader implements Loader {
16
16
`Loaded ${ credits . length } credits and ${ mediaItems . length } media items` ,
17
17
) ;
18
18
19
+ let counter = 0 ;
19
20
for ( let i = 0 ; i < mediaItems . length ; i ++ ) {
20
21
if ( i < mediaItems . length / 2 ) {
21
- mediaItems [ i ] . addCredit ( credits [ i ] as Credit ) ;
22
+ mediaItems [ i ] . addCredit ( credits [ counter ] as Credit ) ;
23
+ counter ++ ;
24
+ mediaItems [ i ] . addCredit ( credits [ counter ] as Credit ) ;
22
25
}
26
+ counter ++ ;
23
27
}
24
28
25
29
return [ ...mediaItems . values ( ) ] ;
@@ -44,14 +48,16 @@ export class XavierCruzLoader implements Loader {
44
48
const fileContents = fs . readFileSync ( filePath , 'utf-8' ) ;
45
49
46
50
const lines = fileContents . split ( '\n' ) ;
47
- const newString = lines . slice ( 1 ) ;
51
+ const contentByLine = lines . slice ( 1 ) ;
48
52
49
- for ( let i = 0 ; i < newString . length ; i ++ ) {
50
- newString [ i ] = newString [ i ] . substring ( newString [ i ] . indexOf ( ',' ) + 1 ) ;
53
+ for ( let i = 0 ; i < contentByLine . length ; i ++ ) {
54
+ contentByLine [ i ] = contentByLine [ i ] . substring (
55
+ contentByLine [ i ] . indexOf ( ',' ) + 1 ,
56
+ ) ;
51
57
}
52
58
53
59
// help from ChatGPT - Fixing the roleStr as Role issue
54
- const credits : Credit [ ] = newString . map ( ( credit ) => {
60
+ const credits : Credit [ ] = contentByLine . map ( ( credit ) => {
55
61
const [ mediaItemId , roleStr , name ] = credit . split ( ',' ) ;
56
62
57
63
// cast roleStr to Role type
0 commit comments