mirror of
https://github.com/iptv-org/iptv-org.github.io.git
synced 2025-05-11 01:20:06 -04:00
1 line
4.1 KiB
JavaScript
1 line
4.1 KiB
JavaScript
var b=Object.defineProperty;var g=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var p=(t,e,s)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,h=(t,e)=>{for(var s in e||(e={}))_.call(e,s)&&p(t,s,e[s]);if(g)for(var s of g(e))w.call(e,s)&&p(t,s,e[s]);return t};import{D as l,X as f,_ as i,Y as m}from"./vendor-be4ac25a.js";const A=l(""),d=l(!1),c=l([]),v=l({}),u=l([]);function I(t){const e=t.toLowerCase().match(/(".*?"|[^"\s]+)+(?=\s*|\s*$)/g)||[],s=[];for(let n of e){let o="_key";if(n.includes(":")&&([o,n]=n.split(":")),n=n.replace(/\"/g,""),o&&n){let r=["streams","guides"].includes(o);s.push({field:o,numerical:r,value:n})}}if(!s.length){d.set(!1),u.set(f(c));return}const a=f(c).filter(n=>{let o=[];for(let r of s){if(!r.value)return!1;if(r.numerical)r.value.startsWith("<")?o.push(n._searchable[r.field]<parseInt(r.value.replace("<",""))):r.value.startsWith(">")?o.push(n._searchable[r.field]>parseInt(r.value.replace(">",""))):o.push(n._searchable[r.field]===parseInt(r.value));else{const y=new RegExp(r.value.replaceAll(",","|"),"i");o.push(y.test(n._searchable[r.field]))}}return o.every(Boolean)});u.set(a),d.set(!0),console.log(".")}async function L(){const t=await $();v.set(t.countries);let e=t.channels.map(s=>(s._raw=k(s),s._streams=t.streams[s.id]||[],s._guides=t.guides[s.id]||[],s._country=t.countries[s.country],s._subdivision=t.subdivisions[s.subdivision],s._languages=s.languages.map(a=>t.languages[a]).filter(a=>a),s._categories=s.categories.map(a=>t.categories[a]).filter(a=>a),s._broadcast_area=s.broadcast_area.map(a=>{const[n,o]=a.split("/");switch(n){case"c":return h({type:n},t.countries[o]);case"r":return h({type:n},t.regions[o]);case"s":return h({type:n},t.subdivisions[o])}}),s._searchable=j(s),s));c.set(e),u.set(e)}function j(t){const e={};for(let s in t)s.startsWith("_")||(Array.isArray(t[s])?e[s]=t[s].map(a=>a.toString().toLowerCase()).join(","):e[s]=t[s]?t[s].toString().toLowerCase():"");return e.streams=t._streams.length,e.guides=t._guides.length,e.is=t.closed||t.replaced_by?"closed":"active",e._key=B(t),e}function B(t){const e=Object.values(i.pick(t,["id","name","alt_names","network","country","subdivision","city","broadcast_area","languages","categories","launched","closed","replaced_by"])),s=t.alt_names?m(t.alt_names):null;return[...e,s].map(a=>a||"").filter(a=>a).join("|").toLowerCase()}function k(t){return JSON.parse(JSON.stringify(t))}function q(t,e){if(window.history.pushState){let s=t&&e?`?${t}=${e}`:"";s=s.replace(/\+/g,"%2B");const a=`${window.location.protocol}//${window.location.host}${window.location.pathname}${s}`,n={};n[t]=e,window.history.pushState(n,"",a),S(e)}}function S(t){const e=t?`${t} \xB7 iptv-org`:"iptv-org";document.title=e}async function $(){const t={};return t.countries=await fetch("https://iptv-org.github.io/api/countries.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>e.map(s=>(s.expanded=!1,s))).then(e=>i.keyBy(e,"code")).catch(console.error),t.regions=await fetch("https://iptv-org.github.io/api/regions.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.keyBy(e,"code")).catch(console.error),t.subdivisions=await fetch("https://iptv-org.github.io/api/subdivisions.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.keyBy(e,"code")).catch(console.error),t.languages=await fetch("https://iptv-org.github.io/api/languages.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.keyBy(e,"code")).catch(console.error),t.categories=await fetch("https://iptv-org.github.io/api/categories.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.keyBy(e,"id")).catch(console.error),t.streams=await fetch("https://iptv-org.github.io/api/streams.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.groupBy(e,"channel")).catch(console.error),t.guides=await fetch("https://iptv-org.github.io/api/guides.json").then(e=>e.json()).then(e=>e.length?e:[]).then(e=>i.groupBy(e,"channel")).catch(console.error),t.channels=await fetch("https://iptv-org.github.io/api/channels.json").then(e=>e.json()).catch(e=>(console.error(e),[])),t}export{I as a,S as b,c,L as d,v as e,u as f,d as h,A as q,q as s};
|