Skip to content

Commit d239210

Browse files
committed
Fix muted segments not loading
1 parent 0769bb7 commit d239210

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

firefox-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "TwitchNoSub",
3-
"version": "0.6",
3+
"version": "0.6.1",
44
"description": "Show sub only VOD on Twitch",
55
"manifest_version": 2,
66
"icons": {

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "TwitchNoSub",
3-
"version": "0.6",
3+
"version": "0.6.1",
44
"description": "Show sub only VOD on Twitch",
55
"manifest_version": 3,
66
"icons": {

src/patched-amazon.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ const oldFetch = self.fetch;
2626
self.fetch = async function (url, opt) {
2727
let response = await oldFetch(url, opt);
2828

29+
// Patch playlist from unmuted to muted segments
30+
if (url.includes("cloudfront") && url.includes(".m3u8")) {
31+
const body = await response.text();
32+
33+
return new Response(body.replace(/-unmuted/g, "-muted"), { status: 200 });
34+
}
35+
2936
if (url.startsWith("https://usher.ttvnw.net/vod/")) {
3037
if (response.status != 200) {
3138
const vodId = url.split("https://usher.ttvnw.net/vod/")[1].split(".m3u8")[0];
@@ -37,9 +44,6 @@ self.fetch = async function (url, opt) {
3744
});
3845
}
3946

40-
// Muted segement are not supported for now
41-
const isMuted = data.muted_segments != undefined && data.muted_segments.length > 0;
42-
4347
let resolutions = data.resolutions;
4448

4549
let sorted_dict = Object.keys(resolutions);
@@ -68,14 +72,8 @@ self.fetch = async function (url, opt) {
6872
switch (data.broadcast_type) {
6973
case "highlight":
7074
for ([resKey, resValue] of Object.entries(resolutions)) {
71-
let link = `https://${domain}/${vodSpecialID}/${resKey}/highlight-${vodId}.m3u8`;
72-
73-
/*if (isMuted) {
74-
link = await patchUnmutedPlaylist(`https://${domain}/${vodSpecialID}/${resKey}/`, link, vodSpecialID, resKey);
75-
}*/
76-
7775
sources_.push({
78-
src: link,
76+
src: `https://${domain}/${vodSpecialID}/${resKey}/highlight-${vodId}.m3u8`,
7977
quality: resKey,
8078
resolution: resValue,
8179
fps: Math.ceil(data.fps[resKey]),
@@ -86,14 +84,8 @@ self.fetch = async function (url, opt) {
8684
break;
8785
case "upload":
8886
for ([resKey, resValue] of Object.entries(resolutions)) {
89-
let link = `https://${domain}/${data.channel.name}/${vodId}/${vodSpecialID}/${resKey}/index-dvr.m3u8`;
90-
91-
/*if (isMuted) {
92-
link = await patchUnmutedPlaylist(`https://${domain}/${data.channel.name}/${vodId}/${vodSpecialID}/${resKey}/`, link, vodSpecialID, resKey);
93-
}*/
94-
9587
sources_.push({
96-
src: link,
88+
src: `https://${domain}/${data.channel.name}/${vodId}/${vodSpecialID}/${resKey}/index-dvr.m3u8`,
9789
quality: resKey,
9890
resolution: resValue,
9991
fps: Math.ceil(data.fps[resKey]),
@@ -104,14 +96,8 @@ self.fetch = async function (url, opt) {
10496
break;
10597
default:
10698
for ([resKey, resValue] of Object.entries(resolutions)) {
107-
let link = `https://${domain}/${vodSpecialID}/${resKey}/index-dvr.m3u8`;
108-
109-
/*if (isMuted) {
110-
link = await patchUnmutedPlaylist(`https://${domain}/${vodSpecialID}/${resKey}/`, link, vodSpecialID, resKey);
111-
}*/
112-
11399
sources_.push({
114-
src: link,
100+
src: `https://${domain}/${vodSpecialID}/${resKey}/index-dvr.m3u8`,
115101
quality: resKey,
116102
resolution: resValue,
117103
fps: Math.ceil(data.fps[resKey]),

0 commit comments

Comments
 (0)