Merge pull request #530 from Materialious/update/1.3.1

Update/1.3.1
This commit is contained in:
Ward
2024-09-10 18:30:47 +12:00
committed by GitHub
13 changed files with 196 additions and 43 deletions
+2 -2
View File
@@ -7,8 +7,8 @@ android {
applicationId "us.materialio.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 29
versionName "1.3.0"
versionCode 30
versionName "1.3.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Materialious",
"version": "1.3.0",
"version": "1.3.1",
"description": "Modern material design for Invidious.",
"author": {
"name": "Ward Pearce",
+3 -5
View File
@@ -1,12 +1,12 @@
{
"name": "materialious",
"version": "1.2.3",
"version": "1.3.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "materialious",
"version": "1.2.3",
"version": "1.3.1",
"dependencies": {
"@capacitor-community/electron": "^5.0.1",
"@capacitor/android": "6.1.2",
@@ -14,6 +14,7 @@
"@capacitor/browser": "^6.0.2",
"@capacitor/cli": "6.1.2",
"@capacitor/core": "^6.1.2",
"@ffmpeg/ffmpeg": "^0.12.10",
"beercss": "^3.6.13",
"fuse.js": "^7.0.0",
"he": "^1.2.0",
@@ -32,7 +33,6 @@
},
"devDependencies": {
"@capacitor/assets": "^3.0.5",
"@ffmpeg/ffmpeg": "^0.12.10",
"@ffmpeg/util": "^0.12.1",
"@sveltejs/adapter-auto": "^3.2.4",
"@sveltejs/adapter-static": "^3.0.1",
@@ -2613,7 +2613,6 @@
"version": "0.12.10",
"resolved": "https://registry.npmjs.org/@ffmpeg/ffmpeg/-/ffmpeg-0.12.10.tgz",
"integrity": "sha512-lVtk8PW8e+NUzGZhPTWj2P1J4/NyuCrbDD3O9IGpSeLYtUZKBqZO8CNj1WYGghep/MXoM8e1qVY1GztTkf8YYQ==",
"dev": true,
"dependencies": {
"@ffmpeg/types": "^0.12.2"
},
@@ -2625,7 +2624,6 @@
"version": "0.12.2",
"resolved": "https://registry.npmjs.org/@ffmpeg/types/-/types-0.12.2.tgz",
"integrity": "sha512-NJtxwPoLb60/z1Klv0ueshguWQ/7mNm106qdHkB4HL49LXszjhjCCiL+ldHJGQ9ai2Igx0s4F24ghigy//ERdA==",
"dev": true,
"engines": {
"node": ">=16.x"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "materialious",
"version": "1.3.0",
"version": "1.3.1",
"private": true,
"scripts": {
"dev": "vite dev",
@@ -13,7 +13,6 @@
},
"devDependencies": {
"@capacitor/assets": "^3.0.5",
"@ffmpeg/ffmpeg": "^0.12.10",
"@ffmpeg/util": "^0.12.1",
"@sveltejs/adapter-auto": "^3.2.4",
"@sveltejs/adapter-static": "^3.0.1",
@@ -46,6 +45,7 @@
"@capacitor/browser": "^6.0.2",
"@capacitor/cli": "6.1.2",
"@capacitor/core": "^6.1.2",
"@ffmpeg/ffmpeg": "^0.12.10",
"beercss": "^3.6.13",
"fuse.js": "^7.0.0",
"he": "^1.2.0",
@@ -62,4 +62,4 @@
"svelte-persisted-store": "^0.11.0",
"vidstack": "^1.12.9"
}
}
}
+1 -6
View File
@@ -2,18 +2,13 @@
import { _ } from 'svelte-i18n';
import { getComments } from './Api';
import { type Comment, type Comments } from './Api/model';
import { getBestThumbnail, numberWithCommas, proxyGoogleImage } from './misc';
import { getBestThumbnail, loadPfp, numberWithCommas, proxyGoogleImage } from './misc';
export let comment: Comment;
export let videoId: string;
let replies: Comments | undefined = undefined;
async function loadPfp(url: string): Promise<string> {
const resp = await fetch(url);
return URL.createObjectURL(await resp.blob());
}
async function loadReplies(continuation: string) {
try {
replies = await getComments(videoId, {
+2 -1
View File
@@ -73,7 +73,8 @@
"downloadSteps": {
"merging": "Merging video & audio together",
"video": "Downloading video",
"audio": "Downloading audio"
"audio": "Downloading audio",
"ffmpeg": "Downloading ffmpeg library & components"
},
"noPlaylists": "No playlists",
"unableToLoadComments": "Unable to load comments",
+5
View File
@@ -170,6 +170,11 @@ export function proxyVideoUrl(source: string): string {
return rawSrc.toString();
}
export async function loadPfp(url: string): Promise<string> {
const resp = await fetch(url);
return URL.createObjectURL(await resp.blob());
}
export function proxyGoogleImage(source: string): string {
if (source.startsWith('//')) source = `https:${source}`;
+17 -8
View File
@@ -1,6 +1,3 @@
import { FFmpeg } from '@ffmpeg/ffmpeg';
import { proxyVideoUrl } from './misc';
interface MediaQuality {
bandwidth: string;
videoUrl: string;
@@ -69,7 +66,7 @@ async function fetchDASHManifest(manifestUrl: string) {
export async function listCombinedQualities(manifestUrl: string): Promise<MediaQuality[]> {
const manifest = await fetchDASHManifest(manifestUrl);
const manifest = await fetchDASHManifest(`${manifestUrl}?local=true`);
const qualities: MediaQuality[] = [];
// Fetch all AdaptationSets (both video and audio)
@@ -93,7 +90,7 @@ export async function listCombinedQualities(manifestUrl: string): Promise<MediaQ
// Combine video and audio representations
videoRepresentations.forEach((videoRep) => {
const videoBandwidth = videoRep.getAttribute('bandwidth');
const videoUrl = proxyVideoUrl(videoRep.getElementsByTagName('BaseURL')[0].textContent as string);
const videoUrl = videoRep.getElementsByTagName('BaseURL')[0].textContent as string;
const width = videoRep.getAttribute('width');
const height = videoRep.getAttribute('height');
const resolution = width && height ? `${width}x${height}` : undefined;
@@ -101,7 +98,7 @@ export async function listCombinedQualities(manifestUrl: string): Promise<MediaQ
// Pair this video representation with each audio representation
audioRepresentations.forEach((audioRep) => {
const audioUrl = proxyVideoUrl(audioRep.getElementsByTagName('BaseURL')[0].textContent as string);
const audioUrl = audioRep.getElementsByTagName('BaseURL')[0].textContent as string;
const audioChannels = audioRep.getElementsByTagName('AudioChannelConfiguration')[0]?.getAttribute('value') || '';
const audioBandwidth = audioRep.getAttribute('bandwidth') || '';
@@ -128,9 +125,16 @@ export async function mergeMediaFromDASH(
video?: (progress: number) => void,
audio?: (progress: number) => void,
merging?: (progress: number) => void,
loadingFfmpeg?: (completed: boolean) => void;
}
) {
const ffmpeg = new FFmpeg();
if (progressCallbacks?.loadingFfmpeg) {
progressCallbacks.loadingFfmpeg(false);
}
const FFmpeg = await import('@ffmpeg/ffmpeg');
const ffmpeg = new FFmpeg.FFmpeg();
ffmpeg.on('progress', ({ progress }) => {
if (progressCallbacks?.merging) {
@@ -139,11 +143,16 @@ export async function mergeMediaFromDASH(
});
await ffmpeg.load({
classWorkerURL: await toBlobURL('/ffmpeg/ffmpeg-worker.js', 'text/javascript'),
coreURL: await toBlobURL('/ffmpeg/ffmpeg-core.js', 'text/javascript'),
wasmURL: await toBlobURL('/ffmpeg/ffmpeg-core.wasm', 'application/wasm'),
workerURL: await toBlobURL('/ffmpeg/ffmpeg-core.worker.js', 'text/javascript')
});
if (progressCallbacks?.loadingFfmpeg) {
progressCallbacks.loadingFfmpeg(true);
}
const { videoUrl, audioUrl } = selectedQuality;
ffmpeg.writeFile('input.mp4', await fetchFile(videoUrl, progressCallbacks?.video));
@@ -156,7 +165,7 @@ export async function mergeMediaFromDASH(
const url = URL.createObjectURL(mergedFile);
const a = document.createElement('a');
a.href = url;
a.download = `${fileName}.mp4`;
a.download = `${fileName} - ${selectedQuality.resolution}.mp4`;
document.body.appendChild(a);
a.click();
@@ -44,6 +44,7 @@
import { _ } from 'svelte-i18n';
import { get } from 'svelte/store';
import type { MediaPlayerElement } from 'vidstack/elements';
import { loadPfp } from '../../../../lib/misc.js';
export let data;
@@ -413,6 +414,10 @@
downloadStage = undefined;
}
}
function onLoadingFFmpeg(completed: boolean) {
downloadStage = $_('player.downloadSteps.ffmpeg');
}
</script>
<svelte:head>
@@ -447,11 +452,9 @@
<nav>
<a href={`/channel/${data.video.authorId}`}>
<nav>
<img
class="circle large"
src={proxyGoogleImage(getBestThumbnail(data.video.authorThumbnails))}
alt="Channel profile"
/>
{#await loadPfp(proxyGoogleImage(getBestThumbnail(data.video.authorThumbnails))) then pfp}
<img class="circle large" src={pfp} alt="Channel profile" />
{/await}
<div>
<p class="bold">{data.video.author}</p>
<p>{data.video.subCountText}</p>
@@ -542,7 +545,8 @@
await mergeMediaFromDASH(quality, data.video.title, {
video: onVideoDownloadProgress,
audio: onAudioDownloadProgress,
merging: onMergingProgress
merging: onMergingProgress,
loadingFfmpeg: onLoadingFFmpeg
})}>{quality.resolution}</a
>
{/each}
@@ -51,11 +51,12 @@ export async function load({ params, url }) {
} catch { }
}
let downloadQualitiesDash;
if (
typeof import.meta.env.VITE_DEFAULT_DOWNLOAD_ENABLED !== 'undefined' &&
import.meta.env.VITE_DEFAULT_DOWNLOAD_ENABLED.toString() === 'true' &&
typeof video.hlsUrl === 'undefined' && get(playerDashStore)
import.meta.env.VITE_DEFAULT_DOWNLOAD_ENABLED &&
import.meta.env.VITE_DEFAULT_DOWNLOAD_ENABLED.toString().toLowerCase() === 'true' &&
!video.liveNow && get(playerDashStore)
) {
downloadQualitiesDash = listCombinedQualities(video.dashUrl);
}
+146
View File
@@ -0,0 +1,146 @@
(function () {
"use strict";
const R = "./ffmpeg-core.js";
var E;
(function (t) {
t.LOAD = "LOAD", t.EXEC = "EXEC", t.WRITE_FILE = "WRITE_FILE", t.READ_FILE = "READ_FILE", t.DELETE_FILE = "DELETE_FILE", t.RENAME = "RENAME", t.CREATE_DIR = "CREATE_DIR", t.LIST_DIR = "LIST_DIR", t.DELETE_DIR = "DELETE_DIR", t.ERROR = "ERROR", t.DOWNLOAD = "DOWNLOAD", t.PROGRESS = "PROGRESS", t.LOG = "LOG", t.MOUNT = "MOUNT", t.UNMOUNT = "UNMOUNT"
})(E || (E = {}));
const a = new Error("unknown message type"),
f = new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),
u = new Error("failed to import ffmpeg-core.js");
let r;
const O = async ({
coreURL: t,
wasmURL: n,
workerURL: e
}) => {
const o = !r;
try {
t || (t = R), importScripts(t)
} catch {
if (t || (t = R.replace("/umd/", "/esm/")), self.createFFmpegCore = (await import(t)).default, !self.createFFmpegCore) throw u
}
const s = t,
c = n || t.replace(/.js$/g, ".wasm"),
b = e || t.replace(/.js$/g, ".worker.js");
return r = await self.createFFmpegCore({
mainScriptUrlOrBlob: `${s}#${btoa(JSON.stringify({ wasmURL: c, workerURL: b }))}`
}), r.setLogger(i => self.postMessage({
type: E.LOG,
data: i
})), r.setProgress(i => self.postMessage({
type: E.PROGRESS,
data: i
})), o
}, l = ({
args: t,
timeout: n = -1
}) => {
r.setTimeout(n), r.exec(...t);
const e = r.ret;
return r.reset(), e
}, m = ({
path: t,
data: n
}) => (r.FS.writeFile(t, n), !0), D = ({
path: t,
encoding: n
}) => r.FS.readFile(t, {
encoding: n
}), S = ({
path: t
}) => (r.FS.unlink(t), !0), I = ({
oldPath: t,
newPath: n
}) => (r.FS.rename(t, n), !0), L = ({
path: t
}) => (r.FS.mkdir(t), !0), N = ({
path: t
}) => {
const n = r.FS.readdir(t),
e = [];
for (const o of n) {
const s = r.FS.stat(`${t}/${o}`),
c = r.FS.isDir(s.mode);
e.push({
name: o,
isDir: c
})
}
return e
}, A = ({
path: t
}) => (r.FS.rmdir(t), !0), w = ({
fsType: t,
options: n,
mountPoint: e
}) => {
const o = t,
s = r.FS.filesystems[o];
return s ? (r.FS.mount(s, n, e), !0) : !1
}, k = ({
mountPoint: t
}) => (r.FS.unmount(t), !0);
self.onmessage = async ({
data: {
id: t,
type: n,
data: e
}
}) => {
const o = [];
let s;
try {
if (n !== E.LOAD && !r) throw f;
switch (n) {
case E.LOAD:
s = await O(e);
break;
case E.EXEC:
s = l(e);
break;
case E.WRITE_FILE:
s = m(e);
break;
case E.READ_FILE:
s = D(e);
break;
case E.DELETE_FILE:
s = S(e);
break;
case E.RENAME:
s = I(e);
break;
case E.CREATE_DIR:
s = L(e);
break;
case E.LIST_DIR:
s = N(e);
break;
case E.DELETE_DIR:
s = A(e);
break;
case E.MOUNT:
s = w(e);
break;
case E.UNMOUNT:
s = k(e);
break;
default:
throw a
}
} catch (c) {
self.postMessage({
id: t,
type: E.ERROR,
data: c.toString()
});
return
}
s instanceof Uint8Array && o.push(s.buffer), self.postMessage({
id: t,
type: n,
data: s
}, o)
}
})();
+1 -7
View File
@@ -1,6 +1,5 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { SvelteKitPWA } from '@vite-pwa/sveltekit';
import { fileURLToPath, URL } from 'node:url';
import { vite as vidstack } from 'vidstack/plugins';
import { defineConfig } from 'vite';
@@ -35,12 +34,7 @@ export default defineConfig({
vidstack(),
sveltekit()
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
optimizeDeps: {
exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util']
}
},
});
+1 -1
View File
@@ -5,7 +5,7 @@ import json
import os
import re
LATEST_VERSION = "1.3.0"
LATEST_VERSION = "1.3.1"
WORKING_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "materialious")
ROOT_PACKAGE = os.path.join(WORKING_DIR, "package.json")