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 $.qtmplayerRadioFeedObj = { 22 body: $("body"), 23 window: $(window), 24 document: $(document), 25 htmlAndbody: $('html,body'), 26 qtFeedData: {}, 27 timeInterval: 15000, 28 /** 29 * ======================================================================================================================================== | 30 * | 31 * | 32 * START SITE FUNCTIONS | 33 * | 34 * | 35 * ======================================================================================================================================== | 36 */ 37 fn: { 38 cachedThumbsArray: [], // when this changes, we fetch a new cover 39 40 // ----------------------------------------------- FEED READERS END ------------------------------------ 41 getThumbnail: function(that, termArray, callBack){ 42 43 44 var preclean = termArray.split('<!--'); 45 if(preclean.length > 1){ 46 termArray = preclean[0]; 47 } 48 49 termArray = termArray.split(' - ').join('-').split(' ').join('+'); 50 51 var thumb; // image from itunes 52 var apiUrl = 'https://itunes.apple.com/search?term='+termArray; 53 54 if(termArray == 'Song title unavailable' || termArray == 'No Titles Available'){ 55 thumb = $.qtmplayerRadioFeedObj.qtFeedData.cover; 56 that.cachedThumbsArray[termArray] = thumb; 57 callBack(thumb); 58 return; 59 } 60 61 62 if( undefined === that.cachedThumbsArray[termArray] ) { 63 64 if( $.qtmplayerRadioFeedObj.qtFeedData.artwork ){ 65 termArray = termArray.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 66 callBack($.qtmplayerRadioFeedObj.qtFeedData.artwork+'?song='+termArray); 67 } else { 68 69 $.ajax({ 70 type: 'GET', 71 cache: true, 72 url: apiUrl, 73 async: true, 74 dataType: 'jsonp', 75 context: this, 76 success: function(json) { 77 if('object' !== typeof( json )){ 78 json = JSON.parse(json); 79 } 80 if(json.resultCount > 0){ 81 thumb = json.results[0].artworkUrl100.split('100x100bb.jpg').join('1000x1000bb.jpg'); 82 that.cachedThumbsArray[termArray] = thumb; 83 callBack(thumb); 84 return; 85 } 86 } 87 }); 88 } 89 } else { 90 // return cached image 91 callBack( that.cachedThumbsArray[termArray] ); 92 return; 93 } 94 }, 95 96 97 98 /**==================================================================== 99 * 100 * 101 * Marquee for longer texts 102 * 103 * 104 ====================================================================*/ 105 marqueeInstances: [], 106 marqueeText: function(that) { 107 if('function' !== typeof( $.fn.marquee ) ){ // missing marquee library? quit 108 return; 109 } 110 var marquees = $('body').find('.proradio-marquee'); 111 // Destroy any old instance of the marquee 112 if( that.marqueeInstances.length > 0 ){ 113 for( var mi = 0; mi < that.marqueeInstances.length; mi++ ){ 114 if( 'undefined' !== typeof( that.marqueeInstances[mi] )){ 115 that.marqueeInstances[mi].marquee('destroy'); 116 } 117 } 118 that.marqueeInstances = []; // reset 119 } 120 $.each(marquees, function(i,c){ 121 var item = $(c); 122 if(item.find('.marquee').length === 0){ 123 item.html('<span class="marquee">'+item.html()+'</span>'); 124 } 125 if( item.outerWidth() > item.find('.marquee').outerWidth() ){ // the title is short? quit! 126 return; 127 } 128 that.marqueeInstances[i] = item.marquee({ 129 duration: 20000, 130 gap: 150, 131 delayBeforeStart: 0, 132 direction: 'left', 133 duplicated: true, 134 pauseOnCycle: 0, 135 startVisible: true 136 }); 137 }); 138 }, 139 140 /** 141 * ======================================================= 142 * Display listeners when available 143 * @since 2022 06 21 144 * ======================================================= 145 * */ 146 qtApplyListeners: function(listeners, listener_peak){ 147 if($.qtmplayerRadioFeedObj.qtFeedData.listeners || $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 148 if(listeners || listener_peak){ 149 $(".qtmplayer__stats").addClass('show'); 150 if(listeners && $.qtmplayerRadioFeedObj.qtFeedData.listeners){ 151 $('.qtmplayer-listeners span').html(listeners); 152 $('.qtmplayer-listeners').show(); 153 } else { 154 $('.qtmplayer-listeners').hide(); 155 } 156 if(listener_peak && $.qtmplayerRadioFeedObj.qtFeedData.listenerspeak){ 157 $('.qtmplayer-listener_peak span').html(listener_peak); 158 $('.qtmplayer-listener_peak').show(); 159 } else { 160 $('.qtmplayer-listener_peak').hide(); 161 } 162 return true; 163 } 164 } 165 $(".qtmplayer__stats").removeClass('show'); 166 $('.qtmplayer-listeners span').html(''); 167 $('.qtmplayer-listener_peak span').html(''); 168 return; 169 }, 170 171 172 qtApplyTitle: function(result, callBack){ 173 var that = this; 174 if(result && result !== ''){ 175 176 var dmes = '>>>>> qtApplyTitle : '+result; 177 $.qtmplayerRadioFeedObj.fn.log(dmes); 178 179 // result = decodeURIComponent(escape(result)); 180 var feedsplit = result.split(" - "); 181 var artist; 182 var title; 183 if(feedsplit.length > 1){ 184 artist = feedsplit[0], 185 title = feedsplit[1]; 186 } else { 187 feedsplit = result.split("-"); 188 if(feedsplit.length > 1){ 189 artist = feedsplit[0], 190 title = feedsplit[1]; 191 } else { 192 artist = ""; 193 title = result; 194 } 195 } 196 var artistSplit = artist.split('['); 197 if( artistSplit.length > 1 ){ 198 artist = artistSplit[0]; 199 } 200 artistSplit = artist.split(' : '); 201 if( artistSplit.length > 1 ){ 202 artist = artistSplit[1]; 203 } 204 var titleSplit = title.split('['); 205 if( titleSplit.length > 1 ){ 206 title = titleSplit[0]; 207 } 208 title = $.trim(title); 209 artist = $.trim(artist); 210 211 $(".qtmplayer-feed").show(); 212 $('.qtmplayer__title').html(title); 213 $('.qtmplayer__artist').html(artist); 214 that.marqueeText( that ); 215 var termArray = artist+'-'+title; 216 217 if( callBack ){ 218 this.getThumbnail(that, termArray, callBack ); 219 } 220 221 if (window.screen.width < 670 ) { 222 223 var uA = navigator.userAgent || navigator.vendor || window.opera; 224 if ( /Googlebot/i.test(uA) || /Bing/i.test(uA) || /Yandex/i.test(uA) || /Apple Bot/i.test(uA) || /DuckDuck Bot/i.test(uA) ){
225 // Do nothing 226 } else { 227 jQuery(document).prop('title', artist+' - '+title); 228 } 229 230 } 231 232 } else { 233 $(".qtmplayer-feed").hide(); 234 } 235 return; 236 }, 237 newFeedReading: function(){ 238 239 240 // debug: fix title not changing after pause 241 242 $.qtmplayerRadioFeedObj.fn.log('newFeedReading = REITERATE - '+$.now()); 243 // console.log( $.qtmplayerRadioFeedObj.qtFeedData ); 244 var o = $.qtmplayerRadioFeedObj, 245 fd = o.qtFeedData, 246 callBack = fd.callBack, 247 fn = o.fn, 248 qtradiofeedHost = (undefined !== fd.host) ? fd.host : '', 249 qtradiofeedPort = (undefined !== fd.port) ? fd.port : '', 250 qtradiofeedProtocol = (undefined !== fd.protocol) ? fd.protocol : 'http', 251 theChannel = (undefined !== fd.channel) ? fd.channel : '', 252 qticecasturl = (undefined !== fd.icecasturl) ? fd.icecasturl : '', 253 qticecastmountpoint = (undefined !== fd.icecastmountpoint) ? fd.icecastmountpoint : '', 254 qticecastchannel = (undefined !== fd.icecastchannel) ? fd.icecastchannel : '', 255 qtradiodotco = (undefined !== fd.radiodotco) ? fd.radiodotco : '', 256 qtairtime = (undefined !== fd.airtime) ? fd.airtime : '', 257 qtradionomy = (undefined !== fd.radionomy) ? fd.radionomy : '', 258 qttextfeed = (undefined !== fd.textfeed) ? fd.textfeed : '', 259 qtUseProxy = (undefined !== fd.useproxy) ? fd.useproxy : '', 260 qtlive365 = (undefined !== fd.live365) ? fd.live365 : '', 261 qtradioking = (undefined !== fd.radioking) ? fd.radioking : '', 262 qtazuracast = (undefined !== fd.azuracast) ? fd.azuracast : '', 263 qtsecuresystems = (undefined !== fd.securesystems) ? fd.securesystems : '', 264 qtradiojar = (undefined !== fd.radiojar) ? fd.radiojar : '', 265 qtradioboss = (undefined !== fd.radioboss) ? fd.radioboss : '', 266 qtmaxcast = (undefined !== fd.maxcast) ? fd.maxcast : '', 267 qtsonicpanel = (undefined !== fd.sonicpanel) ? fd.sonicpanel : '', 268 qtsonicpaneldj = (undefined !== fd.sonicpaneldj) ? fd.sonicpaneldj : '', 269 qtjazler = (undefined !== fd.jazler) ? fd.jazler : '', 270 qtstreamerr = (undefined !== fd.streamerr) ? fd.streamerr : '', 271 qtFeedPlayerTrack = $('#qtFeedPlayerTrack'), 272 qtFeedPlayerAuthor = $('#qtFeedPlayerAuthor'), 273 qtPlayerTrackInfo = $("#qtPlayerTrackInfo"), 274 author, title, result, feedsplit; 275 o = $.qtmplayerRadioFeedObj; 276 var proxyURL = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 277 var timestamp = new Date().getUTCMilliseconds(); 278 279 var listener_peak = false; 280 var listeners = false; 281 282 283 /** 284 * =================================================================== 285 * 286 * MediaCP 287 * 288 * =================================================================== 289 */ 290 if( fd.servertype == 'type-mediacp' ){ 291 fn.log(qtmediacp); 292 if(qtUseProxy){ 293 qtmediacp = proxyURL+'?qtproxycall='+window.btoa(qtmediacp); 294 } 295 $.ajax({ 296 type: 'GET', 297 cache: false, 298 url: qtmediacp, 299 async: true, 300 jsonp: true, 301 success: function(data) { 302 if('object' !== typeof( data )){ 303 data = JSON.parse(data); 304 } 305 fn.log(data); 306 title = data.nowplaying; 307 if(data.coverart && 'function' === typeof(callBack)){ 308 callBack( data.coverart ); 309 callBack = false; 310 } 311 fn.qtApplyTitle(title, callBack); 312 }, 313 error: function(e){ 314 console.log('MediaCP feed not loaded - error ahead:'); 315 console.log(e); 316 } 317 }); 318 return; 319 } 320 321 322 323 /** 324 * =================================================================== 325 * 326 * Streamerr 327 * 328 * =================================================================== 329 */ 330 if( fd.servertype == 'type-streamerr' ){ 331 fn.log(qtstreamerr); 332 if(qtUseProxy){ 333 qtstreamerr = proxyURL+'?qtproxycall='+window.btoa(qtstreamerr); 334 } 335 $.ajax({ 336 type: 'GET', 337 cache: false, 338 url: qtstreamerr, 339 async: true, 340 jsonp: true, 341 success: function(data) { 342 343 if('object' !== typeof( data )){ 344 data = JSON.parse(data); 345 } 346 347 fn.log(data); 348 title = data.nowplaying; 349 if(data.coverart && 'function' === typeof(callBack)){ 350 callBack( data.coverart ); 351 callBack = false;
352 } 353 fn.qtApplyTitle(title, callBack); 354 }, 355 error: function(e){ 356 console.log('Streamerr not working - error ahead:'); 357 console.log(e); 358 } 359 }); 360 return; 361 } 362 363 364 365 /** 366 * =================================================================== 367 * 368 * sonicpanel 369 * 370 * =================================================================== 371 */ 372 if( fd.servertype == 'type-sonicpanel' ){ 373 if( qtsonicpanel !== ''){ 374 if ( qtsonicpanel.indexOf("?") > -1 ) { 375 qtsonicpanel = qtsonicpanel + '&rand='+timestamp; 376 } else { 377 qtsonicpanel = qtsonicpanel + '?rand='+timestamp; 378 } 379 if(qtUseProxy){ 380 qtsonicpanel = proxyURL+'?qtproxycall='+window.btoa(qtsonicpanel); 381 } 382 $.ajax({ 383 type: 'GET', 384 cache: false, 385 url: qtsonicpanel, 386 async: true, 387 success: function(data) { 388 if('object' !== typeof( data )){ 389 data = JSON.parse(data); 390 } 391 var titles = 'Now live - Streaming'; 392 if(data.title){ 393 titles = data.title; 394 if(data.artist){ 395 titles = data.artist+' - '+data.title; 396 } 397 } 398 if(data.art && 'function' === typeof(callBack)){ 399 if(data.title){ 400 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 401 } 402 callBack(data.art); 403 callBack = false; 404 } 405 if(data.thumb && 'function' === typeof(callBack)){ 406 callBack(data.thumb+'#.jpg'); 407 callBack = false; 408 } 409 if( '1' == qtsonicpaneldj && data.djusername !== 'No DJ'){ 410 titles = data.title.split(' - ').join(' / ')+' - '+data.djusername; 411 } 412 if(data.listn){ 413 listeners = data.listn; 414 } 415 if(data.peaklistn){ 416 listener_peak = data.peaklistn; 417 } 418 fn.qtApplyListeners(listeners, listener_peak); 419 fn.qtApplyTitle(titles, callBack); 420 }, 421 error: function(e){ 422 console.log(e); 423 } 424 }); 425 } 426 } 427 428 429 /** 430 * =================================================================== 431 * 432 * qtjazler 433 * 434 * =================================================================== 435 */ 436 if( fd.servertype == 'type-jazler' ){ 437 var qtjazlerFolder = qtjazler.split('NowOnAir.xml').join('AlbumsCache/'); 438 if(qtUseProxy){ 439 qtjazler = proxyURL+'?qtproxycall='+window.btoa(qtjazler); 440 } 441 fn.log('=============================================================='); 442 fn.log(qtjazler); 443 $.ajax({ 444 type: "GET", 445 url:qtjazler, 446 dataType: "xml", 447 async: true, 448 cache: false, 449 success: function(xml) { 450 fn.log(xml); 451 $(xml).find('Event').each(function(){ 452 fn.log($(this)); 453 var CacheImageFile = $(this).find('CacheImageFile').html(); 454 $(this).find('Announcement').each(function(){ 455 var title = $(this).attr('Display'); 456 fn.log(title); 457 if(CacheImageFile && 'function' === typeof(callBack) ){ 458 fn.log(qtjazlerFolder + CacheImageFile); 459 callBack( qtjazlerFolder + CacheImageFile ); 460 callBack = false; 461 } 462 fn.qtApplyTitle(title , callBack); 463 }); 464 465 }); 466 }, 467 error: function(e){ 468 console.log('Jazler source unreachable - please check your channel settings'); 469 console.log(e); 470 } 471 }); 472 return; 473 } 474 475 476 /** 477 * =================================================================== 478 * 479 * laut.FM 480 * 481 * =================================================================== 482 */ 483 if( fd.servertype == 'type-lautfm' ){ 484 fn.log('Server type: LAUT.FM'); 485 fn.log('Stream URL: '+fd.file); 486 if( fd.file.indexOf('/stream.laut.fm/') != -1 ){ 487 fn.log('Laut.FM reading titles'); 488 var radioname = fd.file.split('https').join('http').split('http://stream.laut.fm/').join(''); 489 var radiourl = 'https://api.laut.fm/station/'+radioname+'/current_song'; 490 // if ( radiourl.indexOf("?") > -1 ) { 491 // radiourl = radiourl + '&rand='+timestamp; 492 // } else { 493 // radiourl = radiourl + '?rand='+timestamp; 494 // } 495 if(qtUseProxy){ 496 radiourl = proxyURL+'/?qtproxycall='+window.btoa(radiourl); 497 } 498 // console.log(radiourl); 499 $.ajax({ 500 type: 'GET', 501 url: radiourl, 502 async: true, 503 cache: false, 504 success: function(data) { 505 fn.log('Laut.FM Success'); 506 if('object' !== typeof( data )){ 507 data = JSON.parse(data); 508 } 509 var titles = 'Now live - Streaming'; 510 511 if(data.type){ 512 if(data.type !== 'jingle'){ 513 if(data.title){ 514 titles = data.title; 515 if(data.artist){ 516 if(data.artist.name){ 517 titles = data.artist.name +' - '+ titles; 518 } 519 } 520 } 521 fn.qtApplyTitle( titles, callBack ); 522 } 523 } 524 525 }, 526 error: function(e){ 527 fn.log(e); 528 console.log(e); 529 fn.qtApplyTitle('Laut FM API error - Titles not available'); 530 } 531 }); 532 } 533 return; 534 } // IF servertype end 535 536 537 538 if( fd.servertype === 'type-icy' ){ 539 540 541 fn.log('type-icy'); 542 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 543 $.ajax({ 544 type: 'GET', 545 url: proxyURL, 546 jsonpCallback: 'parseMusic', 547 async: true, 548 cache: false, 549 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 550 success: function(data) { 551 if(data === 'Song title unavailable' || data === 'Cannot open the stream' ){ 552 fn.log('ERROR OPENING THE STREAM OR GETTING THE TITLES: '+data); 553 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 554 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 555 return; 556 } 557 fn.qtApplyTitle( data, callBack ); 558 fn.log(data); 559 }, 560 error: function(e){ 561 console.log('Error'); 562 fn.log(e); 563 console.log(e); 564 } 565 }); 566 } 567 568 569 570 /** 571 * =================================================================== 572 * 573 * Auto or HTTPS shoutcast 574 * 575 * =================================================================== 576 */ 577 if( fd.servertype == 'type-auto' ){ 578 if(fd.file.indexOf('/proxy/') != -1 && fd.file.indexOf('https') != -1 && fd.file.indexOf('?mp=/') != -1){ 579 fn.log('type-auto TYPE 1 - GET MOUNTPOINT'); 580 581 qtradiofeedHost = fd.file.split('?mp=/'); 582 qtradiofeedHost = qtradiofeedHost[0] + '?mp=/stats' + '&rand='+timestamp; 583 if(qtUseProxy){ 584 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 585 } 586 $.ajax({ 587 type: 'GET', 588 url: qtradiofeedHost, 589 async: true, 590 cache: false, 591 dataType: "xml", 592 success: function(data) { 593 594 595 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 596 597 // Listeners ====================================== 598 if($(data).find('CURRENTLISTENERS')){ 599 listeners = $(data).find('CURRENTLISTENERS').html(); 600 } 601 if($(data).find('PEAKLISTENERS')){ 602 listener_peak = $(data).find('PEAKLISTENERS').html(); 603 } 604 fn.qtApplyListeners(listeners, listener_peak); 605 606 }, 607 error: function(e){ 608 fn.log(e); 609 console.log(e); 610 } 611 }); 612 } else if(fd.file.indexOf('/proxy/') == -1 && fd.file.indexOf('https') != -1 && fd.file.endsWith('/stream') && fd.file.indexOf('/mp3') == -1 ){ 613 614 fn.log('type-auto TYPE 2 - XML:'+fd.file.endsWith('/stream')+'? ----> '+fd.file); 615 616 617 618 // OLD system 619 // qtradiofeedHost = fd.file.split('/stream'); 620 // qtradiofeedHost = qtradiofeedHost[0] + '/stats'; // no random here
621 // NEW - replace only the last occurrence of /stream 622 qtradiofeedHost = fd.file.replace(/\/stream$/, '/stats','$1');// fd.file.split('/stream').join('/stats'); 623 624 625 fn.log('Stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 626 627 if(qtUseProxy){ 628 qtradiofeedHost = proxyURL+'?qtproxycall='+window.btoa(qtradiofeedHost); 629 } 630 fn.log('Proxy stats link: <a href="'+qtradiofeedHost+'">'+qtradiofeedHost+'</a>'); 631 $.ajax({ 632 type: 'GET', 633 url: qtradiofeedHost, 634 async: true, 635 //cache: false, 636 //dataType: "xml", 637 success: function(data) { 638 639 640 if(data === 'Song title unavailable' ){ 641 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title , false); 642 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 643 return; 644 } 645 646 647 fn.qtApplyTitle( $(data).find('SONGTITLE').html() , callBack); 648 649 650 // Listeners ====================================== 651 if($(data).find('CURRENTLISTENERS')){ 652 listeners = $(data).find('CURRENTLISTENERS').html(); 653 } 654 if($(data).find('PEAKLISTENERS')){ 655 listener_peak = $(data).find('PEAKLISTENERS').html(); 656 } 657 fn.qtApplyListeners(listeners, listener_peak); 658 659 }, 660 error: function(e){ 661 fn.log(e); 662 console.log(e); 663 } 664 }); 665 666 } else { 667 fn.log('type-auto TYPE 3 ICY METADATA'); 668 669 670 fn.log( proxyURL+"?qtproxycall="+ window.btoa(fd.file) + '&icymetadata=1' ); 671 $.ajax({ 672 type: 'GET', 673 url: proxyURL, 674 jsonpCallback: 'parseMusic', 675 async: true, 676 cache: false, 677 data: { "qtproxycall": window.btoa(fd.file), 'icymetadata': '1' }, 678 success: function(data) { 679 if(data === 'Song title unavailable' ){ 680 fn.qtApplyTitle( $.qtmplayerRadioFeedObj.qtFeedData.title, false ); 681 callBack( $.qtmplayerRadioFeedObj.qtFeedData.cover ); 682 return; 683 } 684 fn.qtApplyTitle( data, callBack ); 685 fn.log(data); 686 } 687 }); 688 689 } 690 return; 691 } 692 693 /** 694 * Maxcast 695 */ 696 /** 697 * =================================================================== 698 * 699 * Maxcast 700 * 701 * =================================================================== 702 */ 703 // Demo feeds: 704 //https://s05.maxcast.com.br/api/status/brasitaliawebradio/current.json 705 //https://s16.maxcast.com.br/api/status/bocadoacreatualjt/current.json 706 if( fd.servertype == 'type-maxcast' ){ 707 fn.log('Maxcast '+ qtmaxcast); 708 qtmaxcast = qtmaxcast + '?rand='+timestamp; 709 if(qtUseProxy){ 710 qtmaxcast = proxyURL+'?qtproxycall='+window.btoa(qtmaxcast); // working without proxy. Leave here just in case 711 } 712 $.ajax({ 713 type: 'GET', 714 cache: false, 715 url: qtmaxcast, 716 async: true, 717 jsonpCallback: "parseMusic", 718 jsonp: false, 719 data: songdata, 720 success: function(data) { 721 if('object' !== typeof(data)){ 722 data = JSON.parse(data); 723 } 724 if(data.playing){ 725 title = data.playing.current; 726 } 727 if(data.song_data && 'function' === typeof(callBack)){ 728 callBack( data.song_data.cover ); 729 callBack = false; 730 } 731 fn.qtApplyTitle(title, callBack); 732 }, 733 error: function(e){ 734 console.log(e); 735 } 736 }); 737 return; 738 } 739 740 if(qtradioboss === '' && qtsecuresystems === '' && qtradiojar === '' && qtradioking === '' && qtazuracast === '' && qttextfeed === '' && qtradionomy === '' && qtlive365 === '' && qtairtime === '' && (qtradiofeedHost === '' || qtradiofeedPort === '' || typeof(qtradiofeedHost) === 'undefined') && qticecasturl === '' && qtradiodotco === '') { 741 fn.qtApplyTitle(); 742 return; 743 } else { 744 745 746 747 748 749 /** 750 * =================================================================== 751 * 752 * Radioboss 753 * 754 * =================================================================== 755 */ 756 if( qtradioboss !== ''){ 757 qtradioboss = qtradioboss;// + '?rand='+timestamp; 758 fn.log(qtradioboss); 759 760 if(qtUseProxy){ 761 qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 762 } 763 764 // qtradioboss = proxyURL+'?qtproxycall='+window.btoa(qtradioboss); 765 $.ajax({ 766 type: 'GET', 767 cache: false, 768 url: qtradioboss, 769 async: true, 770 // contentType: "application/json", 771 // jsonp: true, 772 success: function(data) { 773 if('object' !== typeof( data )){ 774 data = JSON.parse(data); 775 } 776 title = data['nowplaying']; 777 fn.qtApplyTitle(title, callBack); 778 }, 779 error: function(e){ 780 console.log(e); 781 } 782 }); 783 return; 784 } 785 786 787 788 789 790 /** 791 * =================================================================== 792 * 793 * Radiojar 794 * 795 * =================================================================== 796 */ 797 if( qtradiojar !== ''){ 798 if ( qtradiojar.indexOf("?") > -1 ) { 799 qtradiojar = qtradiojar + '&rand='+timestamp; 800 } else { 801 qtradiojar = qtradiojar + '?rand='+timestamp; 802 } 803 if(qtUseProxy){ 804 qtradiojar = proxyURL+'?qtproxycall='+window.btoa(qtradiojar); 805 } 806 $.ajax({ 807 type: 'GET', 808 cache: false, 809 url: qtradiojar, 810 async: true, 811 success: function(data) { 812 if('object' !== typeof( data )){ 813 data = JSON.parse(data); 814 } 815 var titles = 'Now live - Streaming'; 816 if(data.title){ 817 titles = data.title; 818 if(data.artist){ 819 titles = data.artist+' - '+data.title; 820 } 821 } 822 if(data.art && 'function' === typeof(callBack)){ 823 if(data.title){ 824 data.art = data.art + '?title=' + data.title.toLowerCase().replace(/ /g, '-').replace(/[^\w-]+/g, ''); 825 } 826 callBack(data.art); 827 callBack = false;
828 } 829 if(data.thumb && 'function' === typeof(callBack)){ 830 callBack(data.thumb+'#.jpg'); 831 callBack = false; 832 } 833 fn.qtApplyTitle(titles, callBack); 834 }, 835 error: function(e){ 836 console.log(e); 837 } 838 }); 839 } 840 841 842 843 844 /** 845 * =================================================================== 846 * 847 * SecureSystems 848 * 849 * =================================================================== 850 */ 851 if( qtsecuresystems !== ''){ 852 qtsecuresystems =qtsecuresystems; 853 if(qtUseProxy){ 854 qtsecuresystems = proxyURL+'?qtproxycall='+window.btoa(qtsecuresystems); 855 } 856 $.ajax({ 857 type: 'GET', 858 cache: false, 859 url: qtsecuresystems, 860 async: true, 861 dataType: "xml", 862 success: function(data) { 863 if( $(data).find('cover').length > 0 ){ 864 if($(data).find('cover').html() !== '' && 'function' === typeof(callBack)){ 865 callBack($(data).find('cover').html()); 866 callBack = false; 867 } 868 } 869 var title = $(data).find('title').html(); 870 if( 'undefined' == typeof(title) || 'undefined' == title ){ 871 title = $(data).find('name').html(); 872 } 873 fn.qtApplyTitle( $(data).find('artist').html()+ ' - ' +title , callBack); 874 }, 875 error: function(e){ 876 console.log(e); 877 } 878 }); 879 return; 880 } 881 882 883 884 885 886 /** 887 * =================================================================== 888 * 889 * qtlive365 890 * 891 * =================================================================== 892 */ 893 if( qtlive365 !== ''){ 894 qtlive365 = 'https://api.live365.com/station/'+qtlive365; 895 if(qtUseProxy){ 896 qtlive365 = proxyURL+'?qtproxycall='+window.btoa(qtlive365); 897 } 898 899 $.ajax({ 900 type: 'GET', 901 cache: false, 902 url: qtlive365, 903 async: true, 904 jsonpCallback: "parseMusic", 905 jsonp: false, 906 success: function(data) { 907 // console.log(data); 908 jsondata = data; 909 // console.log(json); 910 if('object' !== typeof( data )){ 911 data = JSON.parse(data); 912 } 913 if( data['current-track'].art ){ 914 var art = data['current-track'].art; 915 if( art != ''){ 916 callBack(art); 917 // console.log(art); 918 callBack = false; 919 } 920 } 921 fn.qtApplyTitle(data['current-track'].artist+' - '+data['current-track'].title, callBack); 922 }, 923 error: function(e){ 924 console.log(e); 925 } 926 }); 927 } 928 929 /** 930 * =================================================================== 931 * 932 * Text 933 * 934 * =================================================================== 935 */ 936 else if(qttextfeed !== ''){ 937 var tfeedurl,jsondata, title, proxyURL, mydata; 938 if(qtUseProxy){ 939 tfeedurl = $("#qtmplayer-radiofeed-proxyurl").data('proxyurl'); 940 mydata = { 941 "qtproxycall": window.btoa(qttextfeed), 942 }; 943 } else { 944 tfeedurl = qttextfeed; 945 } 946 $.ajax({ 947 type: 'GET', 948 cache: false, 949 url: tfeedurl, 950 async: true, 951 data: mydata, 952 dataType: "html", 953 success: function(data) { 954 fn.qtApplyTitle( data, callBack ); 955 }, 956 error: function(e){ 957 console.log(e); 958 } 959 }); 960 return; 961 } 962 /** 963 * =================================================================== 964 * 965 * Radionomy 966 * 967 * =================================================================== 968 */ 969 else if(qtradionomy !== '' ) { 970 $.ajax({ 971 type: 'GET', 972 url: qtradionomy, 973 async: true, 974 cache: false, 975 dataType: "xml", 976 success: function(data) { 977 fn.qtApplyTitle( $(data).find('artists').html()+ ' - ' + $(data).find('title').html() ); 978 }, 979 error: function(e){ 980 console.log(e); 981 } 982 }); 983 } 984 985 /** 986 * =================================================================== 987 * 988 * AirTime 989 * 990 * =================================================================== 991 */ 992 else if(qtairtime !== '' && qtairtime !== 'undefined' && qtairtime !== undefined && typeof(qtairtime) !== 'undefined'){ 993 var jsondata, title; 994 $.ajax({ 995 type: 'GET', 996 cache: false, 997 url: qtairtime,//proxyURL, 998 async: true, 999 data: { 1000 "qtproxycall": window.btoa(qtairtime), 1001 }, 1002 jsonpCallback: "parseMusic", 1003 jsonp: true,//jsonp: true, 1004 // contentType: "application/json", 1005 success: function(data) { 1006 // console.log(data); 1007 if(typeof(data) !== 'object'){ 1008 data = JSON.parse(data); 1009 } 1010 title = data.tracks.current.name; 1011 fn.qtApplyTitle(title); 1012 }, 1013 error: function(e) { 1014 } 1015 }); 1016 } 1017 1018 /** 1019 * =================================================================== 1020 * 1021 * Icecast 1022 * 1023 * =================================================================== 1024 */ 1025 else if(qticecasturl !== '' && typeof(qticecasturl) !== 'undefined') { 1026 var feedurl = qticecasturl; 1027 var source; 1028 var title; 1029 var songdata; 1030 var listeners = false;
1031 var listener_peak = false; 1032 if(qtUseProxy){ 1033 feedurl = proxyURL; 1034 songdata = { 1035 "qtproxycall": window.btoa(qticecasturl), 1036 }; 1037 } 1038 // beta 1039 fn.log('Radio feed - Icecast '+ qticecasturl); 1040 // generally ok, not working for LN Soulr Icecast 1041 // console.log( proxyURL+'?qtproxycall='+window.btoa(qticecasturl) ); 1042 $.ajax({ 1043 type: 'GET', 1044 cache: false, 1045 url: feedurl, 1046 async: true, 1047 jsonpCallback: "parseMusic", 1048 jsonp: false,//jsonp: true, 1049 // dataType: 'jsonp', // not working with some radios 1050 data: songdata, 1051 // contentType: "application/json", 1052 success: function(json) { 1053 fn.log('Ajax response'); 1054 fn.log( json ); 1055 1056 // console.log(json); 1057 if('object' !== typeof( json )){ 1058 json = JSON.parse(json); 1059 } 1060 if('undefined' === typeof(json.icestats)){ 1061 // This is Icecast HK 1062 1063 if(qticecastmountpoint){ 1064 source = json[qticecastmountpoint]; 1065 } else { 1066 1067 $.each(json, function(index, element) { 1068 source = element; 1069 if(index == 0){ 1070 source = element; 1071 } 1072 }); 1073 // console.log(source); 1074 } 1075 } else { 1076 source = json.icestats.source; 1077 } 1078 1079 if('undefined' === typeof(source)){ 1080 return; 1081 } 1082 if(qticecastmountpoint){ 1083 source = source[qticecastmountpoint]; 1084 } 1085 if(qticecastchannel){ 1086 // console.log("set source to 0"); 1087 source = source[qticecastchannel]; 1088 } 1089 // since PR.3.2.3 1090 // If there is no channel and there is no title, channel must be 0 1091 if(!qticecastchannel && 'undefined' === typeof(source.title)){ 1092 source = source[0]; 1093 } 1094 title = source.title; 1095 if( source.artist ){ 1096 title = title +' - '+source.artist; 1097 } 1098 fn.qtApplyTitle(title, callBack); 1099 // Listeners ====================================== 1100 if(source.listeners){ 1101 listeners = source.listeners; 1102 } 1103 if(source.listener_peak){ 1104 listener_peak = source.listener_peak; 1105 } 1106 fn.qtApplyListeners(listeners, listener_peak); 1107 1108 },error: function(e) { 1109 console.log(e); 1110 fn.log('Ajax response'); 1111 fn.log( e ); 1112 } 1113 }); 1114 } 1115 /** 1116 * =================================================================== 1117 * 1118 * ShoutCast 1119 * 1120 * =================================================================== 1121 */ 1122 else if (qtradiofeedHost !== '' && qtradiofeedPort !== '' && typeof(qtradiofeedHost) !== 'undefined'){ 1123 // to tide up 1124 var feedData = { 1125 shoutcast_host: qtradiofeedHost, 1126 shoutcast_port: qtradiofeedPort, 1127 shoutcast_protocol: qtradiofeedProtocol, 1128 shoutcast_channel: theChannel 1129 }; 1130 var channel = feedData.shoutcast_channel || 1; 1131 var protocol = 'http'; 1132 if(feedData.shoutcast_port === '443' || feedData.shoutcast_protocol === 'https' ){ 1133 protocol = 'https'; 1134 } 1135 var shoutcastUrl = protocol+'://'+feedData.shoutcast_host+':'+feedData.shoutcast_port+'/stats?sid='+channel+'&json=1'; 1136 var feedurl = shoutcastUrl; 1137 1138 if(qtUseProxy){ 1139 feedurl = proxyURL; 1140 songdata = { 1141 "qtproxycall": window.btoa(shoutcastUrl), 1142 }; 1143 } 1144 1145 /** 1146 * @since PR.3.4.6 2021 02 27 added fallback 1147 */ 1148 try{ 1149 1150 $.ajax({ 1151 type: 'GET', 1152 cache: false, 1153 url: feedurl, 1154 async: true, 1155 data: songdata, 1156 dataType: $.qtmplayerRadioFeedObj.qtFeedData.dataType, 1157 contentType: "application/json", 1158 success: function(json) { 1159 if('object' !== typeof( json )){ 1160 json = JSON.parse(json); 1161 } 1162 fn.qtApplyTitle( json.songtitle, callBack); 1163 // Listeners ====================================== 1164 if(json.currentlisteners){ 1165 listeners = json.currentlisteners; 1166 } 1167 if(json.peaklisteners){ 1168 listener_peak = json.peaklisteners; 1169 } 1170 fn.qtApplyListeners(listeners, listener_peak); 1171 },error: function(e) { 1172 if($.qtmplayerRadioFeedObj.qtFeedData.dataType !== 'jsonp'){ 1173 $.qtmplayerRadioFeedObj.qtFeedData.dataType = 'jsonp'; 1174 $.qtmplayerRadioFeedObj.fn.newFeedReading(); 1175 } 1176 } 1177 }); 1178 } catch(e){ 1179 dataType = 'jsonp'; 1180 console.log(e); 1181 } 1182 1183 return; 1184 } 1185 /** 1186 * =================================================================== 1187 * 1188 * Radio.co 1189 * 1190 * =================================================================== 1191 */ 1192 else if (qtradiodotco !== '' && typeof(qtradiodotco) !== 'undefined'){ 1193 var rUrl = 'https://public.radio.co/stations/'+qtradiodotco+'/status' 1194 $.ajax({ 1195 type: 'GET', 1196 cache: false, 1197 url: rUrl, 1198 async: true, 1199 contentType: "application/json", 1200 success: function(data) { 1201 if( data['current_track'] ){ 1202 title = data['current_track']['title']; 1203 fn.log( 'Radio.co artwork: '+ data['current_track']['artwork_url_large'] ); 1204 if( data['current_track']['artwork_url_large'] && 'function' === typeof(callBack) ){ 1205 var art = data['current_track']['artwork_url_large']; 1206 if( art !== ''){ 1207 callBack( art ); 1208 callBack = false;
1209 } 1210 } 1211 } else { 1212 title = 'Song title currently unavailable - Please check your radio settings'; 1213 } 1214 fn.qtApplyTitle(title, callBack); 1215 }, 1216 error: function(e) { 1217 } 1218 }); 1219 } 1220 /** 1221 * =================================================================== 1222 * 1223 * Radioking 1224 * 1225 * =================================================================== 1226 */ 1227 else if (fd.servertype == 'type-radioking' && qtradioking !== '' ){ 1228 var rUrl = 'https://api.radioking.io/widget/radio/'+qtradioking+'/track/current'; 1229 $.ajax({ 1230 type: 'GET', 1231 cache: false, 1232 url: rUrl, 1233 async: true, 1234 contentType: "application/json", 1235 success: function(data) { 1236 title = data.artist+' - '+data.title; 1237 if(data.cover && 'function' === typeof(callBack)){ 1238 callBack(data.cover); 1239 callBack = false; 1240 } 1241 fn.qtApplyTitle(title, callBack); 1242 }, 1243 error: function(e) { 1244 console.log(e); 1245 } 1246 }); 1247 } 1248 /** 1249 * =================================================================== 1250 * 1251 * Azuracast 1252 * 1253 * =================================================================== 1254 */ 1255 else if (fd.servertype == 'type-azuracast' && qtazuracast !== '' ){ 1256 var rUrl = ''; 1257 var feedurl = qtazuracast + '?rand='+timestamp; 1258 1259 if(qtUseProxy){ 1260 feedurl = proxyURL+'?qtproxycall='+window.btoa(qtazuracast); 1261 } 1262 $.ajax({ 1263 type: 'GET', 1264 cache: false, 1265 url: feedurl, 1266 async: true, 1267 contentType: "application/json", 1268 success: function(data) { 1269 if("string" == typeof(data)){ 1270 data = jQuery.parseJSON( data ); 1271 } 1272 if( 'undefined' === typeof( data.now_playing ) ){ 1273 data = data[0]; 1274 } 1275 author = data.now_playing.song.artist; 1276 title = data.now_playing.song.title; 1277 if('' !== author){ 1278 title = author+' - '+title; 1279 } 1280 if(data.now_playing.song.cover && 'function' === typeof(callBack)){ 1281 callBack(data.now_playing.song.cover); 1282 callBack = false; 1283 } 1284 if(data.now_playing.song.art && 'function' === typeof(callBack)){ 1285 // console.log(data.now_playing.song.art); 1286 callBack(data.now_playing.song.art); 1287 callBack = false; 1288 } 1289 1290 if(data.cover && 'function' === typeof(callBack)){ 1291 callBack(data.cover); 1292 callBack = false; 1293 } 1294 if(data.art && 'function' === typeof(callBack)){ 1295 callBack(data.art); 1296 callBack = false; 1297 } 1298 1299 // Listeners ====================================== 1300 if(data.listeners){ 1301 if(data.listeners.current){ 1302 listeners = data.listeners.current; 1303 } 1304 if(data.listeners.total){ 1305 listener_peak = data.listeners.total; 1306 } 1307 1308 fn.qtApplyListeners(listeners, listener_peak); 1309 } 1310 1311 1312 fn.qtApplyTitle(title, callBack); 1313 }, 1314 error: function(e) { 1315 console.log(e); 1316 1317 } 1318 }); 1319 } 1320 } 1321 return; 1322 }, 1323 feedInterval: null, 1324 stopFeed: function(){ 1325 var o = $.qtmplayerRadioFeedObj; 1326 if("undefined" !== typeof($.qtmplayerRadioFeedObj.fn.qtFeedInterval) ){ 1327 clearInterval($.qtmplayerRadioFeedObj.fn.qtFeedInterval); 1328 } 1329 1330 }, 1331 pushFeed: function( data ){ 1332 var o = $.qtmplayerRadioFeedObj; 1333 o.qtFeedData = data; 1334 o.fn.log('pushFeed = INITIALIZE'+$.now()); 1335 o.fn.log(data); 1336 o.fn.stopFeed(); 1337 o.fn.newFeedReading(); 1338 o.fn.qtApplyListeners(false,false); 1339 $.qtmplayerRadioFeedObj.qtFeedData.dataType = ''; 1340 $.qtmplayerRadioFeedObj.fn.qtFeedInterval = setInterval( 1341 function(){ 1342 o.fn.newFeedReading(); 1343 }, 1344 $.qtmplayerRadioFeedObj.timeInterval 1345 ); 1346 }, 1347 log:function(msg){ 1348 var c = $("#qtmPlayerDebugger"); 1349 if(c.length > 0){
1350 c.append(msg+'<br>'); 1351 } 1352 } 1353 } 1354 1355 }; 1356 $(document).ready(function(){ 1357 $.qtmplayerRadioFeedObj.fn.qtApplyTitle(); 1358 }); 1359})(jQuery); 1360 1361 1362 1363 1364
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.