IPTV

Обсуждение проектов наших жителей.
Вы можете выставить проект на тест или найти помощников для его реализации.

Модератор: BV

hclubmk
Бывалый
Бывалый
Аватара пользователя
 
Сообщения: 235
Зарегистрирован: 19.06.2009 (Пт) 14:23
Откуда: От-туда

IPTV

Сообщение hclubmk » 11.04.2024 (Чт) 23:10

Камрады, здесь кто-то юзает сабж?
Научились ли Вы радоваться трудностям?

hclubmk
Бывалый
Бывалый
Аватара пользователя
 
Сообщения: 235
Зарегистрирован: 19.06.2009 (Пт) 14:23
Откуда: От-туда

IPTV

Сообщение hclubmk » 22.07.2024 (Пн) 19:25

Просто оставлю это здесь, может кому-то и пригодится (при желании "повтыкать" в телек)
движок
обсуждение
Сам парсер в оригинале (HTML):
Код: Выделить всё
<!DOCTYPE html>
<html>
<head>
<title>Поиск трансляций AceStream</title>
<link rel="icon" type="image/x-icon" href="https://acestream.org/img/favicon.ico">
<style>
    #container:focus-within {
     background-color: lightgray;
     width: 1140px;
   }
   #SearchInput {
     box-sizing: border-box;
     background-repeat: no-repeat;
     width: 100%;
     border: none;
     border-bottom: 1px solid #ddd;
   }
   .dropdown {
     position: relative;
     display: inline-block;
   }
   .dropdown-content {
     min-width: 510px;
     height: 300px;
     overflow: auto;
     resize: both;
     border: 1px solid #ddd;
     z-index: 1;
   }
   .dropdown-content a {
     color: black;
     text-decoration: none;
     display: block;
   }
   .dropdown a:hover {background-color: #dd0;}
   .show {display: block;}
   .header{
       font-weight: bold;
       background-color: lightgray;
       border-collapse: collapse;
       border: none;
       border-top: 1px solid darkgray;
       text-align:center;
       cursor: pointer;
       width:1142px;
   }
   .flexcnt {
       display: flex;
       flex-direction: row;
       flex-wrap: nowrap;
       justify-content: flex-start;
       align-items: flex-start;
   }
   table {
     border-collapse: collapse;
   }
   td, th {
     overflow: hidden;
          border: none;
     border-bottom: 1px solid #dddddd;
     text-align: left;
     padding: 0px;
   }
</style>
<script>
   var ChannelsArray = []; var InfohashArray = []; var IDArray = []; var IconArray = []; var CategoriesArray = [];   var SearchStringArray; var UpdatedArray = []; var LangArray = []; var CountriesArray = []; var BitrateArray = []; var ChIDArray = []; var AvailabilityArray = []; var StatusArray = []; var EPG = []; var EPG_start = []; var EPG_stop = [];
   var btn;
   var tickCounter = 0;
   var alreadyL;
   var ChID = 1;
   var ChIcons = 1;
   var SortDirection, SortColumn;
   var SortDirectionStore, SortColumnStore;
   var LogoIndex = 1;
   var MaxLogoTypeValue = 1;
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   window.addEventListener('resize',function() {
      try      
      {
         document.getElementById("ChannelDropdown").style.height = '' + window.innerHeight - document.getElementById("ChannelDropdown").offsetTop - 10 + 'px';
      }
      catch(e)
      {}
   });
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   window.addEventListener('beforeunload', function(event) {
      try
      {
         localStorage.setItem("searchtext", document.getElementById("searchtext").value);
         localStorage.setItem("EngineURL", document.getElementById("EngineURL").value);
         localStorage.setItem("MaxLogoTypeValue", document.getElementById("MaxLogoTypeValue").value);

         try
         {   
            localStorage.setItem("SearchInput", document.getElementById("SearchInput").value);
         }catch(e){}

         try
         {   
            localStorage.setItem("removetext", document.getElementById("removetext").value);
         }catch(e){}

         if (document.getElementById("AutoStart").checked == true)
            localStorage.setItem("AutoStart", 1);
         else
            localStorage.setItem("AutoStart", 0);

         localStorage.setItem("alreadyL", alreadyL);
         if (document.getElementById("AutoExit").checked == true)
            localStorage.setItem("AutoExit", 1);
         else
            localStorage.setItem("AutoExit", 0);

         if (document.getElementById("ChIcons").checked == true)
            localStorage.setItem("ChIcons", 1);
         else
            localStorage.setItem("ChIcons", 0);

         localStorage.setItem("SortDirection", SortDirection);
         localStorage.setItem("SortColumn", SortColumn);
         localStorage.setItem("LogoIndex", LogoIndex);


         if (document.getElementById("ChCategories").checked == true)
            localStorage.setItem("ChCategories", 1);
         else
            localStorage.setItem("ChCategories", 0);
         
         localStorage.setItem("RefType", getCheckedRadio());
      }
      catch(e){}
   });
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   window.addEventListener('load', function(event) {   
         let me = "<h1 style='height:0px; color:lightgray; font-size:10px;' >" + decodeURIComponent(escape(atob('wqkgaGNsdWJtaw=='))) + "</a>";
         document.getElementById("h2").insertAdjacentHTML("beforebegin", me);

      try{

         alreadyS = 0;
         document.getElementById("searchtext").value = window.localStorage.getItem("searchtext");
         document.getElementById("EngineURL").value = window.localStorage.getItem("EngineURL");
         document.getElementById("MaxLogoTypeValue").value = window.localStorage.getItem("MaxLogoTypeValue");

         if (window.localStorage.getItem("AutoStart") == 1)
            {
             document.getElementById("AutoStart").checked = true
            }
         else   
            {
            document.getElementById("AutoStart").checked = false;
            }

         if (window.localStorage.getItem("AutoExit") == 1)
            {
             document.getElementById("AutoExit").checked = true
            }
         else   
            {
            document.getElementById("AutoExit").checked = false;
            }
         if (window.localStorage.getItem("ChIcons") == 1)
            {
             document.getElementById("ChIcons").checked = true
            }
         else   
            {
            document.getElementById("ChIcons").checked = false;
            }
            SortColumnStore = parseInt(window.localStorage.getItem("SortColumn"));
            if(isNaN(SortColumnStore) == true)
               SortColumnStore = 7;

            SortDirectionStore = parseInt(window.localStorage.getItem("SortDirection"));
            if(isNaN(SortDirectionStore) == true)
               SortDirectionStore = 7;

            SortDirectionStore = parseInt(window.localStorage.getItem("LogoIndex"));
            if(isNaN(LogoIndex) == true)
               LogoIndex = 7;

         if (window.localStorage.getItem("ChCategories") == 1)
            {
             document.getElementById("ChCategories").checked = true
            }
         else   
            {
            document.getElementById("AutoStart").checked = false;
            }

         switch(parseInt(window.localStorage.getItem("RefType")))
         {
            case 1: document.getElementById("infohash_ref").checked = true; break;
            case 2: document.getElementById("contentid_ref").checked = true; break;
            case 3: document.getElementById("acecast_ref").checked = true; break;
            default: document.getElementById("infohash_ref").checked = true; break;
         } 

         if (window.localStorage.getItem("alreadyL") == 1)
            {
             alreadyL = 1;
            }
         else   
            {
             alreadyL = 0;
            }

      }
      catch(e){}

      btn = document.getElementById("searchbutton");
      btn.addEventListener("click", doSearch);
      
      if(document.getElementById("AutoStart").checked == true)
      {
         document.getElementById("InfoLabel").innerHTML = 'Автостарт через ' + (5 - tickCounter) + '...';
         autostart();
      }
      else
      {
         try{
               if(alreadyL == 1)
               {
                  alreadyL = 0;
                  doSearch();
               }
         }
         catch(e){}
      }
   });
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getCheckedRadio()
   {
      var radios = document.getElementsByName("play_ref_type");
   
      for (var i = 0, length = radios.length; i < length; i++)
      {
         if (radios[i].checked)
         {
             // do whatever you want with the checked radio
             return parseInt(radios[i].value);
         }
      }
          return 0;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function autostart()
   {
      setTimeout(function a()
      {
         tickCounter++;
         if (tickCounter == 5)
         {
            doSearch();
         }
         else
         {
            document.getElementById("InfoLabel").innerHTML = 'Автостарт через ' + (5 - tickCounter) + '...';
            if(document.getElementById("AutoStart").checked == true)
               autostart();
            else
               document.getElementById("InfoLabel").innerHTML = 'Ожидание действия...';
         }
      },2000);
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function autofinish()
   {
      setTimeout(function a()
      {
         tickCounter++;
         if (tickCounter == 5)
         {
            window.close();
         }
         else
         {
            document.getElementById("InfoLabel").innerHTML = 'Автозавершение через ' + (5 - tickCounter) + '...';
            if(document.getElementById("AutoExit").checked == true)
               autofinish();
            else
               document.getElementById("InfoLabel").innerHTML = 'Ожидание действия...';
         }
      },2000);
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function digit2(a)
   {
      if( a < 10)
         return '0'+a;
      else
         return ''+a;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function SearchChannels(index)
   {
      let xhr = new XMLHttpRequest();

      document.getElementById("InfoLabel").innerHTML = 'Обработка ' + SearchStringArray[index];

      xhr.open('GET', 'http://' + getEngineURL() + '/search?&page_size=20000&page=0&query=' + encodeURI(SearchStringArray[index]),true);
      xhr.send();
      xhr.onload = function()
      {
         if (xhr.status == 200)
         {   
               var obj = JSON.parse(xhr.response);
               for (var i = 0; i < obj.result.total; i++)
               if(CannelFounf(obj.result.results[i].items[0].infohash)==false)
               {
                  if(obj.result.results[i].items[0].name.toLowerCase().indexOf(SearchStringArray[index].toLowerCase()) != -1)
                  {
                     var cccount = obj.result.results[i].items.length;
                     for(var s = 0; s < obj.result.results[i].items.length; s++)
                     {
                        var nnname = obj.result.results[i].items[s].name;
                        if (s>0){nnname = nnname + " (reserve)";}
                        ChannelsArray.push(nnname);
                        InfohashArray.push(obj.result.results[i].items[s].infohash);
                        try
                        {
                        // выбираем иконку с максимальным type
                           var icontype=-1;
                           var iconURL="";
                           var t = parseInt(document.getElementById("MaxLogoTypeValue").value)
                           var maxTypeIcon = ( t == NaN ? 0 : t);
                           for (var ci = 0; ci < obj.result.results[i].icons.length; ci++)
                           {
                              if(obj.result.results[i].icons[ci].url.trim().length > 0)
                              {
                                 if(((icontype < obj.result.results[i].icons[ci].type) == true) && ((obj.result.results[i].icons[ci].type <= maxTypeIcon) == true))
                                 {
                                    icontype = obj.result.results[i].icons[ci].type;
                                    iconURL = obj.result.results[i].icons[ci].url.trim();
                                 }
                              }
                           }
                           IconArray.push(iconURL);
                        }
                        catch(e)
                        {
                           IconArray.push('');
                        }
                        try
                        {
                           var cat = '';
                           for (var ci = 0; ci < obj.result.results[i].items[s].categories.length; ci++)
                           {
                              if( cat.length > 0)
                                 cat = cat + ';';
                              cat = cat + obj.result.results[i].items[s].categories[ci];
                           }
                           CategoriesArray.push(cat);
                        }
                        catch(e)
                        {
                           CategoriesArray.push('');
                        }
                        try
                        {
                           var updated = new Date(obj.result.results[i].items[s].availability_updated_at*1000);
                           var d = updated.getFullYear() + '-' + digit2(updated.getMonth()+1) + '-' + digit2(updated.getDate())  + ' ' + digit2(updated.getHours()) + ':' + digit2(updated.getMinutes())+ ':' + digit2(updated.getSeconds());
                           UpdatedArray.push(d);
                        }
                        catch(e)
                        {
                           UpdatedArray.push('');
                        }
                        try
                        {
                           LangArray.push(obj.result.results[i].items[s].languages);
                        }
                        catch(e)
                        {
                           LangArray.push('');
                        }
                        try
                        {
                           CountriesArray.push(obj.result.results[i].items[s].countries);
                        }
                        catch(e)
                        {
                           CountriesArray.push('');
                        }
                        try
                        {
                           BitrateArray.push(obj.result.results[i].items[s].bitrate);
                        }
                        catch(e)
                        {
                           BitrateArray.push('');
                        }
                        try
                        {
                           ChIDArray.push(obj.result.results[i].items[s].channel_id);
                        }
                        catch(e)
                        {
                           ChIDArray.push('');
                        }
                        try
                        {
                           AvailabilityArray.push(obj.result.results[i].items[s].availability);
                        }
                        catch(e)
                        {
                           AvailabilityArray.push('');
                        }
                        try
                        {
                           var status;
                           if (obj.result.results[i].items[s].status == 2)
                              status = 'available';
                           else
                              status = 'no guaranty';
   
                           StatusArray.push(status);
                        }
                        catch(e)
                        {
                           StatusArray.push('');
                        }
                        try
                        {
                           EPG.push(obj.result.results[i].epg[0].name);
                           EPG_start.push(obj.result.results[i].epg[0].start);
                           EPG_stop.push(obj.result.results[i].epg[0].stop);
                        }
                        catch(e)
                        {
                           EPG.push('');
                           EPG_start.push('');
                           EPG_stop.push('');
                        }
                     }
                  }
               }

            if((SearchStringArray.length -1) == index)
            {
               if (ChID == 1)
               {
                  if (InfohashArray.length > 0)
                     GetContentID(0, getCheckedRadio());
                  else
                     OnFinishScan();
               }
               else
                  OnFinishScan();
            }
            else
            {
               SearchChannels(index+1);
            }
         }
      }
      xhr.onerror = function()
      {
         var m = decodeURIComponent(escape(atob('0JfQsNC/0YDQvtGBINC90LUg0YPQtNCw0LvRgdGPLiDQktC+0LfQvNC+0LbQvdC+LCDQtNCy0LjQttC+0LogQWNlU3RyZWFtINC90LUg0LfQsNCz0YDRg9C20LXQvQ==')));
         document.getElementById("InfoLabel").innerHTML = m;
         alert(m);
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function doSearch()
   {
      if(alreadyS == 1)
      {
         alreadyL = 1;
         location.reload();
      }
      alreadyS = 0;
      alreadyL = 0;

      SearchStringArray = document.getElementById("searchtext").value.split(',');
      SearchChannels(0);
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function CannelFounf(infohash)
   {
      for(var i = 0; i < InfohashArray.length; i++)
         if(InfohashArray[i] == infohash)
            return true;
      return false;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function playContentFromIH(index)
   {
      let xhr = new XMLHttpRequest();
      xhr.open('GET', 'http://' + getEngineURL()  + '/server/api?method=get_content_id&infohash=' + InfohashArray[index], true);
      xhr.send();
      xhr.onload = function() {
         if (xhr.status == 200)
         {   
            var obj = JSON.parse(xhr.response);
            if(!obj.result)
            {
               IDArray[indexi] = ""; // хотя, можно это и не делаьб
            }
            else
            {
               IDArray[index] = obj.result.content_id;
               var textInfo = makeTextInfo(index);
               var q = document.getElementById("infobox");
               q.innerHTML = textInfo;

               var a = document.createElement('a');
               a.href = "acestream://" + IDArray[index];
               a.click();

            }
         }
         else
         {
               IDArray[index] = "";
         }
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function GetContentID(index,really)
   {
      if(really == 2 || really == 3)
      {
         document.getElementById("InfoLabel").innerHTML = 'Поиск ' + (index+1) + ' из ' + InfohashArray.length + ' (' + Math.trunc((index+1)*100/InfohashArray.length) + '%) ID для: ' + ChannelsArray[index];
         let xhr = new XMLHttpRequest();
         xhr.open('GET', 'http://' + getEngineURL() + '/server/api?method=get_content_id&infohash=' + InfohashArray[index],true);
         xhr.send();
         xhr.onload = function() {
            if (xhr.status == 200)
            {   
               var obj = JSON.parse(xhr.response);
               if(!obj.result)
               {
                  IDArray.push("");
               }
               else
               {
                  IDArray.push(obj.result.content_id);
               }
            }
            else
            {
               IDArray.push("");
            }
            
            if((InfohashArray.length -1) == index)
            {
               OnFinishScan();
               return;
            }
            else
            {
               GetContentID(index+1,really);
            }
         }
      }
      else
      {
         IDArray.push("");
         if((InfohashArray.length -1) == index)
         {
            OnFinishScan();
            return;
         }
         else
         {
            GetContentID(index+1,really);
         }
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function OnFinishScan()
   {
      document.getElementById("InfoLabel").innerHTML = decodeURIComponent(escape(atob('0J7QttC40LTQsNC90LjQtSDQtNC10LnRgdGC0LLQuNGPLi4u')));

      addElement();
      alreadyL = 0;
      alreadyS = 1;
      if(document.getElementById("AutoExit").checked == true)
      {
         ExportM3U();
         tickCounter = 0;
         document.getElementById("InfoLabel").innerHTML = decodeURIComponent(escape(atob('0JDQstGC0L7Qt9Cw0LLQtdGA0YjQtdC90LjQtSDRh9C10YDQtdC3IA=='))) + (5 - tickCounter) + '...';
         autofinish();
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function prepareName(arr,name)
   {
      var newName = name;
      for(var i = 0; i < arr.length; i++)
      {
         newName = newName.replace(arr[i], '');
      }
      return newName.trim();
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function CreateM3UItem(index,typeoflink,removearr)
   {
      var category;
      var category2;
      var icon;
      var item = "";
      var name;

      if (CategoriesArray[index].length == 0)
         category = 'group-title=No-category';
      else
      {
         category = '';
         category2 = CategoriesArray[index].split(';');
         for(var ci = 0;ci < category2.length; ci++)
         {
            if (category.length > 0)
               category = category + ' ';
            category = category + 'group-title=' + category2[ci];
         }   
      }
      
      if (IconArray[index].length == 0)
         icon = '';
      else
         icon = 'tvg-logo=' + IconArray[index];

      if(InfohashArray[index].length !=0)
      {   
         name = prepareName(removearr,ChannelsArray[index]);
         switch(typeoflink)
         {
            case 1: item = '#EXTINF:-1 ' + category + ' ' +  icon + ',' + name + '\nhttp://'+getEngineURL() +'/ace/getstream?infohash=' + InfohashArray[index] + '\n'; break;
            case 2: item = '#EXTINF:-1 ' + category + ' ' +  icon + ',' + name + '\nhttp://'+getEngineURL() +'/ace/getstream?id=' + IDArray[index] + '\n'; break;
            case 3: item = '#EXTINF:-1 ' + category + ' ' +  icon + ',' + name + '\nacestream://' + IDArray[index] + '\n'; break;
            default: item = '#EXTINF:-1 ' + category + ' ' +  icon + ',' + name + '\nhttp://'+getEngineURL() +'/ace/getstream?infohash=' + InfohashArray[index] + '\n'; break;
         } 
      }
      return item;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function ExportM3U()
   {   var FileBody = '#EXTM3U\n';
      var div = document.getElementById("ChannelDropdown");
      var a = div.getElementsByTagName("a");
      var RemoveStringArray = document.getElementById("removetext").value.split(',');

      typeoflink = getCheckedRadio();
      for (var i = 0; i < a.length; i++)
      {
         if (a[i].parentElement.parentElement.style.display == "")
         {
            if (a[i].className === 'chname')
               FileBody = FileBody + CreateM3UItem(a[i].id,typeoflink,RemoveStringArray);
         }
      }
      var a = document.createElement('a');
      var blob = new Blob([FileBody], {'type':'application/octet-stream'});
      a.href = window.URL.createObjectURL(blob);
      a.download = 'export.m3u';
      a.click();
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function PlayChannelIndex(i)
   {
      if( IDArray[i].length != 0)
      {
         var a = document.createElement('a');
         a.href = "acestream://" + IDArray[i];
         a.click();
      }
      else
      {
         playContentFromIH(i);
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function makeTextInfo(i)
   {
      var dateNow = parseInt((new Date().getTime() / 1000).toFixed(0));
      var dateStart =  EPG_start[i];
      var dateStop =  EPG_stop[i];
      var percent  = Math.round((dateNow-dateStart)/(dateStop-dateStart)*100);
      return "<div style='float:left; max-height:50px;position: relative; top: 10px; left: 5px; height: 50px; vertical-align: bottom;display: table-cell; '><button type='button' id='play' style='min-width: 100px; max-width: 100px; min-height: 80px; max-height: 80px; vertical-align: center; display: table-cell;' onclick='PlayChannelIndex(`" + i + "`);'><img onerror='this.style.display=`none`' src='" + IconArray[i] + "' style='position: relative; top: -5px; left: -6px; width: 95px; margin-left:0px;vertical-align: bottom; max-height: 50px; max-width: 90;border: 0px solid #fff;'/><br>Смотреть</button></div'>" + "<br><b>" + ChannelsArray[i] + "</b><br><br>" + EPG[i] + ( percent != Infinity ? "<br>" + "<progress value="+percent+" max='100'></progress>" : "") + " " + getUTime(i);
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function GetChannelInfo(e)
   {
      var typeoflink = getCheckedRadio();
      var textInfo = makeTextInfo(e.id);
      var c = document.getElementById("result");
      var q = document.getElementById("infobox");
      q.style = "font-size:16px;";
      q.innerHTML = textInfo;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function ChannelDropDownClick()
   {
      document.getElementById("ChannelDropdown").classList.toggle("show");
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function filterFunction()
   {
      var input, filter, filterArr=[], ul, li, a, i, j;
      input = document.getElementById("SearchInput");
      filter = input.value.toUpperCase();
      filterArr = filter.split(',');

      if(filter == decodeURIComponent(escape(atob('SENMVUJNSw=='))))
      {
         alert(decodeURIComponent(escape(atob('0J/RgNC40LLQtdGCINGA0LDQt9GA0LDQsdC+0YLRh9C40LohCmhjbHVibWtAbGlzdC5ydQ=='))));
      }
      div = document.getElementById("ChannelDropdown");
      a = div.getElementsByClassName("chname");
      for (i = 0; i < a.length; i++)
      {
         if(filter.length == 0)
         {
            a[i].parentElement.parentElement.style.display = "";
         }
         else
         {
            txtValue = a[i].textContent || a[i].innerText;
            for (j = 0; j < filterArr.length; j++)
            {
               if(filterArr[j].length == 0)
                  continue;
               
               if (txtValue.toUpperCase().indexOf(filterArr[j]) > -1)
               {
                  a[i].parentElement.parentElement.style.display = "";
                  break;
               }
               else
               {
                  a[i].parentElement.parentElement.style.display = "none";
               }
            }
         }
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getCountryFlag(CCode)
   {
      var name = "";
      if (typeof CCode === "undefined")
         return "";
      else
      {
         try{
         CCode.forEach(function a(item, index, arr){
            var CCodeUP = item.toString();
            CCodeUP = CCodeUP.toUpperCase();
            if(CCodeUP != "INT")
            {
               name = decodeURIComponent(escape(atob('aHR0cHM6Ly9mbGFnY2RuLmNvbS93NDAv'))) + CCodeUP.toLowerCase() + ".png";
               return name;
            }
            });
         return name;
         }
         catch(e)
         {
            return "";
         }
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getFullCountryName(CCode)
   {
      var name = "";
      if (typeof CCode === "undefined")
         return "";
      else
      {
         try{
         CCode.forEach(function a(item, index, arr){
            let regionNames = new Intl.DisplayNames(["en"], { type: "region" });
            var CCodeUP = item.toString();
            CCodeUP = CCodeUP.toUpperCase();
            if(name.length > 0 )
               name = name + ", ";
            if(CCodeUP == "INT")
               name = name + "International";
            else
               name = name + regionNames.of(CCodeUP);
            });
         return name;
         }
         catch(e)
         {
            return "";
         }
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getLanguage(LL)
   {
      if (typeof LL === "undefined")
         return "";
      else
      {
         if(LL.toString().length > 0)
            return " (" + LL.toString() +")";
         else
            return "";
      }
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getChannelStatus(i)
   {
      return StatusArray[i] + " [" + AvailabilityArray[i].toFixed(2) + "]";
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getProgress(i)
   {
      var dateNow = parseInt((new Date().getTime() / 1000).toFixed(0));
      var dateStart =  EPG_start[i];
      var dateStop =  EPG_stop[i];
      var percent  = Math.round((dateNow-dateStart)/(dateStop-dateStart)*100);
      
      if (percent == Infinity)
         return '&nbsp;'
      else
         if(percent < 10)
            return '&nbsp;' + percent + '%'
         else
            return '' + percent + '%'
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getUTime(i)
   {
      if(EPG_start[i] != '')
      {
         var s = new Date(EPG_start[i]*1000);
         var e = new Date(EPG_stop[i]*1000);
         var d = '' + digit2(s.getHours()) + ':' + digit2(s.getMinutes())+ ' - ' +  digit2(e.getHours()) + ':' + digit2(e.getMinutes());
         return d;
      }
      else
         return '';

   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function SortTable(index,direction=1000)
   {   
      var tableHeader = document.getElementById('tableHeader');

      if(SortColumn != index)
      {
         SortColumn = index;
         if(direction == 1000)
            SortDirection = index;
         else
            SortDirection = direction;
      }
      else
      {
         if(SortDirection < 0)
            SortDirection = 0;
         else
            if(Math.abs(SortDirection)==index)
               SortDirection = -SortDirection;
            else
               SortDirection = index;
      }
      if(SortDirection == 0)
         SortColumn = 8;

      var SortHeader = index - 1 - ( index > 4 ? 1 : 0);
      for(var i=0;i<6;i++)
      {
         //Caption tableHeader.children[0].getElementsByTagName("TD")[0].innerHTML
         var Caption = tableHeader.children[0].getElementsByTagName("TD")[i].innerHTML;
         Caption = Caption.substring(0,Caption.length - 1);
         if (i == SortHeader)
         {
            var d;
            if (SortDirection > 0) d = "&#8593;";
            else
               if (SortDirection < 0) d = "&#8595;";
                  else
                     d = "-";
            Caption = Caption + d;
         }
         else
         {
            Caption = Caption + '-';
         }
         tableHeader.children[0].getElementsByTagName("TD")[i].innerHTML = Caption;
      }

      const parent = document.querySelector('.dropdown-content');
      const children = parent.querySelectorAll('.containerClass'); //elementClass
      const childrenArr = [...children];
      
      childrenArr.forEach(child => child.remove());
      
      childrenArr.sort((child1, child2) => {
        const value1 = child1.children[0].getElementsByTagName("TD")[SortColumn].childNodes[0].innerHTML.toLowerCase();
        const value2 = child2.children[0].getElementsByTagName("TD")[SortColumn].childNodes[0].innerHTML.toLowerCase();
       

        if (value1 > value2) return 1*(SortDirection > 0 ? 1 : -1);
        if (value1 < value2) return -1*(SortDirection > 0 ? 1 : -1);
      
        return 0;
      });

      childrenArr.forEach(child => parent.append(child));
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function getEngineURL()
   {
      var URL = document.getElementById('EngineURL').value.trim();
      if(URL.length == 0)
         return "127.0.0.1:6878";
      else
         return URL;
   }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
   function addElement()
   {
      try
      {
         document.getElementById('SearchResult').remove();
      }
      catch(e){}

      try
      {
         document.getElementById('InfoDiv').remove();
      }
      catch(e){}

      if (ChannelsArray.length >0)
      {
         var SearchResult = document.createElement('div');
         SearchResult.id = "SearchResult";

      SearchResult.innerHTML = decodeURIComponent(escape(atob('PGlucHV0IHR5cGU9J3RleHQnIHBsYWNlaG9sZGVyPSfQpNC40LvRjNGC0YAgKNCY0JvQmCkg0YLRgNCw0L3RgdC70Y/RhtC40Lkg0L/QviDQuNC80LXQvdC4INGBINGA0LDQt9C00LXQu9C40YLQtdC70Y/QvNC4ICZhcG9zOywmYXBvczsnIGlkPSdTZWFyY2hJbnB1dCcgc3R5bGU9J2JvcmRlcjogMXB4IHNvbGlkICMwMDA7d2lkdGg6NDA1cHg7IGJvcmRlci1yYWRpdXM6IDNweDsnIG9uaW5wdXQ9J2ZpbHRlckZ1bmN0aW9uKCknPjxicj48aW5wdXQgdHlwZT0ndGV4dCcgcGxhY2Vob2xkZXI9J9Ci0LXQutGB0YIg0YEg0YDQsNC30LTQtdC70LjRgtC10LvRj9C80LggJmFwb3M7LCZhcG9zOyDQtNC70Y8g0YPQtNCw0LvQtdC90LjRjyDQuNC3INC90LDQt9Cy0LDQvdC40Y8g0YLQsNC90YHQu9GP0YbQuNC4JyBpZD0ncmVtb3ZldGV4dCcgbmFtZT0ncmVtb3ZldGV4dCcgc3R5bGU9J2JvcmRlcjogMXB4IHNvbGlkICMwMDA7d2lkdGg6NDAwcHg7IGJvcmRlci1yYWRpdXM6IDNweDsnPiZuYnNwOzxpbnB1dCB0eXBlPSdidXR0b24nIGlkPSdleHBvcnQnICB2YWx1ZT0n0K3QutGB0L/QvtGA0YIuLi4nIHN0eWxlPSd3aWR0aDogMTAwcHgnPjx0YWJsZSBpZD0ndGFibGVIZWFkZXInIGNsYXNzPSdoZWFkZXInPjx0cj48dGQgY2xhc3M9J2hlYWRlcicgc3R5bGU9J2JvcmRlci1sZWZ0OiAxcHggc29saWQgZGFya2dyYXk7IHdpZHRoOjMyMHB4OyBtYXgtd2lkdGg6MzIwcHg7IG1heC1oZWlnaHQ6MjBweDsgb3ZlcmZsb3c6IGhpZGRlbjsnIG9uY2xpY2s9J1NvcnRUYWJsZSgxKSc+0J3QsNC40LzQtdC90L7QstCw0L3QuNC1IC08L3RkPjx0ZCBjbGFzcz0naGVhZGVyJyBzdHlsZT0nd2lkdGg6NDBweDtvdmVyZmxvdzpoaWRkZW47JyBvbmNsaWNrPSdTb3J0VGFibGUoMiknPiUgLTwvdGQ+PHRkIGNsYXNzPSdoZWFkZXInIHN0eWxlPSd3aWR0aDoxNDBweDtvdmVyZmxvdzpoaWRkZW47JyBvbmNsaWNrPSdTb3J0VGFibGUoMyknPtCU0L7RgdGC0YPQv9C90L7RgdGC0YwgLTwvdGQ+PHRkIGNsYXNzPSdoZWFkZXInIHN0eWxlPSd3aWR0aDoxODBweDtvdmVyZmxvdzpoaWRkZW47JyBvbmNsaWNrPSdTb3J0VGFibGUoNCknPtCe0LHQvdC+0LLQu9C10L0gLTwvdGQ+PHRkIGNsYXNzPSdoZWFkZXInIHN0eWxlPSd3aWR0aDoyMzBweDsgbWF4LXdpZHRoOjIzMHB4OyBtYXgtaGVpZ2h0OjIwcHg7IG92ZXJmbG93OiBoaWRkZW47JyBvbmNsaWNrPSdTb3J0VGFibGUoNiknPtCh0YLRgNCw0L3QsCAo0Y/Qt9GL0LopIC08L3RkPjx0ZCBjbGFzcz0naGVhZGVyJyBzdHlsZT0nYm9yZGVyLXJpZ2h0OiAxcHggc29saWQgZGFya2dyYXk7d2lkdGg6MjAwcHg7b3ZlcmZsb3c6aGlkZGVuOycgb25jbGljaz0nU29ydFRhYmxlKDcpJz7QmtCw0YLQtdCz0L7RgNC40LggLTwvdGQ+PC90cj48L3RhYmxlPjxkaXYgaWQ9J2ZsZXhjb250YWluZXInIGNsYXNzPSdmbGV4Y250Jz48ZGl2IGlkPSdDaGFubmVsRHJvcGRvd24nIGNsYXNzPSdkcm9wZG93bi1jb250ZW50JyBzdHlsZT0nYm9yZGVyOiAxcHggc29saWQgIzAwMDt3aWR0aDoxMTQwcHg7bWF4LXdpZHRoOiAxMTQwcHg7bWluLXdpZHRoOiAxMTQwcHg7bWluLWhlaWdodDogMjBweDsnPjwvZGl2PjwvZGl2Pg==')));

         document.getElementById("result").appendChild(SearchResult);

         var newSearch = document.createElement("div");
         for(var i=0;i<ChannelsArray.length;i++)
         {
            var newDiv = document.createElement("div");
            newDiv.innerHTML = "<table class='elementClass' id='channelTable'><tr><td id=" + i + "style='width:30px; max-width:30px; max-height:20px; overflow: hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:30px; max-width:30px; max-height:20px; overflow:hidden;'><img onerror='this.style.display=`none`' src='" + IconArray[i] + "' style='border: 0px solid #fff;width:30px; max-width:30px; max-height:20px;'></td><td style='width:300px; max-width:300px; overflow:hidden;'></a><a class='chname' href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:300px;overflow:hidden;'>" + ChannelsArray[i] + "</a></td><td id=" + i + "onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:60px; max-width:60px; max-height:20px; overflow: hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:60px; max-width:60px; max-height:20px; overflow:hidden;'>"+getProgress(i)+"</a></td><td style='width:140px;overflow:hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:140px;overflow:hidden;'>" +  getChannelStatus(i) + "</a></td><td style='width:180px;overflow:hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:180px;overflow:hidden;'>" +  UpdatedArray[i] + "</a></td><td style='width:30px; max-width:30px; max-height:20px; overflow: hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:30px; max-width:30px; max-height:20px; overflow:hidden;'><img onerror='this.style.display=`none`' src='" + getCountryFlag(CountriesArray[i]) + "' style='border: 0px solid #fff;width:30px; max-width:30px; max-height:20px;'></td><td style='width:200px;overflow:auto;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:200px;overflow:auto;'>" +  getFullCountryName(CountriesArray[i]) + getLanguage(LangArray[i]) + "</a></td><td style='width:200px;overflow:hidden;'><a href=# id=" + i + " onclick='GetChannelInfo(this)' ondblclick='PlayChannelIndex("+i+")' style='width:200px;overflow:hidden;'>" +  CategoriesArray[i].replaceAll(' ','').replaceAll(';','; ') + "</a></td><td style='display:none;'><a>"+i+"</a></td></tr></table>";
            newDiv.id="container";
            newDiv.className="containerClass";
            document.getElementById("ChannelDropdown").appendChild(newDiv);
         }
         document.getElementById("SearchInput").value = window.localStorage.getItem("SearchInput");
         document.getElementById("removetext").value = window.localStorage.getItem("removetext");
         document.getElementById("ChannelDropdown").style.height = '' + window.innerHeight - document.getElementById("ChannelDropdown").offsetTop - 10 + 'px';

         SortTable(SortColumnStore, SortDirectionStore);
         filterFunction();
         document.getElementById('export').addEventListener('click', function () {ExportM3U();});
      }
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
</script>
</head>
<body>
<h3 id='h2'  style='height:5px'>Поиск трансляций AceStream</h2>
<form>
<input type="text" id="searchtext" name="searchtext" placeholder="Строка поиска с разделителями ','" style='border: 1px solid #000;width:300px; border-radius: 3px;'>
<input type="button" id="searchbutton"  value="Поиск" style='width: 100px'><br>
<div style = 'float:left;'>
      <fieldset style="border: 1px solid #000;width:275px; border-radius: 3px;">
      <legend>Формат ссылок в плейлисте:</legend>
      <input type="radio" id="infohash_ref" name="play_ref_type" value=1>
      <label for="infohash_ref">infohash</label><br>
      <input type="radio" id="contentid_ref" name="play_ref_type" value=2>
      <label for="contentid_ref">content id</label><br>
      <input type="radio" id="acecast_ref" name="play_ref_type" value=3>
      <label for="acecast_ref">acestream://</label><br>
      <hr>
      <input type="checkbox" id="ChIcons"/>
      <label for="ChIcons">иконки каналов &nbsp</label><select size="1" name="iconType" id='MaxLogoTypeValue'>
   <option value=1>тип 1</option>
   <option value=2>тип 2</option>
   <option value=3>тип 3</option>
   </select>
<br>
      <input type="checkbox" id="ChCategories"/>
      <label for="ChCategories">категории каналов</label>
      </fieldset>
</div>
<div id='infobox'>
</div>
<br style='clear:both;'><br>
<label for="EngineURL">URL движка: </label>
<input type="text" id="EngineURL"  placeholder="127.0.0.1:6878 (по умолчанию)" style='border: 1px solid #000;width:200px; border-radius: 3px;'/><br>
<input type="checkbox" id="AutoStart"/>
<label for="AutoStart">автостарт</label><br>
<input type="checkbox" id="AutoExit"/>
<label for="AutoExit">автозавершение с экспортом</label><br>
<label id="InfoLabel">Ожидание действия...</label><br>
<div id='result'></div>
</form>
</body>
</html>

Всем добра :D
Научились ли Вы радоваться трудностям?


Вернуться в Наши проекты

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1

    TopList