@@ -59,29 +59,27 @@ app.get('/cinema', (req, res) => {
59
59
showtimes . push ( theater )
60
60
} )
61
61
62
- const urls = movie
63
- . find ( 'img' )
64
- . attr ( 'src' )
65
- . match ( / \/ i m a g e s \/ p o s t e r \/ .+ \. ( j p g | j p e g | p n g ) / ig) || [ ]
66
-
67
- const imgUrl = `http://kvikmyndir.is${ urls [ 0 ] } `
68
-
69
- const realeasedYear = movie
70
- . find ( '.mynd_titill_artal' )
71
- . text ( )
72
- . replace ( '/[()]/g' , '' )
73
-
74
- // Create an object of info
75
- // and add it to the 'results' array.
76
- obj . results . push ( {
77
- title : movie . find ( '.title' ) . remove ( '.year' ) . html ( ) . trim ( ) ,
78
- released : realeasedYear ,
79
- restricted : null ,
80
- imdb : movie . find ( '.imdbEinkunn' ) . text ( ) . trim ( ) ,
81
- imdbLink : movie . find ( '.imdbEinkunn a' ) . attr ( 'href' ) ? movie . find ( '.imdbEinkunn a' ) . attr ( 'href' ) . trim ( ) : '' ,
82
- image : imgUrl ,
83
- showtimes,
84
- } )
62
+ const src = movie . find ( 'img' ) . attr ( 'src' )
63
+ if ( src ) {
64
+ const urls = src . match ( / \/ i m a g e s \/ p o s t e r \/ .+ \. ( j p g | j p e g | p n g ) / ig) || [ ]
65
+ const imgUrl = `http://kvikmyndir.is${ urls [ 0 ] } `
66
+ const realeasedYear = movie
67
+ . find ( '.mynd_titill_artal' )
68
+ . text ( )
69
+ . replace ( '/[()]/g' , '' )
70
+
71
+ // Create an object of info
72
+ // and add it to the 'results' array.
73
+ obj . results . push ( {
74
+ title : movie . find ( '.title' ) . remove ( '.year' ) . html ( ) . trim ( ) ,
75
+ released : realeasedYear ,
76
+ restricted : null ,
77
+ imdb : movie . find ( '.imdbEinkunn' ) . text ( ) . trim ( ) ,
78
+ imdbLink : movie . find ( '.imdbEinkunn a' ) . attr ( 'href' ) ? movie . find ( '.imdbEinkunn a' ) . attr ( 'href' ) . trim ( ) : '' ,
79
+ image : imgUrl ,
80
+ showtimes,
81
+ } )
82
+ }
85
83
} )
86
84
87
85
return res . cache ( ) . json ( obj )
0 commit comments