mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 18:13:25 +00:00
refactor: use parse-hls
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
"@movie-web/eslint-config": "workspace:^0.2.0",
|
||||
"@movie-web/prettier-config": "workspace:^0.1.0",
|
||||
"@movie-web/tsconfig": "workspace:^0.1.0",
|
||||
"@types/hls-parser": "^0.8.7",
|
||||
"eslint": "^8.56.0",
|
||||
"prettier": "^3.1.1",
|
||||
"typescript": "^5.3.3"
|
||||
@@ -31,7 +30,7 @@
|
||||
"prettier": "@movie-web/prettier-config",
|
||||
"dependencies": {
|
||||
"@movie-web/providers": "^2.2.0",
|
||||
"hls-parser": "^0.10.8",
|
||||
"parse-hls": "^1.0.7",
|
||||
"srt-webvtt": "^2.0.0",
|
||||
"tmdb-ts": "^1.6.1"
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { parse, types } from "hls-parser";
|
||||
import hls from "parse-hls";
|
||||
import { default as toWebVTT } from "srt-webvtt";
|
||||
|
||||
import type {
|
||||
@@ -113,18 +113,12 @@ export async function extractTracksFromHLS(
|
||||
const response = await fetch(playlistUrl, { headers }).then((res) =>
|
||||
res.text(),
|
||||
);
|
||||
const playlist = parse(response);
|
||||
if (!playlist.isMasterPlaylist) return null;
|
||||
if (!(playlist instanceof types.MasterPlaylist)) return null;
|
||||
|
||||
const tracks = playlist.variants.map((variant) => {
|
||||
const playlist = hls.parse(response);
|
||||
return {
|
||||
video: variant.video,
|
||||
audio: variant.audio,
|
||||
subtitles: variant.subtitles,
|
||||
video: playlist.streamRenditions,
|
||||
audio: playlist.audioRenditions,
|
||||
subtitles: playlist.subtitlesRenditions,
|
||||
};
|
||||
});
|
||||
return tracks;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
23
pnpm-lock.yaml
generated
23
pnpm-lock.yaml
generated
@@ -182,9 +182,9 @@ importers:
|
||||
'@movie-web/providers':
|
||||
specifier: ^2.2.0
|
||||
version: 2.2.0
|
||||
hls-parser:
|
||||
specifier: ^0.10.8
|
||||
version: 0.10.8
|
||||
parse-hls:
|
||||
specifier: ^1.0.7
|
||||
version: 1.0.7
|
||||
srt-webvtt:
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
@@ -201,9 +201,6 @@ importers:
|
||||
'@movie-web/tsconfig':
|
||||
specifier: workspace:^0.1.0
|
||||
version: link:../../tooling/typescript
|
||||
'@types/hls-parser':
|
||||
specifier: ^0.8.7
|
||||
version: 0.8.7
|
||||
eslint:
|
||||
specifier: ^8.56.0
|
||||
version: 8.56.0
|
||||
@@ -3169,12 +3166,6 @@ packages:
|
||||
resolution: {integrity: sha512-qkcUlZmX6c4J8q45taBKTL3p+LbITgyx7qhlPYOdOHZB7B31K0mXbP5YA7i7SgDeEGuI9MnumiKPEMrxg8j3KQ==}
|
||||
dev: false
|
||||
|
||||
/@types/hls-parser@0.8.7:
|
||||
resolution: {integrity: sha512-3ry9V6i/uhSbNdvBUENAqt2p5g+xKIbjkr5Qv4EaXe7eIJnaGQntFZalRLQlKoEop381a0LwUr2qNKKlxQC4TQ==}
|
||||
dependencies:
|
||||
'@types/node': 20.11.16
|
||||
dev: true
|
||||
|
||||
/@types/inquirer@6.5.0:
|
||||
resolution: {integrity: sha512-rjaYQ9b9y/VFGOpqBEXRavc3jh0a+e6evAbI31tMda8VlPaSy0AZJfXsvmIe3wklc7W6C3zCSfleuMXR7NOyXw==}
|
||||
dependencies:
|
||||
@@ -6350,10 +6341,6 @@ packages:
|
||||
source-map: 0.7.4
|
||||
dev: false
|
||||
|
||||
/hls-parser@0.10.8:
|
||||
resolution: {integrity: sha512-7FSqn7HYqXEW7I3qcgHJbtpNzi2nLKlBblPvHV6Uc6esVZ8JGfN3xUV7739gfaOh+w/O6TFxysLyW3GeLlAJTA==}
|
||||
dev: false
|
||||
|
||||
/hmac-drbg@1.0.1:
|
||||
resolution: {integrity: sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==}
|
||||
dependencies:
|
||||
@@ -8427,6 +8414,10 @@ packages:
|
||||
safe-buffer: 5.2.1
|
||||
dev: false
|
||||
|
||||
/parse-hls@1.0.7:
|
||||
resolution: {integrity: sha512-tnAK2nXe8J/Jf66SwY2cUAKKXInLR9hkNhTtcS7t6J4CgkG8LGBfC1GuuXg7kLLbIQLXpVhZrY/tfyhDbqfzwg==}
|
||||
dev: false
|
||||
|
||||
/parse-json@4.0.0:
|
||||
resolution: {integrity: sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==}
|
||||
engines: {node: '>=4'}
|
||||
|
Reference in New Issue
Block a user