@@ -32,6 +32,7 @@ function getClient() {
3232 if ( urlMatch ( 'zmescience.com' ) ) return 'sovrnus' ;
3333 if ( urlMatch ( [ 'livingly.com' , 'independent.ie' ] ) ) return 'sovrnuk' ;
3434 if ( urlMatch ( 'clickon.co' ) ) return 'clickon' ;
35+ if ( urlMatch ( [ 'lbc.co.uk' , 'classicfm.com' , 'capitalfm.com' , 'heart.co.uk' ] ) ) return 'global-radio' ;
3536
3637 function urlMatch ( url ) {
3738 return Array . isArray ( url )
@@ -46,11 +47,7 @@ const CLIENT = getClient();
4647
4748class App extends React . Component {
4849 static getVideos ( url , client ) {
49- let endpoint = `https://uat.suggestv.io/semantics?url=${ url } &skipcache=true` ;
50-
51- if ( client === 'telegraph' ) {
52- endpoint += `&client=${ client } ` ;
53- }
50+ let endpoint = `https://uat.suggestv.io/semantics?url=${ url } &client=${ client } &skipcache=true` ;
5451
5552 return fetch ( endpoint , {
5653 method : 'GET' ,
@@ -167,54 +164,26 @@ class App extends React.Component {
167164
168165 setVideos ( data ) {
169166 let videos = [ ] ;
170- const SCORE_LIMIT = CLIENT === 'telegraph' ? 7 : 25 ;
171- this . setState ( { query : data . query } ) ;
167+ const SCORE_LIMIT = 15 ;
168+ this . setState ( { query : data . keywords } ) ;
172169
173- if ( data !== null && data . results && data . results . hits && data . results . hits . hit . length !== 0 ) {
170+ if ( data !== null && data . results && data . results . length > 0 ) {
174171
175- data . results . hits . hit . slice ( 0 , 4 ) . forEach ( ( video ) => {
172+ data . results . forEach ( ( video ) => {
176173 let keywordsMatched = [ ] ;
177174 const highlights = video . highlights ;
178175 const fields = video . fields ;
179176 const regex = / \* ( \S [ \s \S ] * ?) \* / g;
180177
181- // grab all highlighted keywords
182- if ( CLIENT === 'telegraph' ) {
183- keywordsMatched = keywordsMatched
184- . concat ( highlights . extra_one . match ( regex ) || [ ] )
185- . concat ( highlights . description . match ( regex ) || [ ] )
186- . concat ( highlights . keywords . match ( regex ) || [ ] )
187- . concat ( highlights . thumbnail_alt . match ( regex ) || [ ] )
188- . concat ( highlights . thumbnail_alt_small . match ( regex ) || [ ] ) ;
189-
190- } else {
191- keywordsMatched = keywordsMatched
192- . concat ( highlights . descriptions_default . match ( regex ) || [ ] )
193- . concat ( highlights . descriptions_long . match ( regex ) || [ ] )
194- . concat ( highlights . title . match ( regex ) || [ ] )
195- . concat ( highlights . slug . match ( regex ) || [ ] )
196- . concat ( highlights . thumbnails_large_alttext . match ( regex ) || [ ] )
197- . concat ( highlights . thumbnails_small_alttext . match ( regex ) || [ ] )
198- . concat ( highlights . published . match ( regex ) || [ ] ) ;
199- }
200-
201- // deduplicate array
202- const uniqueKeywords = [ ] ;
203- keywordsMatched
204- . map ( k => k . toLowerCase ( ) )
205- . forEach ( ( k ) => {
206- if ( uniqueKeywords . indexOf ( k ) === - 1 ) uniqueKeywords . push ( k ) ;
207- } ) ;
208-
209- if ( Number ( fields . _score [ 0 ] ) > SCORE_LIMIT && uniqueKeywords . length >= 1 ) {
178+ if ( Number ( fields . _score [ 0 ] ) > SCORE_LIMIT ) {
210179 videos . push ( {
211180 sources : [ {
212- src : CLIENT === 'telegraph' ? fields . video_url [ 0 ] : fields . videos_hd_uri [ 0 ] ,
181+ src : fields . sources [ 0 ] ,
213182 type : 'video/mp4' ,
214183 } ] ,
215- poster : CLIENT === 'telegraph' ? fields . thumbnail_url [ 0 ] : fields . thumbnails_large_src [ 0 ] ,
216- title : CLIENT === 'telegraph' ? fields . extra_one [ 0 ] : fields . title [ 0 ] ,
217- description : CLIENT === 'telegraph' ? fields . description [ 0 ] : fields . descriptions_default [ 0 ] ,
184+ poster : fields . poster [ 0 ] ,
185+ title : fields . title [ 0 ] ,
186+ description : fields . description [ 0 ] ,
218187 videoId : video . id ,
219188 } ) ;
220189 }
0 commit comments