1/** 2* 3* @package qtmplayer 4* @subpackage qtmplayer-radiofeed 5* 6*/ 7 8(function($) { 9 "use strict"; 10 function isXML(xml){ 11 try { 12 xmlDoc = $.parseXML(xml); //is valid XML 13 return true; 14 } catch (err) { 15 // was not XML 16 return false; 17 } 18 } 19 20 21 22 $.qtmplayerRadioFeedObj = { 23 body: $("body"), 24 window: $(window), 25 document: $(document), 26 htmlAndbody: $('html,body'), 27 qtFeedData: {}, 28 timeInterval: 15000, 29 /** 30 * ======================================================================================================================================== | 31 * | 32 * | 33 * START SITE FUNCTIONS | 34 * | 35 * | 36 * ======================================================================================================================================== | 37 */ 38 fn: { 39 cachedThumbsArray: [], // when this changes, we fetch a new cover 40 updateMediaData(){ 41 // console.log( 'updateMediaData: ' ); 42 // console.log( $.qtMplayerGlobalSongData ); 43 if ('mediaSession' in navigator) { 44 if($.qtMplayerGlobalSongData.thumbnail && false !== $.qtMplayerGlobalSongData.thumbnail){ 45 // console.log('Yes art'); 46 navigator.mediaSession.metadata = new MediaMetadata({ 47 title: $.qtMplayerGlobalSongData.title, 48 artist: $.qtMplayerGlobalSongData.artist, 49 artwork: [ 50 { src: $.qtMplayerGlobalSongData.thumbnail, type: "image/jpeg" } 51 ] 52 }); 53 } else { 54 // console.log('No art'); 55 navigator.mediaSession.metadata = new MediaMetadata({ 56 title: $.qtMplayerGlobalSongData.title, 57 artist: $.qtMplayerGlobalSongData.artist 58 }); 59 } 60 } 61 }, 62 // ----------------------------------------------- FEED READERS END ------------------------------------ 63 getThumbnail: function(that, termArray, callBack){ 64 65 66 var preclean = termArray.split('<!--'); 67 if(preclean.length > 1){ 68 termArray = preclean[0]; 69 } 70 71 termArray = termArray.split(' - ').join('-').split(' ').join('+'); 72 73 var thumb; // image from itunes 74 var apiUrl = 'https://itunes.apple.com/search?term='+termArray; 75 76 if(termArray == 'Song title unavailable' || termArray == 'No Titles Available'){ 77 thumb = $.qtmplayerRadioFeedObj.qtFeedData.cover; 78 that.cachedThumbsArray[termArray] = thumb; 79 $.qtMplayerGlobalSongData.thumbnail = thumb; 80 callBack(thumb); 81 return; 82 } 83 84 85 if( undefined === that.cachedThumbsArray[termArray] ) { 86 87 if( $.qtmplayerRadioFeedObj.qtFeedData.artwork ){ 88 termArray = termArray.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 89 callBack($.qtmplayerRadioFeedObj.qtFeedData.artwork+'?song='+termArray); 90 } else { 91 92 $.ajax({ 93 type: 'GET', 94 cache: true, 95 url: apiUrl, 96 async: true, 97 dataType: 'jsonp', 98 context: this, 99 success: function(json) { 100 if('object' !== typeof( json )){ 101 json = JSON.parse(json); 102 } 103 if(json.resultCount > 0){ 104 thumb = json.results[0].artworkUrl100.split('100x100bb.jpg').join('1000x1000bb.jpg'); 105 that.cachedThumbsArray[termArray] = thumb; 106 $.qtMplayerGlobalSongData.thumbnail = thumb; 107 108 109 callBack(thumb); 110 return; 111 } 112 } 113 }); 114 } 115 } else { 116 // return cached image 117 $.qtMplayerGlobalSongData.thumbnail = that.cachedThumbsArray[termArray]; 118 callBack( that.cachedThumbsArray[termArray] ); 119 return; 120 } 121 $.qtmplayerRadioFeedObj.fn.updateMediaData(); 122 }, 123 124 125 126 /**==================================================================== 127 * 128 * 129 * Marquee for longer texts 130 * 131 * 132 ====================================================================*/ 133 marqueeInstances: [], 134 marqueeText: function(that) { 135 if('function' !== typeof( $.fn.marquee ) ){ // missing marquee library? quit 136 return; 137 } 138 var marquees = $('body').find('.proradio-marquee'); 139 // Destroy any old instance of the marquee 140 if( that.marqueeInstances.length > 0 ){ 141 for( var mi = 0; mi < that.marqueeInstances.length; mi++ ){ 142 if( 'undefined' !== typeof( that.marqueeInstances[mi] )){ 143 that.marqueeInstances[mi].marquee('destroy'); 144 } 145 } 146 that.marqueeInstances = []; // reset 147 } 148 $.each(marquees, function(i,c){ 149 var item = $(c); 150 if(item.find('.marquee').length === 0){ 151 item.html('<span class="marquee">'+item.html()+'</span>'); 152 } 153 if( item.outerWidth() > item.find('.marquee').outerWidth() ){ // the title is short? quit! 154 return; 155 } 156 that.marqueeInstances[i] = item.marquee({ 157 duration: 20000, 158 gap: 150, 159 delayBeforeStart: 0, 160 direction: 'left', 161 duplicated: true, 162 pauseOnCycle: 0, 163 startVisible: true 164 }); 165 }); 166 }, 167 168 /** 169 * =======================================================
170 * Display listeners when available 171 * @since 2022 06 21 172 * ======================================================= 173 * */ 174 qtApplyListeners: function(listeners, listener_peak){ 175 if($.qtmplayerRadioFeedObj.qtFeedData.listeners || $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 176 if(listeners || listener_peak){ 177 $(".qtmplayer__stats").addClass('show'); 178 if(listeners && $.qtmplayerRadioFeedObj.qtFeedData.listeners){ 179 $('.qtmplayer-listeners span').html(listeners); 180 $('.qtmplayer-listeners').show(); 181 } else { 182 $('.qtmplayer-listeners').hide(); 183 } 184 if(listener_peak && $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 185 $('.qtmplayer-listener_peak span').html(listener_peak); 186 $('.qtmplayer-listener_peak').show(); 187 } else { 188 $('.qtmplayer-listener_peak').hide(); 189 } 190 return true; 191 } 192 } 193 $(".qtmplayer__stats").removeClass('show'); 194 $('.qtmplayer-listeners span').html(''); 195 $('.qtmplayer-listener_peak span').html(''); 196 return; 197 }, 198 199 200 qtApplyTitle: function(result, callBack){ 201 var that = this; 202 if(result && result !== ''){ 203 204 var dmes = '>>>>> qtApplyTitle : '+result; 205 $.qtmplayerRadioFeedObj.fn.log(dmes); 206 207 // result = decodeURIComponent(escape(result)); 208 var feedsplit = result.split(" - "); 209 var artist; 210 var title; 211 if(feedsplit.length > 1){ 212 artist = feedsplit[0], 213 title = feedsplit[1]; 214 } else { 215 feedsplit = result.split("-"); 216 if(feedsplit.length > 1){ 217 artist = feedsplit[0], 218 title = feedsplit[1]; 219 } else { 220 artist = ""; 221 title = result; 222 } 223 } 224 var artistSplit = artist.split('['); 225 if( artistSplit.length > 1 ){ 226 artist = artistSplit[0]; 227 } 228 artistSplit = artist.split(' : '); 229 if( artistSplit.length > 1 ){ 230 artist = artistSplit[1]; 231 } 232 var titleSplit = title.split('['); 233 if( titleSplit.length > 1 ){ 234 title = titleSplit[0]; 235 } 236 title = $.trim(title); 237 artist = $.trim(artist); 238 239 $(".qtmplayer-feed").show(); 240 $('.qtmplayer__title').html(title); 241 $('.qtmplayer__artist').html(artist); 242 243 244 245 246 that.marqueeText( that ); 247 var termArray = artist+'-'+title; 248 249 if( callBack ){ 250 this.getThumbnail(that, termArray, callBack ); 251 } 252 253 254 // Update media data ============================== 255 if (window.screen.width < 670 ) { 256 var uA = navigator.userAgent || navigator.vendor || window.opera; 257 if ( /Googlebot/i.test(uA) || /Bing/i.test(uA) || /Yandex/i.test(uA) || /Apple Bot/i.test(uA) || /DuckDuck Bot/i.test(uA) ){ 258 // Do nothing 259 } else { 260 jQuery(document).prop('title', artist+' - '+title); 261 } 262 } 263 $.qtMplayerGlobalSongData.title = title; 264 $.qtMplayerGlobalSongData.artist = artist; 265 $.qtmplayerRadioFeedObj.fn.updateMediaData(); 266 267 } else { 268 $(".qtmplayer-feed").hide(); 269 } 270 return; 271 }, 272 newFeedReading: function(){ 273 274 275 // debug: fix title not changing after pause 276 277 $.qtmplayerRadioFeedObj.fn.log('newFeedReading = REITERATE - '+$.now()); 278 // console.log( $.qtmplayerRadioFeedObj.qtFeedData ); 279 var o = $.qtmplayerRadioFeedObj, 280 fd = o.qtFeedData, 281 callBack = fd.callBack, 282 fn = o.fn, 283 qtradiofeedHost = (undefined !== fd.host) ? fd.host : '', 284 qtradiofeedPort = (undefined !== fd.port) ? fd.port : '', 285 qtradiofeedProtocol = (undefined !== fd.protocol) ? fd.protocol : 'http', 286 theChannel = (undefined !== fd.channel) ? fd.channel : '', 287 qticecasturl = (undefined !== fd.icecasturl) ? fd.icecasturl : '', 288 qticecastmountpoint = (undefined !== fd.icecastmountpoint) ? fd.icecastmountpoint : '', 289 qticecastchannel = (undefined !== fd.icecastchannel) ? fd.icecastchannel : '', 290 qtradiodotco = (undefined !== fd.radiodotco) ? fd.radiodotco : '', 291 qtairtime = (undefined !== fd.airtime) ? fd.airtime : '', 292 qtradionomy = (undefined !== fd.radionomy) ? fd.radionomy : '', 293 qttextfeed = (undefined !== fd.textfeed) ? fd.textfeed : '', 294 qtUseProxy = (undefined !== fd.useproxy) ? fd.useproxy : '', 295 qtlive365 = (undefined !== fd.live365) ? fd.live365 : '', 296 qtradioking = (undefined !== fd.radioking) ? fd.radioking : '', 297 qtazuracast = (undefined !== fd.azuracast) ? fd.azuracast : '', 298 qtsecuresystems = (undefined !== fd.securesystems) ? fd.securesystems : '', 299 qtradiojar = (undefined !== fd.radiojar) ? fd.radiojar : '', 300 qtradioboss = (undefined !== fd.radioboss) ? fd.radioboss : '', 301 qtmaxcast = (undefined !== fd.maxcast) ? fd.maxcast : '', 302 qtsonicpanel = (undefined !== fd.sonicpanel) ? fd.sonicpanel : '', 303 qtsonicpaneldj = (undefined !== fd.sonicpaneldj) ? fd.sonicpaneldj : '', 304 qtjazler = (undefined !== fd.jazler) ? fd.jazler : '', 305 qteverestcast = (undefined !== fd.everestcast) ? fd.everestcast : '', 306 qtstreamerr = (undefined !== fd.streamerr) ? fd.streamerr : '', 307 qtstreamguys_api = (undefined !== fd.streamguys_api) ? fd.streamguys_api : '', 308 qtstreamguys_uuid = (undefined !== fd.streamguys_uuid) ? fd.streamguys_uuid : '', 309 qtradiocult = (undefined !== fd.radiocult) ? fd.radiocult : '', 310 broadcastradio = (undefined !== fd.broadcastradio) ? fd.broadcastradio : '', 311 radiolize = (undefined !== fd.radiolize) ? fd.radiolize : '', 312 stationplaylist = (undefined !== fd.stationplaylist) ? fd.stationplaylist : '', 313 yesstreaming = (undefined !== fd.yesstreaming) ? fd.yesstreaming : '', 314 qtFeedPlayerTrack = $('#qtFeedPlayerTrack'), 315 qtFeedPlayerAuthor = $('#qtFeedPlayerAuthor'), 316 qtPlayerTrackInfo = $("#qtPlayerTrackInfo"), 317 author, title, result, feedsplit; 318 o = $.qtmplayerRadioFeedObj; 319 var proxyURL = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 320 var timestamp = new Date().getUTCMilliseconds(); 321 var listener_peak = false;
322 var listeners = false; 323 324 325 /** 326 * =================================================================== 327 * 328 * YesStreaming 329 * 330 * =================================================================== 331 */ 332 333 if( fd.servertype == 'type-yesstreaming' && yesstreaming ){ 334 if(qtUseProxy){ 335 yesstreaming = proxyURL+'?qtproxycall='+window.btoa(yesstreaming); //REQUIRED 336 } 337 $.ajax({ 338 type: 'GET', 339 cache: false, 340 url: yesstreaming, 341 async: true, 342 jsonp: "callback", 343 success: function(data) { 344 345 if (typeof data !== 'object') { 346 try { 347 data = JSON.parse(data); 348 } catch (e) { 349 console.log("Invalid JSON from Radiolize"); 350 return; 351 } 352 } 353 // console.log( data.results[0] ); 354 var results = data.results[0]; 355 var trackTitlte = data.results[0].metadata; 356 if( 'undefined' !== typeof(data.results[0].img_url) && data.results[0].img_url && 'function' === typeof(callBack) ){ 357 console.log( data.results[0].img_url ); 358 callBack( data.results[0].img_url ); 359 callBack = false; 360 } 361 if( trackTitlte ){ 362 fn.qtApplyTitle(trackTitlte, callBack); 363 } else { 364 console.log(yesstreaming); 365 console.log('Yesstreaming title not available'); 366 fn.qtApplyTitle('Title not available', callBack); 367 } 368 }, 369 error: function(e){ 370 console.log(yesstreaming); 371 console.log('Yesstreaming feed not loaded - error ahead:'); 372 console.log(e); 373 } 374 }); 375 return; 376 } 377 378 379 /** 380 * =================================================================== 381 * 382 * stationplaylist 383 * 384 * =================================================================== 385 */ 386 if( fd.servertype == 'type-stationplaylist' && stationplaylist ){ 387 if(qtUseProxy){ 388 stationplaylist = proxyURL+'?qtproxycall='+window.btoa(stationplaylist); //REQUIRED 389 } 390 391 392 $.ajax({ 393 type: "GET", 394 url:stationplaylist, 395 dataType: "xml", 396 async: true, 397 cache: false, 398 success: function(xml) { 399 fn.log(xml); 400 $(xml).find('Current').each(function(){ 401 fn.log($(this)); 402 var song = $(this); 403 var title = song.find('Title').html(); 404 var artist = song.find('Artist').html(); 405 var artwork = song.find('Image'); 406 407 if(artwork){ 408 artwork = artwork.html(); 409 if(artwork != ''){ 410 callBack( artwork ); 411 callBack = false; 412 } 413 } 414 fn.qtApplyTitle(title + ' - ' + artist , callBack); 415 }); 416 }, 417 error: function(e){ 418 console.log('stationplaylist source unreachable - please check your channel settings'); 419 console.log(e); 420 } 421 }); 422 return; 423 } 424 425 426 /** 427 * =================================================================== 428 * 429 * Radiolize 430 * 431 * =================================================================== 432 */ 433 if( fd.servertype == 'type-radiolize' && radiolize ){ 434 if(qtUseProxy){ 435 radiolize = proxyURL+'?qtproxycall='+window.btoa(radiolize); //REQUIRED 436 } 437 $.ajax({ 438 type: 'GET', 439 url: radiolize, 440 cache: false, 441 async: true, 442 dataType: 'json', 443 success: function(data) { 444 if (typeof data !== 'object') { 445 try { 446 data = JSON.parse(data); 447 } catch (e) { 448 console.log("Invalid JSON from Radiolize"); 449 return; 450 } 451 } 452 453 if (!data.now_playing || !data.now_playing.song || !data.now_playing.song.text) { 454 fn.log("Missing data for Radiolize song title"); 455 return; 456 } 457 458 var title = data.now_playing.song.text; 459 460 if (typeof data.now_playing.song.art !== 'undefined' && data.now_playing.song.art && typeof callBack === 'function') { 461 var img = data.now_playing.song.art; 462 $.qtMplayerGlobalSongData.thumbnail = img; 463 callBack(img); 464 callBack = false;
465 } 466 467 fn.qtApplyTitle(title, callBack); 468 }, 469 error: function(e) { 470 console.log('Broadcast.Radio feed not loaded - error ahead:'); 471 console.log(e); 472 } 473 }); 474 475 return; 476 } 477 478 /** 479 * =================================================================== 480 * 481 * Broadcast.Radio 482 * 483 * =================================================================== 484 */ 485 if( fd.servertype == 'type-broadcastradio' && broadcastradio ){ 486 if(qtUseProxy){ 487 broadcastradio = proxyURL+'?qtproxycall='+window.btoa(broadcastradio); //REQUIRED 488 } 489 $.ajax({ 490 type: 'GET', 491 cache: false, 492 url: broadcastradio, 493 async: true, 494 jsonp: true, 495 success: function(data) { 496 if('object' !== typeof( data )){ 497 data = JSON.parse(data); 498 } 499 if(!data.success){ 500 fn.log("Missing data for Broadcast.Radio song title"); 501 return; 502 } 503 title = data.body.now_playing.title; 504 if(data.body.now_playing.artist ){ 505 title = title +' - ' + data.body.now_playing.artist; 506 } 507 if( 'undefined' !== typeof(data.body.now_playing.artworkUrl) && data.body.now_playing.artworkUrl && 'function' === typeof(callBack) ){ 508 if( 'undefined' !== typeof( data.body.now_playing.artworkUrl ) ){ 509 if( data.body.now_playing.artworkUrl ){ 510 var img = data.body.now_playing.artworkUrl; 511 $.qtMplayerGlobalSongData.thumbnail = img; 512 callBack( img ); 513 callBack = false; 514 } 515 } 516 } 517 fn.qtApplyTitle(title, callBack); 518 }, 519 error: function(e){ 520 console.log('Broadcast.Radio feed not loaded - error ahead:'); 521 console.log(e); 522 } 523 }); 524 return; 525 } 526 527 528 529 /** 530 * =================================================================== 531 * 532 * RadioCult 533 * 534 * =================================================================== 535 */ 536 if( fd.servertype == 'type-radiocult' && qtradiocult ){ 537 // if(qtUseProxy){ 538 qtradiocult = proxyURL+'?qtproxycall='+window.btoa(qtradiocult); //REQUIRED 539 // } 540 $.ajax({ 541 type: 'GET', 542 cache: false, 543 url: qtradiocult, 544 async: true, 545 jsonp: true, 546 success: function(data) { 547 if('object' !== typeof( data )){ 548 data = JSON.parse(data); 549 } 550 if(!data.result.metadata){ 551 fn.log("Missing data for Radiocult song title"); 552 return; 553 } 554 title = data.result.metadata.title; 555 556 if(data.result.metadata.artist ){ 557 title = title +' - ' + data.result.metadata.artist; 558 } 559 if( 'undefined' !== typeof(data.result.metadata.artwork) && data.result.metadata.artwork && 'function' === typeof(callBack) ){ 560 if( 'undefined' !== typeof(data.result.metadata.artwork.original ) ){ 561 if( data.result.metadata.artwork.original ){ 562 var img = data.result.metadata.artwork.original; 563 $.qtMplayerGlobalSongData.thumbnail = img; 564 callBack( img ); 565 callBack = false; 566 } 567 } 568 } 569 fn.qtApplyTitle(title, callBack); 570 }, 571 error: function(e){ 572 console.log('Streamguys feed not loaded - error ahead:'); 573 console.log(e); 574 } 575 }); 576 return; 577 } 578 /** 579 * =================================================================== 580 * 581 * SteamGuys 582 * 583 * =================================================================== 584 */ 585 if( fd.servertype == 'type-streamguys' && qtstreamguys_api && qtstreamguys_uuid ){ 586 var apiurl = 'https://jetapi.streamguys.com/'+qtstreamguys_api+'/scraper/'+qtstreamguys_uuid+'/metadata/raw/'; 587 588 if(qtUseProxy){ 589 apiurl = proxyURL+'?qtproxycall='+window.btoa(apiurl); 590 } 591 $.ajax({ 592 type: 'GET', 593 cache: false, 594 url: apiurl, 595 async: true, 596 jsonp: true, 597 success: function(text) { 598 if(text == '{"error":"API Key not found."}'){ 599 return; 600 } 601 // Regular expression to match the StreamTitle value 602 var match = text.match(/StreamTitle='(.*?)'/); 603 var title = match ? match[1] : ""; 604 fn.qtApplyTitle(title, callBack); 605 }, 606 error: function(e){ 607 console.log('Streamguys feed not loaded - error ahead:'); 608 console.log(e); 609 } 610 }); 611 return; 612 } 613 614 /** 615 * =================================================================== 616 * 617 * EverestCast 618 * 619 * =================================================================== 620 */ 621 if( fd.servertype == 'type-everestcast' ){ 622 fn.log(qteverestcast); 623 if(qtUseProxy){ 624 qteverestcast = proxyURL+'?qtproxycall='+window.btoa(qteverestcast); 625 } 626 $.ajax({ 627 type: 'GET', 628 cache: false, 629 url: qteverestcast, 630 async: true, 631 jsonp: true, 632 success: function(data) { 633 if('object' !== typeof( data )){ 634 data = JSON.parse(data); 635 } 636 637 if(!data.current_track.title){ 638 fn.log("Missing data for Everestcast song title"); 639 return; 640 } 641 title = data.current_track.title; 642 if(data.current_track.image && 'function' === typeof(callBack)){ 643 644 $.qtMplayerGlobalSongData.thumbnail = data.current_track.image; 645 callBack( data.current_track.image ); 646 callBack = false;
647 } 648 fn.qtApplyTitle(title, callBack); 649 }, 650 error: function(e){ 651 console.log('MediaCP feed not loaded - error ahead:'); 652 console.log(e); 653 } 654 }); 655 return; 656 } 657 658 659 /** 660 * =================================================================== 661 * 662 * MediaCP 663 * 664 * =================================================================== 665 */ 666 if( fd.servertype == 'type-mediacp' ){ 667 fn.log(qtmediacp); 668 if(qtUseProxy){ 669 qtmediacp = proxyURL+'?qtproxycall='+window.btoa(qtmediacp); 670 } 671 $.ajax({ 672 type: 'GET', 673 cache: false, 674 url: qtmediacp, 675 async: true, 676 jsonp: true, 677 success: function(data) { 678 if('object' !== typeof( data )){ 679 data = JSON.parse(data); 680 } 681 fn.log(data); 682 title = data.nowplaying; 683 if(data.coverart && 'function' === typeof(callBack)){ 684 $.qtMplayerGlobalSongData.thumbnail = data.coverart; 685 callBack( data.coverart ); 686 687 callBack = false; 688 } 689 fn.qtApplyTitle(title, callBack); 690 }, 691 error: function(e){ 692 console.log('MediaCP feed not loaded - error ahead:'); 693 console.log(e); 694 } 695 }); 696 return; 697 } 698 699 700 701 /** 702 * =================================================================== 703 * 704 * Streamerr 705 * 706 * =================================================================== 707 */ 708 if( fd.servertype == 'type-streamerr' ){ 709 fn.log(qtstreamerr); 710 if(qtUseProxy){ 711 qtstreamerr = proxyURL+'?qtproxycall='+window.btoa(qtstreamerr); 712 } 713 $.ajax({ 714 type: 'GET', 715 cache: false, 716 url: qtstreamerr, 717 async: true, 718 jsonp: true, 719 success: function(data) { 720 721 if('object' !== typeof( data )){ 722 data = JSON.parse(data); 723 } 724 725 fn.log(data); 726 title = data.nowplaying; 727 if(data.coverart && 'function' === typeof(callBack)){ 728 $.qtMplayerGlobalSongData.thumbnail = data.coverart; 729 callBack( data.coverart ); 730 731 callBack = false; 732 } 733 fn.qtApplyTitle(title, callBack); 734 }, 735 error: function(e){ 736 console.log('Streamerr not working - error ahead:'); 737 console.log(e); 738 } 739 }); 740 return; 741 } 742 743 744 745 /** 746 * =================================================================== 747 * 748 * sonicpanel 749 * 750 * =================================================================== 751 */ 752 if( fd.servertype == 'type-sonicpanel' ){ 753 if( qtsonicpanel !== ''){ 754 if ( qtsonicpanel.indexOf("?") > -1 ) { 755 qtsonicpanel = qtsonicpanel + '&rand='+timestamp; 756 } else { 757 qtsonicpanel = qtsonicpanel + '?rand='+timestamp; 758 } 759 if(qtUseProxy){ 760 qtsonicpanel = proxyURL+'?qtproxycall='+window.btoa(qtsonicpanel); 761 } 762 $.ajax({ 763 type: 'GET', 764 cache: false, 765 url: qtsonicpanel, 766 async: true, 767 success: function(data) { 768 if('object' !== typeof( data )){ 769 data = JSON.parse(data); 770 } 771 var titles = 'Now live - Streaming'; 772 if(data.title){ 773 titles = data.title; 774 if(data.artist){ 775 titles = data.artist+' - '+data.title; 776 } 777 } 778 if(data.art && 'function' === typeof(callBack)){ 779 if(data.title){ 780 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 781 } 782 $.qtMplayerGlobalSongData.thumbnail = data.art; 783 callBack(data.art); 784 785 callBack = false; 786 } 787 if(data.thumb && 'function' === typeof(callBack)){ 788 $.qtMplayerGlobalSongData.thumbnail = data.thumb+'#.jpg'; 789 callBack(data.thumb+'#.jpg'); 790 791 callBack = false; 792 } 793 if( '1' == qtsonicpaneldj && data.djusername !== 'No DJ'){ 794 titles = data.title.split(' - ').join(' / ')+' - '+data.djusername; 795 } 796 if(data.listn){ 797 listeners = data.listn; 798 } 799 if(data.peaklistn){ 800 listener_peak = data.peaklistn; 801 } 802 fn.qtApplyListeners(listeners, listener_peak); 803 fn.qtApplyTitle(titles, callBack); 804 }, 805 error: function(e){ 806 console.log(e); 807 } 808 }); 809 } 810 } 811 812 813 /** 814 * =================================================================== 815 * 816 * qtjazler 817 * 818 * =================================================================== 819 */ 820 if( fd.servertype == 'type-jazler' ){ 821 var qtjazlerFolder = qtjazler.split('NowOnAir.xml').join('AlbumsCache/'); 822 if(qtUseProxy){ 823 qtjazler = proxyURL+'?qtproxycall='+window.btoa(qtjazler); 824 } 825 fn.log('=============================================================='); 826 fn.log(qtjazler); 827 $.ajax({ 828 type: "GET", 829 url:qtjazler, 830 dataType: "xml", 831 async: true, 832 cache: false, 833 success: function(xml) { 834 fn.log(xml); 835 $(xml).find('Event').each(function(){ 836 fn.log($(this)); 837 var CacheImageFile = $(this).find('CacheImageFile').html(); 838 $(this).find('Announcement').each(function(){ 839 var title = $(this).attr('Display'); 840 fn.log(title); 841 if(CacheImageFile && 'function' === typeof(callBack) ){ 842 fn.log(qtjazlerFolder + CacheImageFile); 843 844 $.qtMplayerGlobalSongData.thumbnail = qtjazlerFolder + CacheImageFile; 845 callBack( qtjazlerFolder + CacheImageFile ); 846 callBack = false;
847 } 848 fn.qtApplyTitle(title , callBack); 849 }); 850 851 }); 852 }, 853 error: function(e){ 854 console.log('Jazler source unreachable - please check your channel settings'); 855 console.log(e); 856 } 857 }); 858 return; 859 } 860 861 862 /** 863 * =================================================================== 864 * 865 * laut.FM 866 * 867 * =================================================================== 868 */ 869 if( fd.servertype == 'type-lautfm' ){ 870 fn.log('Server type: LAUT.FM'); 871 fn.log('Stream URL: '+fd.file); 872 if( fd.file.indexOf('/stream.laut.fm/') != -1 ){ 873 fn.log('Laut.FM reading titles'); 874 var radioname = fd.file.split('https').join('http').split('http://stream.laut.fm/').join(''); 875 var radiourl = 'https://api.laut.fm/station/'+radioname+'/current_song'; 876 // if ( radiourl.indexOf("?") > -1 ) { 877 // radiourl = radiourl + '&rand='+timestamp; 878 // } else { 879 // radiourl = radiourl + '?rand='+timestamp; 880 // } 881 if(qtUseProxy){ 882 radiourl = proxyURL+'/?qtproxycall='+window.btoa(radiourl); 883 } 884 // console.log(radiourl); 885 $.ajax({ 886 type: 'GET', 887 url: radiourl, 888 async: true, 889 cache: false, 890 success: function(data) { 891 fn.log('Laut.FM Success'); 892 if('object' !== typeof( data )){ 893 data = JSON.parse(data); 894 } 895 var titles = 'Now live - Streaming'; 896 897 if(data.type){ 898 if(data.type !== 'jingle'){ 899 if(data.title){ 900 titles = data.title; 901 if(data.artist){ 902 if(data.artist.name){ 903 titles = data.artist.name +' - '+ titles; 904 } 905 } 906 } 907 fn.qtApplyTitle( titles, callBack ); 908 } 909 } 910 911 }, 912 error: function(e){ 913 fn.log(e); 914 console.log(e); 915 fn.qtApplyTitle('Laut FM API error - Titles not available'); 916 } 917 }); 918 } 919 return; 920 } // IF servertype end 921 922 923 924 if( fd.servertype === 'type-icy' ){ 925 926 927 fn.log('type-icy'); 928 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 929 $.ajax({ 930 type: 'GET', 931 url: proxyURL, 932 jsonpCallback: 'parseMusic', 933 async: true, 934 cache: false, 935 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 936 success: function(data) { 937 if(data === 'Song title unavailable' || data === 'Cannot open the stream' ){ 938 fn.log('ERROR OPENING THE STREAM OR GETTING THE TITLES: '+data); 939 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 940 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 941 return; 942 } 943 fn.qtApplyTitle( data, callBack ); 944 fn.log(data); 945 }, 946 error: function(e){ 947 console.log('Error'); 948 fn.log(e); 949 console.log(e); 950 } 951 }); 952 } 953 954 955 956 /** 957 * =================================================================== 958 * 959 * Auto or HTTPS shoutcast 960 * 961 * =================================================================== 962 */ 963 if( fd.servertype == 'type-auto' ){ 964 if(fd.file.indexOf('/proxy/') != -1 && fd.file.indexOf('https') != -1 && fd.file.indexOf('?mp=/') != -1){ 965 fn.log('type-auto TYPE 1 - GET MOUNTPOINT'); 966 967 qtradiofeedHost = fd.file.split('?mp=/'); 968 qtradiofeedHost = qtradiofeedHost[0] + '?mp=/stats' + '&rand='+timestamp; 969 if(qtUseProxy){ 970 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 971 } 972 $.ajax({ 973 type: 'GET', 974 url: qtradiofeedHost, 975 async: true, 976 cache: false, 977 dataType: "xml", 978 success: function(data) { 979 980 981 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 982 983 // Listeners ====================================== 984 if($(data).find('CURRENTLISTENERS')){ 985 listeners = $(data).find('CURRENTLISTENERS').html(); 986 } 987 if($(data).find('PEAKLISTENERS')){ 988 listener_peak = $(data).find('PEAKLISTENERS').html(); 989 } 990 fn.qtApplyListeners(listeners, listener_peak); 991 992 }, 993 error: function(e){ 994 fn.log(e); 995 console.log(e); 996 } 997 }); 998 } else if(fd.file.indexOf('/proxy/') == -1 && fd.file.indexOf('https') != -1 && fd.file.endsWith('/stream') && fd.file.indexOf('/mp3') == -1 ){ 999 1000 fn.log('type-auto TYPE 2 - XML:'+fd.file.endsWith('/stream')+'? ----> '+fd.file); 1001 1002 1003 1004 // OLD system 1005 // qtradiofeedHost = fd.file.split('/stream'); 1006 // qtradiofeedHost = qtradiofeedHost[0] + '/stats'; // no random here
1007 // NEW - replace only the last occurrence of /stream 1008 qtradiofeedHost = fd.file.replace(/\/stream$/, '/stats','$1');// fd.file.split('/stream').join('/stats'); 1009 1010 1011 fn.log('Stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 1012 1013 if(qtUseProxy){ 1014 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 1015 } 1016 fn.log('Proxy stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 1017 $.ajax({ 1018 type: 'GET', 1019 url: qtradiofeedHost, 1020 async: true, 1021 //cache: false, 1022 //dataType: "xml", 1023 success: function(data) { 1024 1025 1026 if(data === 'Song title unavailable' ){ 1027 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title , false); 1028 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 1029 return; 1030 } 1031 1032 1033 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 1034 1035 1036 // Listeners ====================================== 1037 if($(data).find('CURRENTLISTENERS')){ 1038 listeners = $(data).find('CURRENTLISTENERS').html(); 1039 } 1040 if($(data).find('PEAKLISTENERS')){ 1041 listener_peak = $(data).find('PEAKLISTENERS').html(); 1042 } 1043 fn.qtApplyListeners(listeners, listener_peak); 1044 1045 }, 1046 error: function(e){ 1047 fn.log(e); 1048 console.log(e); 1049 } 1050 }); 1051 1052 } else { 1053 fn.log('type-auto TYPE 3 ICY METADATA'); 1054 1055 1056 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 1057 $.ajax({ 1058 type: 'GET', 1059 url: proxyURL, 1060 jsonpCallback: 'parseMusic', 1061 async: true, 1062 cache: false, 1063 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 1064 success: function(data) { 1065 if(data === 'Song title unavailable' ){ 1066 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 1067 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 1068 return; 1069 } 1070 fn.qtApplyTitle( data, callBack ); 1071 fn.log(data); 1072 } 1073 }); 1074 1075 } 1076 return; 1077 } 1078 1079 /** 1080 * Maxcast 1081 */ 1082 /** 1083 * =================================================================== 1084 * 1085 * Maxcast 1086 * 1087 * =================================================================== 1088 */ 1089 // Demo feeds: 1090 //https://s05.maxcast.com.br/api/status/brasitaliawebradio/current.json 1091 //https://s16.maxcast.com.br/api/status/bocadoacreatualjt/current.json 1092 if( fd.servertype == 'type-maxcast' ){ 1093 fn.log('Maxcast '+ qtmaxcast); 1094 qtmaxcast = qtmaxcast + '?rand='+timestamp; 1095 if(qtUseProxy){ 1096 qtmaxcast = proxyURL+'?qtproxycall='+window.btoa(qtmaxcast); // working without proxy. Leave here just in case 1097 } 1098 $.ajax({ 1099 type: 'GET', 1100 cache: false, 1101 url: qtmaxcast, 1102 async: true, 1103 jsonpCallback: "parseMusic", 1104 jsonp: false, 1105 data: songdata, 1106 success: function(data) { 1107 if('object' !== typeof(data)){ 1108 data = JSON.parse(data); 1109 } 1110 if(data.playing){ 1111 title = data.playing.current; 1112 } 1113 if(data.song_data && 'function' === typeof(callBack)){ 1114 1115 $.qtMplayerGlobalSongData.thumbnail = data.song_data.cover; 1116 callBack( data.song_data.cover ); 1117 callBack = false; 1118 } 1119 fn.qtApplyTitle(title, callBack); 1120 }, 1121 error: function(e){ 1122 console.log(e); 1123 } 1124 }); 1125 return; 1126 } 1127 1128 if(qtradioboss === '' && qtsecuresystems === '' && qtradiojar === '' && qtradioking === '' && qtazuracast === '' && qttextfeed === '' && qtradionomy === '' && qtlive365 === '' && qtairtime === '' && (qtradiofeedHost === '' || qtradiofeedPort === '' || typeof(qtradiofeedHost) === 'undefined') && qticecasturl === '' && qtradiodotco === '') { 1129 fn.qtApplyTitle(); 1130 return; 1131 } else { 1132 1133 1134 1135 1136 1137 /** 1138 * =================================================================== 1139 * 1140 * Radioboss 1141 * 1142 * =================================================================== 1143 */ 1144 if( qtradioboss !== ''){ 1145 qtradioboss = qtradioboss;// + '?rand='+timestamp; 1146 fn.log(qtradioboss); 1147 1148 if(qtUseProxy){ 1149 qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 1150 } 1151 1152 // qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 1153 $.ajax({ 1154 type: 'GET', 1155 cache: false, 1156 url: qtradioboss, 1157 async: true, 1158 // contentType: "application/json", 1159 // jsonp: true, 1160 success: function(data) { 1161 if('object' !== typeof( data )){ 1162 data = JSON.parse(data); 1163 } 1164 title = data['nowplaying']; 1165 fn.qtApplyTitle(title, callBack); 1166 }, 1167 error: function(e){ 1168 console.log(e); 1169 } 1170 }); 1171 return; 1172 } 1173 1174 1175 1176 1177 1178 /** 1179 * =================================================================== 1180 * 1181 * Radiojar 1182 * 1183 * =================================================================== 1184 */ 1185 if( qtradiojar !== ''){ 1186 if ( qtradiojar.indexOf("?") > -1 ) { 1187 qtradiojar = qtradiojar + '&rand='+timestamp; 1188 } else { 1189 qtradiojar = qtradiojar + '?rand='+timestamp; 1190 } 1191 if(qtUseProxy){ 1192 qtradiojar = proxyURL+'?qtproxycall='+window.btoa(qtradiojar); 1193 } 1194 $.ajax({ 1195 type: 'GET', 1196 cache: false, 1197 url: qtradiojar, 1198 async: true, 1199 success: function(data) { 1200 if('object' !== typeof( data )){ 1201 data = JSON.parse(data); 1202 } 1203 var titles = 'Now live - Streaming'; 1204 if(data.title){ 1205 titles = data.title; 1206 if(data.artist){ 1207 titles = data.artist+' - '+data.title; 1208 } 1209 } 1210 if(data.art && 'function' === typeof(callBack)){ 1211 if(data.title){ 1212 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 1213 } 1214 1215 $.qtMplayerGlobalSongData.thumbnail = data.art; 1216 callBack(data.art); 1217 callBack = false;
1218 } 1219 if(data.thumb && 'function' === typeof(callBack)){ 1220 1221 $.qtMplayerGlobalSongData.thumbnail = data.thumb+'#.jpg'; 1222 callBack(data.thumb+'#.jpg'); 1223 callBack = false; 1224 } 1225 fn.qtApplyTitle(titles, callBack); 1226 }, 1227 error: function(e){ 1228 console.log(e); 1229 } 1230 }); 1231 } 1232 1233 1234 1235 1236 /** 1237 * =================================================================== 1238 * 1239 * SecureSystems 1240 * 1241 * =================================================================== 1242 */ 1243 if( qtsecuresystems !== ''){ 1244 qtsecuresystems =qtsecuresystems; 1245 if(qtUseProxy){ 1246 qtsecuresystems = proxyURL+'?qtproxycall='+window.btoa(qtsecuresystems); 1247 } 1248 $.ajax({ 1249 type: 'GET', 1250 cache: false, 1251 url: qtsecuresystems, 1252 async: true, 1253 dataType: "xml", 1254 success: function(data) { 1255 if( $(data).find('cover').length > 0 ){ 1256 if($(data).find('cover').html() !== '' && 'function' === typeof(callBack)){ 1257 1258 $.qtMplayerGlobalSongData.thumbnail = $(data).find('cover').html(); 1259 callBack($(data).find('cover').html()); 1260 callBack = false; 1261 } 1262 } 1263 var title = $(data).find('title').html(); 1264 if( 'undefined' == typeof(title) || 'undefined' == title ){ 1265 title = $(data).find('name').html(); 1266 } 1267 fn.qtApplyTitle( $(data).find('artist').html()+ ' - ' +title , callBack); 1268 }, 1269 error: function(e){ 1270 console.log(e); 1271 } 1272 }); 1273 return; 1274 } 1275 1276 1277 1278 1279 1280 /** 1281 * =================================================================== 1282 * 1283 * qtlive365 1284 * 1285 * =================================================================== 1286 */ 1287 if( qtlive365 !== ''){ 1288 qtlive365 = 'https://api.live365.com/station/'+qtlive365; 1289 if(qtUseProxy){ 1290 qtlive365 = proxyURL+'?qtproxycall='+window.btoa(qtlive365); 1291 } 1292 1293 $.ajax({ 1294 type: 'GET', 1295 cache: false, 1296 url: qtlive365, 1297 async: true, 1298 jsonpCallback: "parseMusic", 1299 jsonp: false, 1300 success: function(data) { 1301 // console.log(data); 1302 jsondata = data; 1303 // console.log(json); 1304 if('object' !== typeof( data )){ 1305 data = JSON.parse(data); 1306 } 1307 if( data['current-track'].art ){ 1308 var art = data['current-track'].art; 1309 if( art != ''){ 1310 1311 // console.log(art); 1312 $.qtMplayerGlobalSongData.thumbnail = art; 1313 callBack(art); 1314 callBack = false; 1315 } 1316 } 1317 fn.qtApplyTitle(data['current-track'].artist+' - '+data['current-track'].title, callBack); 1318 }, 1319 error: function(e){ 1320 console.log(e); 1321 } 1322 }); 1323 } 1324 1325 /** 1326 * =================================================================== 1327 * 1328 * Text 1329 * 1330 * =================================================================== 1331 */ 1332 else if(qttextfeed !== ''){ 1333 var tfeedurl,jsondata, title, proxyURL, mydata; 1334 if(qtUseProxy){ 1335 tfeedurl = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 1336 mydata = { 1337 "qtproxycall": window.btoa(qttextfeed), 1338 }; 1339 } else { 1340 tfeedurl = qttextfeed; 1341 } 1342 $.ajax({ 1343 type: 'GET', 1344 cache: false, 1345 url: tfeedurl, 1346 async: true, 1347 data: mydata, 1348 dataType: "html", 1349 success: function(data) { 1350 fn.qtApplyTitle( data, callBack ); 1351 }, 1352 error: function(e){ 1353 console.log(e); 1354 } 1355 }); 1356 return; 1357 } 1358 /** 1359 * =================================================================== 1360 * 1361 * Radionomy 1362 * 1363 * =================================================================== 1364 */ 1365 else if(qtradionomy !== '' ) { 1366 $.ajax({ 1367 type: 'GET', 1368 url: qtradionomy, 1369 async: true, 1370 cache: false, 1371 dataType: "xml", 1372 success: function(data) { 1373 fn.qtApplyTitle( $(data).find('artists').html()+ ' - ' + $(data).find('title').html() ); 1374 }, 1375 error: function(e){ 1376 console.log(e); 1377 } 1378 }); 1379 } 1380 1381 /** 1382 * =================================================================== 1383 * 1384 * AirTime 1385 * 1386 * =================================================================== 1387 */ 1388 else if(qtairtime !== '' && qtairtime !== 'undefined' && qtairtime !== undefined && typeof(qtairtime) !== 'undefined'){ 1389 var jsondata, title; 1390 $.ajax({ 1391 type: 'GET', 1392 cache: false, 1393 url: qtairtime,//proxyURL, 1394 async: true, 1395 data: { 1396 "qtproxycall": window.btoa(qtairtime), 1397 }, 1398 jsonpCallback: "parseMusic", 1399 jsonp: true,//jsonp: true, 1400 // contentType: "application/json", 1401 success: function(data) { 1402 // console.log(data); 1403 if(typeof(data) !== 'object'){ 1404 data = JSON.parse(data); 1405 } 1406 title = data.tracks.current.name; 1407 fn.qtApplyTitle(title); 1408 }, 1409 error: function(e) { 1410 } 1411 }); 1412 } 1413 1414 /** 1415 * =================================================================== 1416 * 1417 * Icecast 1418 * 1419 * =================================================================== 1420 */ 1421 else if(qticecasturl !== '' && typeof(qticecasturl) !== 'undefined') { 1422 var feedurl = qticecasturl; 1423 var source; 1424 var title; 1425 var songdata; 1426 var listeners = false;
1427 var listener_peak = false; 1428 if(qtUseProxy){ 1429 feedurl = proxyURL; 1430 songdata = { 1431 "qtproxycall": window.btoa(qticecasturl), 1432 }; 1433 } 1434 // beta 1435 fn.log('Radio feed - Icecast '+ qticecasturl); 1436 // generally ok, not working for LN Soulr Icecast 1437 // console.log( proxyURL+'?qtproxycall='+window.btoa(qticecasturl) ); 1438 $.ajax({ 1439 type: 'GET', 1440 cache: false, 1441 url: feedurl, 1442 async: true, 1443 jsonpCallback: "parseMusic", 1444 jsonp: false,//jsonp: true, 1445 // dataType: 'jsonp', // not working with some radios 1446 data: songdata, 1447 // contentType: "application/json", 1448 success: function(json) { 1449 fn.log('Ajax response'); 1450 fn.log( json ); 1451 1452 // console.log(json); 1453 if('object' !== typeof( json )){ 1454 json = JSON.parse(json); 1455 } 1456 if('undefined' === typeof(json.icestats)){ 1457 // This is Icecast HK 1458 1459 if(qticecastmountpoint){ 1460 source = json[qticecastmountpoint]; 1461 } else { 1462 1463 $.each(json, function(index, element) { 1464 source = element; 1465 if(index == 0){ 1466 source = element; 1467 } 1468 }); 1469 // console.log(source); 1470 } 1471 } else { 1472 source = json.icestats.source; 1473 } 1474 1475 if('undefined' === typeof(source)){ 1476 return; 1477 } 1478 if(qticecastmountpoint){ 1479 source = source[qticecastmountpoint]; 1480 } 1481 if(qticecastchannel){ 1482 // console.log("set source to 0"); 1483 source = source[qticecastchannel]; 1484 } 1485 // since PR.3.2.3 1486 // If there is no channel and there is no title, channel must be 0 1487 if(!qticecastchannel && 'undefined' === typeof(source.title)){ 1488 source = source[0]; 1489 } 1490 title = source.title; 1491 if( source.artist ){ 1492 title = title + ' - ' + source.artist; 1493 } 1494 fn.qtApplyTitle(title, callBack); 1495 // Listeners ====================================== 1496 if(source.listeners){ 1497 listeners = source.listeners; 1498 } 1499 if(source.listener_peak){ 1500 listener_peak = source.listener_peak; 1501 } 1502 fn.qtApplyListeners(listeners, listener_peak); 1503 1504 },error: function(e) { 1505 console.log(e); 1506 fn.log('Ajax response'); 1507 fn.log( e ); 1508 } 1509 }); 1510 } 1511 /** 1512 * =================================================================== 1513 * 1514 * ShoutCast 1515 * 1516 * =================================================================== 1517 */ 1518 else if (qtradiofeedHost !== '' && qtradiofeedPort !== '' && typeof(qtradiofeedHost) !== 'undefined'){ 1519 // to tide up 1520 var feedData = { 1521 shoutcast_host: qtradiofeedHost, 1522 shoutcast_port: qtradiofeedPort, 1523 shoutcast_protocol: qtradiofeedProtocol, 1524 shoutcast_channel: theChannel 1525 }; 1526 var channel = feedData.shoutcast_channel || 1; 1527 var protocol = 'http'; 1528 if(feedData.shoutcast_port === '443' || feedData.shoutcast_protocol === 'https' ){ 1529 protocol = 'https'; 1530 } 1531 var shoutcastUrl = protocol+'://'+feedData.shoutcast_host+':'+feedData.shoutcast_port+'/stats?sid='+channel+'&json=1'; 1532 var feedurl = shoutcastUrl; 1533 1534 if(qtUseProxy){ 1535 feedurl = proxyURL; 1536 songdata = { 1537 "qtproxycall": window.btoa(shoutcastUrl), 1538 }; 1539 } 1540 1541 /** 1542 * @since PR.3.4.6 2021 02 27 added fallback 1543 */ 1544 try{ 1545 1546 $.ajax({ 1547 type: 'GET', 1548 cache: false, 1549 url: feedurl, 1550 async: true, 1551 data: songdata, 1552 dataType: $.qtmplayerRadioFeedObj.qtFeedData.dataType, 1553 contentType: "application/json", 1554 success: function(json) { 1555 if('object' !== typeof( json )){ 1556 json = JSON.parse(json); 1557 } 1558 fn.qtApplyTitle( json.songtitle, callBack); 1559 // Listeners ====================================== 1560 if(json.currentlisteners){ 1561 listeners = json.currentlisteners; 1562 } 1563 if(json.peaklisteners){ 1564 listener_peak = json.peaklisteners; 1565 } 1566 fn.qtApplyListeners(listeners, listener_peak); 1567 },error: function(e) { 1568 if($.qtmplayerRadioFeedObj.qtFeedData.dataType !== 'jsonp'){ 1569 $.qtmplayerRadioFeedObj.qtFeedData.dataType = 'jsonp'; 1570 $.qtmplayerRadioFeedObj.fn.newFeedReading(); 1571 } 1572 } 1573 }); 1574 } catch(e){ 1575 dataType = 'jsonp'; 1576 console.log(e); 1577 } 1578 1579 return; 1580 } 1581 /** 1582 * =================================================================== 1583 * 1584 * Radio.co 1585 * 1586 * =================================================================== 1587 */ 1588 else if (qtradiodotco !== '' && typeof(qtradiodotco) !== 'undefined'){ 1589 var rUrl = 'https://public.radio.co/stations/'+qtradiodotco+'/status' 1590 $.ajax({ 1591 type: 'GET', 1592 cache: false, 1593 url: rUrl, 1594 async: true, 1595 contentType: "application/json", 1596 success: function(data) { 1597 if( data['current_track'] ){ 1598 title = data['current_track']['title']; 1599 fn.log( 'Radio.co artwork: '+ data['current_track']['artwork_url_large'] ); 1600 if( data['current_track']['artwork_url_large'] && 'function' === typeof(callBack) ){ 1601 var art = data['current_track']['artwork_url_large']; 1602 if( art !== ''){ 1603 1604 $.qtMplayerGlobalSongData.thumbnail = art; 1605 callBack( art ); 1606 callBack = false;
1607 } 1608 } 1609 } else { 1610 title = 'Song title currently unavailable - Please check your radio settings'; 1611 } 1612 fn.qtApplyTitle(title, callBack); 1613 }, 1614 error: function(e) { 1615 } 1616 }); 1617 } 1618 /** 1619 * =================================================================== 1620 * 1621 * Radioking 1622 * 1623 * =================================================================== 1624 */ 1625 else if (fd.servertype == 'type-radioking' && qtradioking !== '' ){ 1626 var rUrl = 'https://api.radioking.io/widget/radio/'+qtradioking+'/track/current'; 1627 $.ajax({ 1628 type: 'GET', 1629 cache: false, 1630 url: rUrl, 1631 async: true, 1632 contentType: "application/json", 1633 success: function(data) { 1634 title = data.artist+' - '+data.title; 1635 if(data.cover && 'function' === typeof(callBack)){ 1636 1637 $.qtMplayerGlobalSongData.thumbnail = data.cover; 1638 callBack(data.cover); 1639 callBack = false; 1640 } 1641 fn.qtApplyTitle(title, callBack); 1642 }, 1643 error: function(e) { 1644 console.log(e); 1645 } 1646 }); 1647 } 1648 /** 1649 * =================================================================== 1650 * 1651 * Azuracast 1652 * 1653 * =================================================================== 1654 */ 1655 else if (fd.servertype == 'type-azuracast' && qtazuracast !== '' ){ 1656 var rUrl = ''; 1657 var feedurl = qtazuracast + '?rand='+timestamp; 1658 1659 if(qtUseProxy){ 1660 feedurl = proxyURL+'?qtproxycall='+window.btoa(qtazuracast); 1661 } 1662 $.ajax({ 1663 type: 'GET', 1664 cache: false, 1665 url: feedurl, 1666 async: true, 1667 contentType: "application/json", 1668 success: function(data) { 1669 if("string" == typeof(data)){ 1670 data = jQuery.parseJSON( data ); 1671 } 1672 if( 'undefined' === typeof( data.now_playing ) ){ 1673 data = data[0]; 1674 } 1675 author = data.now_playing.song.artist; 1676 title = data.now_playing.song.title; 1677 if('' !== author){ 1678 title = author+' - '+title; 1679 } 1680 if(data.now_playing.song.cover && 'function' === typeof(callBack)){ 1681 $.qtMplayerGlobalSongData.thumbnail = data.now_playing.song.cover; 1682 callBack(data.now_playing.song.cover); 1683 1684 callBack = false; 1685 } 1686 if(data.now_playing.song.art && 'function' === typeof(callBack)){ 1687 // console.log(data.now_playing.song.art); 1688 $.qtMplayerGlobalSongData.thumbnail = data.now_playing.song.art; 1689 callBack(data.now_playing.song.art); 1690 1691 callBack = false; 1692 } 1693 1694 if(data.cover && 'function' === typeof(callBack)){ 1695 $.qtMplayerGlobalSongData.thumbnail = data.cover; 1696 callBack(data.cover); 1697 1698 callBack = false; 1699 } 1700 if(data.art && 'function' === typeof(callBack)){ 1701 $.qtMplayerGlobalSongData.thumbnail = data.art; 1702 callBack(data.art); 1703 1704 callBack = false; 1705 } 1706 1707 // Listeners ====================================== 1708 if(data.listeners){ 1709 if(data.listeners.current){ 1710 listeners = data.listeners.current; 1711 } 1712 if(data.listeners.total){ 1713 listener_peak = data.listeners.total; 1714 } 1715 1716 fn.qtApplyListeners(listeners, listener_peak); 1717 } 1718 1719 1720 fn.qtApplyTitle(title, callBack); 1721 }, 1722 error: function(e) { 1723 console.log(e); 1724 1725 } 1726 }); 1727 } 1728 } 1729 return; 1730 }, 1731 feedInterval: null, 1732 stopFeed: function(){ 1733 var o = $.qtmplayerRadioFeedObj; 1734 if("undefined" !== typeof($.qtmplayerRadioFeedObj.fn.qtFeedInterval) ){ 1735 clearInterval($.qtmplayerRadioFeedObj.fn.qtFeedInterval); 1736 } 1737 1738 }, 1739 pushFeed: function( data ){ 1740 1741 var o = $.qtmplayerRadioFeedObj; 1742 o.qtFeedData = data; 1743 o.fn.log('pushFeed = INITIALIZE'+$.now()); 1744 o.fn.log(data); 1745 o.fn.stopFeed(); 1746 o.fn.newFeedReading(); 1747 o.fn.qtApplyListeners(false,false); 1748 $.qtmplayerRadioFeedObj.qtFeedData.dataType = ''; 1749 $.qtmplayerRadioFeedObj.fn.qtFeedInterval = setInterval( 1750 function(){ 1751 o.fn.newFeedReading(); 1752 }, 1753 $.qtmplayerRadioFeedObj.timeInterval 1754 ); 1755 }, 1756 log:function(msg){ 1757 var c = $("#qtmPlayerDebugger"); 1758 if(c.length > 0){
1759 c.append(msg+'<br>'); 1760 } 1761 } 1762 } 1763 1764 }; 1765 $(document).ready(function(){ 1766 $.qtmplayerRadioFeedObj.fn.qtApplyTitle(); 1767 }); 1768})(jQuery); 1769 1770 1771 1772 1773
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.