@vyla-entertainment/sdk 1.14.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sources/vixsrc.js +37 -35
package/package.json
CHANGED
package/src/sources/vixsrc.js
CHANGED
|
@@ -52,8 +52,8 @@ export async function getStream({ id, s, e, absoluteBase }) {
|
|
|
52
52
|
playlist = `${BASE_URL}${playlist}`;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const
|
|
56
|
-
const rawMasterUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${
|
|
55
|
+
const defaultLang = extract(/lang(?:uage)?["']\s*:\s*["']([a-z]{2,5})/i, html) || 'en';
|
|
56
|
+
const rawMasterUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${defaultLang}`;
|
|
57
57
|
|
|
58
58
|
const masterProxy = absoluteBase && absoluteBase !== '/'
|
|
59
59
|
? `${absoluteBase.replace(/^https:\/\/(localhost|127\.0\.0\.1)/, 'http://$1')}/api?url=${encodeURIComponent(rawMasterUrl)}&proxyHeaders=${encodeURIComponent(JSON.stringify({ ...HEADERS, Referer: embedUrl }))}`
|
|
@@ -62,50 +62,52 @@ export async function getStream({ id, s, e, absoluteBase }) {
|
|
|
62
62
|
const playlistText = await fetchText(masterProxy, { headers: { ...HEADERS, 'Referer': embedUrl } }).catch(() => null);
|
|
63
63
|
if (!playlistText?.includes('#EXTM3U')) return null;
|
|
64
64
|
|
|
65
|
-
let finalUrl = null;
|
|
66
|
-
let bestHeight = 0;
|
|
67
65
|
const lines = playlistText.split('\n');
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
66
|
+
const audioTracks = [];
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
|
|
69
|
+
for (const line of lines) {
|
|
70
|
+
if (line.startsWith('#EXT-X-MEDIA') && line.includes('TYPE=AUDIO')) {
|
|
71
|
+
const name = line.match(/NAME=["']([^"']+)["']/)?.[1] || 'Default';
|
|
72
|
+
const rendition = line.match(/rendition=([a-zA-Z0-9_-]+)/)?.[1]
|
|
73
|
+
|| line.match(/LANGUAGE=["']([^"']+)["']/)?.[1]
|
|
74
|
+
|| name;
|
|
75
|
+
const key = rendition.toLowerCase();
|
|
76
|
+
if (!seen.has(key)) {
|
|
77
|
+
seen.add(key);
|
|
78
|
+
audioTracks.push({ name, lang: rendition });
|
|
79
|
+
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!finalUrl.startsWith('http')) {
|
|
85
|
-
const baseMatch = rawMasterUrl.match(/^(https?:\/\/[^\/]+)/);
|
|
86
|
-
const base = baseMatch ? baseMatch[1] : BASE_URL;
|
|
87
|
-
if (finalUrl.startsWith('/')) {
|
|
88
|
-
finalUrl = `${base}${finalUrl}`;
|
|
89
|
-
} else {
|
|
90
|
-
const pathParts = rawMasterUrl.split('/');
|
|
91
|
-
pathParts.pop();
|
|
92
|
-
finalUrl = `${pathParts.join('/')}/${finalUrl}`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
83
|
+
const allUrls = [];
|
|
95
84
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
|
|
85
|
+
if (audioTracks.length > 0) {
|
|
86
|
+
for (const track of audioTracks) {
|
|
87
|
+
const streamUrl = `${playlist}${playlist.includes('?') ? '&' : '?'}token=${token}&expires=${expires}&h=1&lang=${track.lang}`;
|
|
88
|
+
allUrls.push({
|
|
89
|
+
url: streamUrl,
|
|
90
|
+
server: `VixSrc (${track.name})`,
|
|
101
91
|
skipProxy: true,
|
|
102
92
|
headers: {
|
|
103
93
|
...HEADERS,
|
|
104
94
|
'Referer': `${BASE_URL}/`
|
|
105
95
|
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
allUrls.push({
|
|
100
|
+
url: rawMasterUrl,
|
|
101
|
+
server: 'VixSrc',
|
|
102
|
+
skipProxy: true,
|
|
103
|
+
headers: {
|
|
104
|
+
...HEADERS,
|
|
105
|
+
'Referer': `${BASE_URL}/`
|
|
106
106
|
}
|
|
107
|
-
|
|
108
|
-
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { allUrls };
|
|
109
111
|
} catch (err) {
|
|
110
112
|
return null;
|
|
111
113
|
}
|