Add YouTube support

This commit is contained in:
Korbs 2024-11-29 17:45:45 -05:00
parent 57eb7f9246
commit c1602e7087
2 changed files with 22 additions and 4 deletions

View file

@ -15,7 +15,7 @@
"live-streaming" "live-streaming"
], ],
"type": "module", "type": "module",
"version": "0.4.63", "version": "0.4.65",
"exports": { "exports": {
".": "./index.ts" ".": "./index.ts"
}, },
@ -30,7 +30,7 @@
"astro": "^4.14.2" "astro": "^4.14.2"
}, },
"scripts": { "scripts": {
"npm:publish": "npm publish --registry https://npm.sudovanilla.org/", "publish": "npm publish && npm publish --registry https://npm.sudovanilla.org/",
"test": "cd test/ && bun start" "test": "cd test/ && bun start"
} }
} }

View file

@ -11,6 +11,11 @@ const {
VideoAttributes, VideoAttributes,
AudioAttributes, AudioAttributes,
YouTube = false,
YouTubeQuality = '137',
Invidious,
WatchId,
Milieu, Milieu,
MilieuMode = "Default", MilieuMode = "Default",
MilieuSpeed = "2000", MilieuSpeed = "2000",
@ -29,14 +34,27 @@ import Controller from './Controls/Controller.astro'
import Seek from './Controls/Seek.astro' import Seek from './Controls/Seek.astro'
import Sync from './Controls/Sync.astro' import Sync from './Controls/Sync.astro'
// YouTube
if (YouTube === true) {
// 8K = 272
// 4K = 315
// 1080p = 137
// 720p = 302
// Dash Audio = 251
var YTVideo = 'https://' + Invidious +'/latest_version?id=' + WatchId + '&itag=' + YouTubeQuality
var YTAudio = 'https://' + Invidious +'/latest_version?id=' + WatchId + '&itag=251'
} else if (YouTube === false) {
null
}
// Icons and Styles // Icons and Styles
import './Styles/Index.scss' import './Styles/Index.scss'
import './Styles/Iconoir.css' import './Styles/Iconoir.css'
--- ---
<div class="video-container" id={"zorn-player-" + PlayerName}> <div class="video-container" id={"zorn-player-" + PlayerName}>
<video class="main-video" {VideoAttributes} disableremoteplayback src={Video} poster={Poster} preload="auto"></video> <video class="main-video" {VideoAttributes} disableremoteplayback src={YouTube ? YTVideo : Video} poster={Poster} preload="auto"></video>
{Audio ? <audio class="main-audio"><source {AudioAttributes} src={Audio} type="audio/mp3"/></audio> : null } {Audio ? <audio class="main-audio"><source {AudioAttributes} src={YouTube ? YTAudio : Audio} type="audio/mp3"/></audio> : null }
{Audio ? <Sync PlayerName={PlayerName}/> : null } {Audio ? <Sync PlayerName={PlayerName}/> : null }
{Milieu ? {Milieu ?
<MilieuEffect <MilieuEffect