Skip to content

Commit 8044491

Browse files
committedDec 16, 2024
generateUrls
1 parent 6c5fd33 commit 8044491

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed
 

‎js/m3u8.js

+22-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,27 @@ function init() {
154154

155155
if (isEmpty(_m3u8Url)) {
156156
$("#loading").hide(); $("#m3u8Custom").show();
157+
158+
// 批量生成切片链接
159+
$("#generateUrls").change(function () {
160+
const rangePattern = /\$\{range:(\d+)-(\d+),?(\d+)?\}/;
161+
const text = $(this).val();
162+
const match = text.match(rangePattern);
163+
if (match) {
164+
const start = parseInt(match[1]);
165+
const end = parseInt(match[2]);
166+
const padding = match[3] ? parseInt(match[3]) : 0;
167+
const urls = [];
168+
for (let i = start; i <= end; i++) {
169+
let number = i.toString();
170+
if (padding > 0) {
171+
number = number.padStart(padding, '0');
172+
}
173+
urls.push(text.replace(rangePattern, number));
174+
}
175+
$("#m3u8Text").val(urls.join("\n"));
176+
}
177+
});
157178
$("#parse").click(function () {
158179
let m3u8Text = $("#m3u8Text").val().trim();
159180
let baseUrl = $("#baseUrl").val().trim();
@@ -194,7 +215,7 @@ function init() {
194215
const getId = parseInt(params.get("getId"));
195216
if (getId) {
196217
chrome.tabs.sendMessage(getId, "getM3u8", function (result) {
197-
$("#m3u8Text").html(result.m3u8Content);
218+
$("#m3u8Text").val(result.m3u8Content);
198219
$("#parse").click();
199220
$("#info").html(result.mediaInfo);
200221
});

‎m3u8.html

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ <h1 class="optionsTitle" data-i18n="titleM3U8"></h1>
2727
class="width100"></textarea>
2828
<input type="text" id="baseUrl" placeholder="BaseURL" class="fullInput" />
2929
<div class="line"></div>
30+
<input type="text" id="generateUrls" placeholder="https://bmmmd.com/${range:1-5}.ts" class="fullInput" />
31+
<div class="line"></div>
3032
<input type="text" id="m3u8Url" placeholder="m3u8 URL" class="fullInput" />
3133
<div class="line"></div>
3234
<input type="text" id="referer" placeholder="Referer" class="fullInput" />

0 commit comments

Comments
 (0)
Please sign in to comment.