@@ -143,7 +143,7 @@ function generateWeights(prev, movies) {
143143 const writer = toLookupTable ( prev . Writer ) ;
144144 const country = toLookupTable ( prev . Country ) ;
145145 const role = toLookupTable ( prev . Role ) ;
146- const { year, rating } = prev ;
146+ const { year} = prev ;
147147
148148 return movies
149149 . map ( ( movie , i ) => {
@@ -154,7 +154,7 @@ function generateWeights(prev, movies) {
154154 weight += countMatches ( movie . Country , country ) * ( + process . env . COUNTRY_WEIGHT || 1 ) ;
155155 weight += countMatches ( movie . Role , role ) * ( + process . env . ROLE_WEIGHT || 1 ) ;
156156 weight += ( movie . year === year ? 1 : 0 ) * ( + process . env . YEAR_WEIGHT || 1 ) ;
157- weight *= rating ;
157+ weight += movie . rating * ( + process . env . RATING_WEIGHT || 1 ) ;
158158 return [ weight , i ] ;
159159 } )
160160 . sort ( ( [ a ] , [ b ] ) => b - a ) ;
@@ -169,7 +169,9 @@ async function selectMediaStreams(movie) {
169169 for ( m of media ) {
170170 const { Stream, file} = m . Part [ 0 ] ;
171171 const video = Stream . find ( ( { streamType} ) => streamType === 1 ) ;
172- const audio = Stream . find ( ( { streamType, languageCode} ) => streamType === 2 && languageCode === 'eng' ) ;
172+
173+ const audioTracks = Stream . filter ( ( { streamType, languageCode} ) => streamType === 2 ) ;
174+ const audio = audioTracks . length === 1 ? audioTracks [ 0 ] : audioTracks . find ( ( { streamType, languageCode} ) => languageCode === 'eng' ) ;
173175
174176 if ( video && audio ) {
175177 return { video, audio, file} ;
@@ -226,6 +228,7 @@ function playMovie(movie, {audio, video, file}, nextMovie) {
226228 '-b:a' , '160k' ,
227229 '-ac' , '2' ,
228230 '-bufsize' , '7000k' ,
231+ '-flvflags' , 'no_duration_filesize' ,
229232 '-f' , 'flv' , process . env . ANGELTHUMP_INGEST ,
230233 ] ;
231234 const ffmpeg = spawn ( 'ffmpeg' , options ) ;
@@ -295,10 +298,10 @@ async function notifyChat(movie) {
295298 } ) ,
296299 ] ) ;
297300
298- const imdbInfo = imdbUrl && ` - ${ imdbUrl } (${ movie . rating } )` ;
299- let emotes = process . env . STRIMS_EMOTES && process . env . STRIMS_EMOTES . split ( "," )
300- let selectedEmote = emotes && emotes [ Math . floor ( Math . random ( ) * emotes . length ) ]
301- let data = `${ selectedEmote } ${ movie . title } (${ movie . year } )${ imdbInfo } started at ${ process . env . STRIMS_URL } ` ;
301+ const imdbInfo = imdbUrl ? ` - ${ imdbUrl } (${ movie . rating } )` : '' ;
302+ const emotes = process . env . STRIMS_EMOTES && process . env . STRIMS_EMOTES . split ( "," )
303+ const selectedEmote = emotes ? emotes [ Math . floor ( Math . random ( ) * emotes . length ) ] : "" ;
304+ const data = `${ selectedEmote } ${ movie . title } (${ movie . year } )${ imdbInfo } started at ${ process . env . STRIMS_URL } ` ;
302305 ws . send ( 'MSG ' + JSON . stringify ( { data} ) ) ;
303306 ws . close ( ) ;
304307}
0 commit comments