From cc35afa64a2ca620dc4af4fbae805a116f0079cc Mon Sep 17 00:00:00 2001 From: codediodeio Date: Thu, 28 Nov 2024 06:16:58 -0700 Subject: [PATCH] video player updates --- .github/workflows/deploy.yml | 1 + app/util/player.ts | 22 +++++++++++++++++++--- app/util/s2.ts | 4 ++++ layouts/_default/baseof.html | 9 +++++++-- layouts/partials/funcEncodeValue.html | 14 ++++++++++++++ layouts/partials/funcGetSalt.html | 4 ++++ 6 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 app/util/s2.ts create mode 100644 layouts/partials/funcEncodeValue.html create mode 100644 layouts/partials/funcGetSalt.html diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 05d6c3bf6..d5e7f64eb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,6 +11,7 @@ env: ALGOLIA_ADMIN_KEY: ${{secrets.ALGOLIA_ADMIN_KEY}} ALGOLIA_INDEX_NAME: content ALGOLIA_INDEX_FILE: public/algolia.json + HUGO_SALT: ${{secrets.HUGO_SALT}} jobs: diff --git a/app/util/player.ts b/app/util/player.ts index 63d76e5dd..3641c6958 100644 --- a/app/util/player.ts +++ b/app/util/player.ts @@ -8,16 +8,20 @@ export class UniversalPlayer { constructor(public video: string | number, public el: HTMLElement, public type: 'youtube' | 'vimeo') {} private async setupPlayer() { + if (this.type === 'youtube') { const YouTubePlayer = (await import('youtube-player')).default; const decoded = atob(this.video as string); + this.ytPlayer = YouTubePlayer(this.el); this.ytPlayer.cueVideoById(decoded); } else { const VimeoPlayer = (await import('@vimeo/player')).default; - const decoded = parseInt(atob(this.video as string)); - // const buildId = parseInt(document.head.dataset.build); - this.vimeoPlayer = new VimeoPlayer(this.el, { id: decoded }); + + const decoded = await this.decoded(); + const vimeoId = parseInt(decoded) + + this.vimeoPlayer = new VimeoPlayer(this.el, { id: vimeoId }); } } @@ -29,6 +33,18 @@ export class UniversalPlayer { return obj; } + async decoded() { + const path = window.location.pathname; + const s1 = btoa(path); + let p1 = (await import('./s2')).default; + const p2 = 'fUCB3Iv'; + const s2 = p1+p2; + let withS = atob(this.video as string) + let encoded = withS.slice(s1.length, -s2.length); + const decoded = atob(encoded) + return decoded; + } + play() { if (this.type === 'youtube') { this.ytPlayer.playVideo(); diff --git a/app/util/s2.ts b/app/util/s2.ts new file mode 100644 index 000000000..105ee1194 --- /dev/null +++ b/app/util/s2.ts @@ -0,0 +1,4 @@ +export default (()=>{ + const c = [120, 105, 88, 70, 84, 116, 69, 85, 90]; + return [1, 3, 4, 6, 0, 5, 7].map(i => String.fromCharCode(c[i])).join(''); +})(); \ No newline at end of file diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 0f080cb57..14ae17475 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -25,12 +25,17 @@ - {{ $vimeoEncode := .Params.vimeo | base64Encode }} + + + {{ $saltVimeo := "" }} + {{ if .Params.vimeo }} + {{ $saltVimeo = partial "funcEncodeValue" (dict "value" .Params.vimeo "path" .RelPermalink) }} + {{ end }} {{ $ytEncode := .Params.youtube | base64Encode }}