@@ -26,6 +26,13 @@ const oldFetch = self.fetch;
26
26
self . fetch = async function ( url , opt ) {
27
27
let response = await oldFetch ( url , opt ) ;
28
28
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 ( / - u n m u t e d / g, "-muted" ) , { status : 200 } ) ;
34
+ }
35
+
29
36
if ( url . startsWith ( "https://usher.ttvnw.net/vod/" ) ) {
30
37
if ( response . status != 200 ) {
31
38
const vodId = url . split ( "https://usher.ttvnw.net/vod/" ) [ 1 ] . split ( ".m3u8" ) [ 0 ] ;
@@ -37,9 +44,6 @@ self.fetch = async function (url, opt) {
37
44
} ) ;
38
45
}
39
46
40
- // Muted segement are not supported for now
41
- const isMuted = data . muted_segments != undefined && data . muted_segments . length > 0 ;
42
-
43
47
let resolutions = data . resolutions ;
44
48
45
49
let sorted_dict = Object . keys ( resolutions ) ;
@@ -68,14 +72,8 @@ self.fetch = async function (url, opt) {
68
72
switch ( data . broadcast_type ) {
69
73
case "highlight" :
70
74
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
-
77
75
sources_ . push ( {
78
- src : link ,
76
+ src : `https:// ${ domain } / ${ vodSpecialID } / ${ resKey } /highlight- ${ vodId } .m3u8` ,
79
77
quality : resKey ,
80
78
resolution : resValue ,
81
79
fps : Math . ceil ( data . fps [ resKey ] ) ,
@@ -86,14 +84,8 @@ self.fetch = async function (url, opt) {
86
84
break ;
87
85
case "upload" :
88
86
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
-
95
87
sources_ . push ( {
96
- src : link ,
88
+ src : `https:// ${ domain } / ${ data . channel . name } / ${ vodId } / ${ vodSpecialID } / ${ resKey } /index-dvr.m3u8` ,
97
89
quality : resKey ,
98
90
resolution : resValue ,
99
91
fps : Math . ceil ( data . fps [ resKey ] ) ,
@@ -104,14 +96,8 @@ self.fetch = async function (url, opt) {
104
96
break ;
105
97
default :
106
98
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
-
113
99
sources_ . push ( {
114
- src : link ,
100
+ src : `https:// ${ domain } / ${ vodSpecialID } / ${ resKey } /index-dvr.m3u8` ,
115
101
quality : resKey ,
116
102
resolution : resValue ,
117
103
fps : Math . ceil ( data . fps [ resKey ] ) ,
0 commit comments