Skip to content

Commit

Permalink
perf ⚡ : update proxy for tvg-logo
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertHe committed Jan 16, 2024
1 parent e8728dc commit 8479601
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/sources/iptv_org.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { is_filted_channels } from "../utils"
import { converter, handle_m3u } from "./utils"
import type { TSources } from "./utils"

Expand All @@ -15,7 +16,7 @@ export const iptv_org_filter = (raw: string): [string, number] => {
const invalid = invalidExp.test(rawArray[i + 1])

if (!!reg && !invalid) {
if (["ABNChina.us", "NTDTVChina.us"].includes(reg[1].trim())) {
if (is_filted_channels(reg[1].trim())) {
i += 2
continue
} else if (!sourced.includes(reg[1]) || !reg[1]) {
Expand Down Expand Up @@ -67,9 +68,7 @@ export const iptv_org_stream_filter = (raw: string): [string, number] => {
)
result.push(rawArray[i + 1])
}
} else if (
["ABNChina.us", "NTDTVChina.us"].includes(reg[1].trim())
) {
} else if (is_filted_channels(reg[1].trim())) {
i += 2
continue
} else if (!sourced.includes(reg[1])) {
Expand Down
3 changes: 2 additions & 1 deletion src/sources/yang_m3u.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { replace_github_raw_proxy_url } from "../utils"
import { handle_m3u, type TSources } from "./utils"

export const yang_m3u_filter = (raw: string): [string, number] => {
const rawArray = handle_m3u(raw)
const rawArray = handle_m3u(replace_github_raw_proxy_url(raw))

return [rawArray.join("\n"), (rawArray.length - 1) / 2]
}
Expand Down
3 changes: 2 additions & 1 deletion src/sources/yuechan_live.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { replace_github_raw_proxy_url } from "../utils"
import { handle_m3u, type TSources } from "./utils"

export const yuechan_live_filter = (raw: string): [string, number] => {
const rawArray = handle_m3u(raw)
const rawArray = handle_m3u(replace_github_raw_proxy_url(raw))

return [rawArray.join("\n"), (rawArray.length - 1) / 2]
}
Expand Down
12 changes: 12 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,15 @@ export const get_github_raw_proxy_url = () => {
const custom = process.env.CUSTOM_GITHUB_RAW_SOURCE_PROXY_URL
return !!custom ? custom : `https://ghproxy.net`
}

export const replace_github_raw_proxy_url = (s: string) => {
const proxy_url = get_github_raw_proxy_url()
return s.replace(
/tvg\-logo="https:\/\/raw\.githubusercontent\.com\//g,
`tvg-logo="${proxy_url}/https://raw.githubusercontent.com/`
)
}

export const is_filted_channels = (s: string) => {
return ["ABNChina.us", "NTDTVChina.us"].includes(s)
}

0 comments on commit 8479601

Please sign in to comment.