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