Manual channel curation and fuzzy channel searching #1
@@ -1,4 +1,4 @@
|
||||
export async function GET(request: Request) {
|
||||
export async function GET() {
|
||||
return new Response('OK', {
|
||||
status: 200,
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { manualNameToIdMappings } from "@/utils/constants"
|
||||
import { debugLog } from "@/utils/debugLog"
|
||||
import { NextRequest } from "next/server"
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
export async function GET() {
|
||||
const response = await fetch(`https://sdlive-1-internal.d-ho.me/playlist.m3u8`)
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -46,24 +46,26 @@ export async function GET(request: NextRequest) {
|
||||
else return false
|
||||
})
|
||||
|
||||
const url = new URL(request.url)
|
||||
const baseUrl = `${url.protocol}//${url.host}`
|
||||
// const url = new URL(request.url)
|
||||
// const baseUrl = `${url.protocol}//${url.host}`
|
||||
|
||||
const nameToIDMap: Record<string, string> = {}
|
||||
await Promise.all(filteredChannels.map(async channelName => {
|
||||
const country = channelName.endsWith("USA")
|
||||
? "US" :
|
||||
channelName.endsWith("CA") || channelName.endsWith("Canada")
|
||||
? "CA" :
|
||||
channelName.endsWith("UK")
|
||||
? "UK" :
|
||||
null
|
||||
// const nameToIDMap: Record<string, string> = {}
|
||||
// await Promise.all(filteredChannels.map(async channelName => {
|
||||
// const country = channelName.endsWith("USA")
|
||||
// ? "US" :
|
||||
// channelName.endsWith("CA") || channelName.endsWith("Canada")
|
||||
// ? "CA" :
|
||||
// channelName.endsWith("UK")
|
||||
// ? "UK" :
|
||||
// null
|
||||
|
||||
const response = await fetch(`${baseUrl}/iptv/channel?name=${encodeURIComponent(channelName)}${country ? `&country=${country}` : ""}`)
|
||||
const channelInfo = await response.json()
|
||||
const foundId: string = channelInfo[0].item.id
|
||||
nameToIDMap[channelName] = foundId
|
||||
}))
|
||||
// const response = await fetch(`${baseUrl}/iptv/channel?name=${encodeURIComponent(channelName)}${country ? `&country=${country}` : ""}`)
|
||||
// const channelInfo = await response.json()
|
||||
// const foundId: string = channelInfo.id
|
||||
// nameToIDMap[channelName] = foundId
|
||||
// }))
|
||||
|
||||
const nameToIDMap = filteredChannels.map(channelName => `${channelName} => ${manualNameToIdMappings[channelName]}`)
|
||||
|
||||
return new Response(JSON.stringify(nameToIDMap), {
|
||||
headers: {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { NextRequest } from "next/server"
|
||||
import Fuse from "fuse.js"
|
||||
import { debugLog } from "@/utils/debugLog";
|
||||
import { manualNameToIdMappings } from "@/utils/constants";
|
||||
|
||||
type ChannelInfo = {
|
||||
id: string,
|
||||
@@ -19,42 +20,8 @@ type ChannelInfo = {
|
||||
website: string | null
|
||||
}
|
||||
|
||||
const manualNameToIdMappings: Record<string, string> = {
|
||||
// "5 USA": "5USA.uk",
|
||||
// "Oxygen True Crime": "TrueCrime.uk",
|
||||
// "CBC CA": "CBAFTDT.ca",
|
||||
// "CMT USA": "CMTMusic.us",
|
||||
// "Sportsnet West": "SportsnetWorld.ca",
|
||||
// "Sportsnet East": "Sportsnet.ca",
|
||||
// "Fox Sports 1 USA": "FoxSports2LatinAmerica.us",
|
||||
// "BET USA": "IBTVUSA.us",
|
||||
// "FOXNY USA": "FoxBusinessNetwork.us",
|
||||
// "CBSNY USA": "CBNEspanol.us",
|
||||
// "ABCNY USA": "MBC1USA.us",
|
||||
// "Nat Geo Wild USA": "NatGeoKidsLatinAmerica.us",
|
||||
// "CTV 2 Canada": "GTNCanada.ca",
|
||||
// "AMC USA": "AMCRush.us",
|
||||
// "ESPN USA": "ESPN3LatinAmerica.us",
|
||||
// "MTV USA": "IBTVUSA.us",
|
||||
// "IFC TV USA": "IndTVUSA.us",
|
||||
// "FOX USA": "FoxBusinessNetwork.us",
|
||||
// "Sportsnet Ontario": "SportsnetOne.ca",
|
||||
// "NBCNY USA": "MBC1USA.us",
|
||||
// "Showtime SHOxBET USA": "ShowtimeShowcase.us",
|
||||
// "ESPN2 USA": "ESPN3LatinAmerica.us",
|
||||
// "MY9TV USA": "MMCTVUSA.us",
|
||||
// "MAVTV USA": "MMCTVUSA.us",
|
||||
// "CW USA": "WUSADT1.us",
|
||||
// "Discovery Life Channel": "DiscoveryChannel.ca",
|
||||
// "The Food Network": "TheWordNetwork.us",
|
||||
// "WETV USA": "IBTVUSA.us",
|
||||
// "ION USA": "HmongUSATV.us",
|
||||
// "CTV Canada": "GTNCanada.ca",
|
||||
|
||||
}
|
||||
|
||||
let memoChannelData: ChannelInfo[] | null = null;
|
||||
let memoFuses: Record<string, Fuse<ChannelInfo>> = {}
|
||||
const memoFuses: Record<string, Fuse<ChannelInfo>> = {}
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
|
||||
@@ -70,6 +37,8 @@ export async function GET(request: NextRequest) {
|
||||
const channelData = memoChannelData || (await (await fetch("https://iptv-org.github.io/api/channels.json")).json() as ChannelInfo[])
|
||||
memoChannelData = channelData
|
||||
|
||||
debugLog(name)
|
||||
|
||||
// Skip logic for manual mappings
|
||||
if (manualNameToIdMappings[name]) {
|
||||
const manualId = manualNameToIdMappings[name]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { manualNameToIdMappings } from "@/utils/constants"
|
||||
import { debugLog } from "@/utils/debugLog"
|
||||
import { NextRequest } from "next/server"
|
||||
|
||||
@@ -50,7 +51,10 @@ export async function GET(request: NextRequest) {
|
||||
return new Response("Internal Server Error", { status: 500 })
|
||||
}
|
||||
|
||||
const newInfo = `#EXTINF:-1 tvg-id="${sdliveChannelNum}.sdlive" ${afterExtInf}`
|
||||
const channelName = info.split(",").at(-1) ?? ""
|
||||
const tvgid = manualNameToIdMappings[channelName]
|
||||
|
||||
const newInfo = `#EXTINF:-1 ${tvgid ? `tvg-id="${tvgid}" tvg-group="dhome-curated"` : `tvg-id="${sdliveChannelNum}.sdlive"`} sdlive-id="${sdliveChannelNum}.sdlive" ${afterExtInf}`
|
||||
|
||||
newLines.push(newInfo, streamURL)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
export const manualNameToIdMappings: Record<string, string> = {
|
||||
"5 USA": "5USA.uk",
|
||||
"A&E USA": "AE.us",
|
||||
"ABC USA": "ABC.us",
|
||||
"ABCNY USA": "ABC.us",
|
||||
"ACC Network USA": "ACCNetwork.us",
|
||||
"AMC USA": "AMC.us",
|
||||
"AXS TV USA": "AXSTV.us",
|
||||
"BBC America (BBCA)": "BBCAmerica.us",
|
||||
"BBC Four UK": "BBCFour.uk",
|
||||
"BBC One UK": "BBCOne.uk",
|
||||
"BBC Three UK": "BBCThree.uk",
|
||||
"BBC Two UK": "BBCTwo.uk",
|
||||
"BET USA": "BET.us",
|
||||
"BIG TEN Network (BTN USA)": "BigTenNetwork.us",
|
||||
"BeIN SPORTS USA": "beINSportsUSA.us",
|
||||
"Bravo USA": "Bravo.us",
|
||||
"CBC CA": "CBLTDT.ca",
|
||||
"CBS Sports Network (CBSSN)": "CBSSportsNetworkCanada.ca",
|
||||
"CBS USA": "CBS.us",
|
||||
"CBSNY USA": "CBS.us",
|
||||
"CMT USA": "CMT.us",
|
||||
"CNBC USA": "CNBC.us",
|
||||
"CNN USA": "CNN.us",
|
||||
"COZI TV USA": "CoziTV.us",
|
||||
"CTV 2 Canada": "CHCJDT.ca",
|
||||
"CTV Canada": "CFTODT.ca",
|
||||
"CW USA": "CW.us",
|
||||
"Cinemax USA": "Cinemax.us",
|
||||
"Comet USA": "Comet.us",
|
||||
"Cooking Channel USA": "CookingChannel.us",
|
||||
"Crime+ Investigation USA": "CrimePlusInvestigation.us",
|
||||
"Discovery Channel": "DiscoveryChannel.ca",
|
||||
"Discovery Family": "DiscoveryFamily.us",
|
||||
"Discovery Life Channel": "DiscoveryLife.us",
|
||||
"E! Entertainment Television": "E.us",
|
||||
"ESPN USA": "ESPN.us",
|
||||
"ESPN2 USA": "ESPN2.us",
|
||||
"ESPNU USA": "ESPNU.us",
|
||||
"FOX Deportes USA": "FoxDeportes.us",
|
||||
"FOX USA": "Fox.us",
|
||||
"FOXNY USA": "Fox.us",
|
||||
"FX Movie Channel": "FXMovieChannel.us",
|
||||
"FX USA": "FX.us",
|
||||
"FXX USA": "FXX.us",
|
||||
"FYI": "FYI.us",
|
||||
"Fox News": "FoxNewsChannel.us",
|
||||
"Fox Sports 1 USA": "FoxSports1.us",
|
||||
"Fox Sports 2 USA": "FoxSports2.us",
|
||||
"Freeform": "Freeform.us",
|
||||
"GOLF Channel USA": "GolfChannel.us",
|
||||
"Galavisi贸n USA": "Galavision.us",
|
||||
"Game Show Network": "GameShowNetwork.us",
|
||||
"Global CA": "CIIIDT.ca",
|
||||
"HBO Comedy USA": "HBOComedy.us",
|
||||
"HBO Family USA": "HBOFamily.us",
|
||||
"HBO Latino USA": "HBOLatino.us",
|
||||
"HBO Signature USA": "HBOSignature.us",
|
||||
"HBO USA": "HBO.us",
|
||||
"HBO Zone USA": "HBOZone.us",
|
||||
"HBO2 USA": "HBO2.us",
|
||||
"HGTV": "HGTV.ca",
|
||||
"History USA": "History.us",
|
||||
"IFC TV USA": "IFC.us",
|
||||
"ION USA": "IONTV.us",
|
||||
"ITV 1 UK": "ITV1.uk",
|
||||
"ITV 2 UK": "ITV2.uk",
|
||||
"ITV 3 UK": "ITV3.uk",
|
||||
"ITV 4 UK": "ITV4.uk",
|
||||
"Investigation Discovery (ID USA)": "InvestigationDiscovery.us",
|
||||
"Longhorn Network USA": "LonghornNetwork.us",
|
||||
"MASN USA": "MASN.us",
|
||||
"MAVTV USA": "RacerNetwork.us",
|
||||
"METV USA": "MercedEducationalTV.us",
|
||||
"MLB Network USA": "MLBNetwork.us",
|
||||
"MSG USA": "MSG.us",
|
||||
"MTV USA": "MTV.us",
|
||||
"MY9TV USA": "WWORDT1.us",
|
||||
"NBA TV USA": "NBATV.us",
|
||||
"NBC USA": "NBC.us",
|
||||
"NBCNY USA": "NBC.us",
|
||||
"NESN USA": "NESN.us",
|
||||
"NHL Network USA": "NHLNetwork.us",
|
||||
"NICK": "Nickelodeon.us",
|
||||
"Nat Geo Wild USA": "NationalGeographicWild.us",
|
||||
"NewsNation USA": "NewsNation.us",
|
||||
"Newsmax USA": "NewsmaxTV.us",
|
||||
"Oprah Winfrey Network (OWN)": "OWN.ca",
|
||||
"Oxygen True Crime": "Oxygen.us",
|
||||
"POP TV USA": "PopTV.us",
|
||||
"Paramount Network": "ParamountNetwork.us",
|
||||
"RDS 2 CA": "RDS2.ca",
|
||||
"RDS CA": "RDS.ca",
|
||||
"SEC Network USA": "SECNetwork.us",
|
||||
"SYFY USA": "Syfy.us",
|
||||
"Showtime SHOxBET USA": "ShoxBet.us",
|
||||
"Showtime USA": "Showtime.us",
|
||||
"Sportsnet 360": "Sportsnet360.ca",
|
||||
"Sportsnet East": "Sportsnet.ca",
|
||||
"Sportsnet One": "SportsnetOne.ca",
|
||||
"Sportsnet Ontario": "SportsnetOntario.ca",
|
||||
"Sportsnet West": "SportsnetWest.ca",
|
||||
"Sportsnet World": "SportsnetWorld.ca",
|
||||
"TBS USA": "TBS.us",
|
||||
"TCM USA": "TCM.us",
|
||||
"TMC Channel USA": "TheMovieChannel.us",
|
||||
"TNT USA": "TNT.us",
|
||||
"TSN1": "TSN1.ca",
|
||||
"TSN2": "TSN2.ca",
|
||||
"TSN3": "TSN3.ca",
|
||||
"TSN4": "TSN4.ca",
|
||||
"TSN5": "TSN5.ca",
|
||||
"TUDN USA": "TUDN.us",
|
||||
"TV ONE USA": "TVOne.us",
|
||||
"The Food Network": "FoodNetwork.us",
|
||||
"The Hallmark Channel": "HallmarkChannel.us",
|
||||
"The Weather Channel": "TheWeatherChannel.us",
|
||||
"TruTV USA": "truTV.us",
|
||||
"USA Network": "USANetwork.us",
|
||||
"Universal Kids USA": "UniversalKids.us",
|
||||
"VH1 USA": "VH1.us",
|
||||
"VICE TV": "VICETV.us",
|
||||
"WETV USA": "WeTV.us",
|
||||
"WWE Network": "WWENetwork.ca",
|
||||
"YES Network USA": "YesNetwork.us"
|
||||
}
|
||||
Reference in New Issue
Block a user