feat ✨ : from info
This commit is contained in:
parent
5ffbbff726
commit
8e7f4af834
|
@ -1,5 +1,5 @@
|
|||
<!-- list_title_here -->
|
||||
|
||||
| No. | Channel Name | Source |
|
||||
| --- | ------------ | --- |
|
||||
| No. | Channel Name | From | Source |
|
||||
| --- | ------------ | ---- | ------ |
|
||||
<!-- channels_here -->
|
||||
|
|
|
@ -3,6 +3,7 @@ import path from "path"
|
|||
|
||||
import { handle_m3u } from "./sources"
|
||||
import type { TEPGSource } from "./epgs/utils"
|
||||
import { get_from_info } from "./utils"
|
||||
|
||||
export interface IREADMESource {
|
||||
name: string
|
||||
|
@ -28,7 +29,11 @@ export const updateChannelList = (
|
|||
let channels: Array<string>[] = []
|
||||
while (i < m3uArray.length) {
|
||||
const reg = channelRegExp.exec(m3uArray[i]) as RegExpExecArray
|
||||
channels.push([reg[2].replace(/\|/g, "").trim(), m3uArray[i + 1]])
|
||||
channels.push([
|
||||
reg[2].replace(/\|/g, "").trim(),
|
||||
get_from_info(m3uArray[i + 1]),
|
||||
m3uArray[i + 1],
|
||||
])
|
||||
i += 2
|
||||
}
|
||||
|
||||
|
@ -44,7 +49,9 @@ export const updateChannelList = (
|
|||
`${channels
|
||||
?.map(
|
||||
(c, idx) =>
|
||||
`| ${idx + 1} | ${c[0].replace("|", "")} | <${c[1]}> |`
|
||||
`| ${idx + 1} | ${c[0].replace("|", "")} | ${c[1]} | <${
|
||||
c[2]
|
||||
}> |`
|
||||
)
|
||||
.join("\n")}\n\nUpdated at **${new Date()}**`
|
||||
)
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
const from_infos = new Map([
|
||||
["sn.chinamobile.com", "中国移动陕西"],
|
||||
["sh.chinamobile.com", "中国移动上海"],
|
||||
["hl.chinamobile.com", "中国移动黑龙江"],
|
||||
["cztv.com", "浙江广播电视集团"],
|
||||
["mobaibox.com", "中国移动江苏"],
|
||||
["cgtn.com", "CGTN"],
|
||||
["cctv.com", "CCTV"],
|
||||
])
|
||||
|
||||
export const get_from_info = (url: string) => {
|
||||
for (const [k, v] of from_infos) {
|
||||
if (url.includes(k)) {
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
const hostRegExp = /([^:]+):\/\/([^/]+)/
|
||||
|
||||
return hostRegExp.exec(url)![2]
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
export * from "./handlers"
|
||||
export * from "./const"
|
||||
export * from "./logo"
|
||||
export * from "./from"
|
Loading…
Reference in New Issue