Skip to content

Commit

Permalink
fix m3u parse bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed May 18, 2024
1 parent 6ea9c7b commit 8ad2e65
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions assets/channels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
我的視頻,#genre#
尼亚加拉瀑布,https://cdn.pixabay.com/video/2019/11/04/28707-371213524_large.mp4
4 changes: 2 additions & 2 deletions statics/mytv/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ <h1>我的电视·服务</h1>
</div>

<div id="message2" class="message hide">
<pre>,#genre#
标题,index.m3u8</pre>
<pre>组名,#genre#
标题,视频地址</pre>
</div>

<div id="message3" class="message hide">
Expand Down
12 changes: 9 additions & 3 deletions statics/mytv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,17 @@ const read = async (file, extension) => {
line = line.trim();
if (line.startsWith('#EXTINF')) {
const infos = line.split(',');
const title = infos.pop()
const title = infos.pop();

const nameMatchResult = infos[0]?.match(nameRegex);
const name = nameMatchResult ? nameMatchResult[1] : '';

const logoMatchResult = infos[0]?.match(logRegex);
const logo = logoMatchResult ? logoMatchResult[1] : '';
list.push({
name: infos[0]?.match(nameRegex)[1],
name: name,
group: infos[0]?.match(groupRegex)[1],
logo: infos[0]?.match(logRegex)[1],
logo: logo,
title: title,
uris: [lines[lines.indexOf(line) + 1]]
})
Expand Down

0 comments on commit 8ad2e65

Please sign in to comment.