@@ -192,7 +192,7 @@ function checkYoutubeStatus(){
192192 }
193193 } ,
194194 error : function ( XMLHttpRequest , textStatus , error ) {
195- if ( XMLHttpRequest . statusText != "OK" ) {
195+ if ( XMLHttpRequest . statusText != "OK" && XMLHttpRequest . status != 404 ) {
196196 wyn . isConnected = false ;
197197 chrome . extension . sendMessage ( { type : "createSnackbar" , message : wyn . strings . connect_failed } ) ;
198198 console . log ( wyn . strings . log_color_prefix + wyn . strings . connect_failed , wyn . strings . log_color_green ) ;
@@ -358,7 +358,7 @@ function checkYoutube(num, refresh, batch) {
358358 wyn . activeCheckings [ num ] = true ;
359359
360360 var channels = JSON . parse ( localStorage . getItem ( "channels" ) ) ;
361- var url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=1 &playlistId=" + channels [ num ] . playlistId + "&key=" + wyn . apiKey ;
361+ var url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=5 &playlistId=" + channels [ num ] . playlistId + "&key=" + wyn . apiKey ;
362362
363363 console . log ( wyn . strings . notification_log_check + channels [ num ] . name ) ;
364364 $ . ajax ( {
@@ -367,6 +367,14 @@ function checkYoutube(num, refresh, batch) {
367367 wyn . activeCheckings [ num ] = false ;
368368 } ,
369369 success : function ( data ) {
370+ data . items . sort ( function ( a , b ) {
371+ var a = new Date ( a . snippet . publishedAt ) ,
372+ b = new Date ( b . snippet . publishedAt ) ;
373+ if ( a > b ) return - 1 ;
374+ if ( a < b ) return 1 ;
375+ return 0 ;
376+ } ) ;
377+
370378 var videoId = data . items [ 0 ] . snippet . resourceId . videoId ,
371379 url = "https://www.googleapis.com/youtube/v3/videos?part=statistics,contentDetails&maxResults=1&id=" + videoId + "&key=" + wyn . apiKey ,
372380 prevVideoId = channels [ num ] . latestVideo . id ;
0 commit comments