Skip to content

Commit

Permalink
Merge pull request #259 from openzim/setup-ogvjs
Browse files Browse the repository at this point in the history
Add support for ogv.js in video player
benoit74 authored Jul 4, 2024
2 parents bcf700e + 8f24baa commit 5ae8960
Showing 13 changed files with 881 additions and 76 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add playlist panel for playing videos in a playlist (#216)
- Remove `--autoplay` CLI argument and set autoplay to always be true (#233)
- Add playlist view page in new Vue.js UI (#223)
- Add support for ogv.js in video-js player (#230)
- Remove openzim.toml and install all dependencies using Yarn (#218)

## [2.3.0] - 2024-05-22

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ WORKDIR /output

# Copy pyproject.toml and its dependencies
COPY README.md /src/
COPY scraper/pyproject.toml scraper/openzim.toml /src/scraper/
COPY scraper/pyproject.toml /src/scraper/
COPY scraper/src/youtube2zim/__about__.py /src/scraper/src/youtube2zim/__about__.py

# Install Python dependencies
44 changes: 0 additions & 44 deletions scraper/openzim.toml

This file was deleted.

3 changes: 0 additions & 3 deletions scraper/pyproject.toml
Original file line number Diff line number Diff line change
@@ -28,9 +28,6 @@ allow-direct-references = true
kind = "scraper"
additional-keywords = ["youtube"]

[tool.hatch.build.hooks.openzim-build]
dependencies = [ "zimscraperlib==3.4.0"] # required for fix_ogv_dist

[project.optional-dependencies]
scripts = ["invoke==2.2.0"]
lint = ["black==24.4.2", "ruff==0.4.10"]
18 changes: 0 additions & 18 deletions scraper/src/youtube2zim/scraper.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,6 @@
from kiwixstorage import KiwixStorage
from pif import get_public_ip
from zimscraperlib.download import stream_file
from zimscraperlib.fix_ogvjs_dist import fix_source_dir
from zimscraperlib.i18n import NotFound, get_language_details
from zimscraperlib.image.convertion import convert_image
from zimscraperlib.image.presets import WebpHigh
@@ -190,18 +189,6 @@ def __init__(
def root_dir(self):
return ROOT_DIR

@property
def templates_dir(self):
return self.root_dir.joinpath("templates")

@property
def assets_src_dir(self):
return self.templates_dir.joinpath("assets")

@property
def assets_dir(self):
return self.build_dir.joinpath("assets")

@property
def channels_dir(self):
return self.build_dir.joinpath("channels")
@@ -488,11 +475,6 @@ def validate_id(self):
def prepare_build_folder(self):
"""prepare build folder before we start downloading data"""

# copy assets
shutil.copytree(self.assets_src_dir, self.assets_dir)

fix_source_dir(self.assets_dir)

# cache folder to store youtube-api results
self.cache_dir.mkdir(exist_ok=True)

File renamed without changes.
3 changes: 3 additions & 0 deletions zimui/package.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
"name": "zimui",
"version": "0.0.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
@@ -41,9 +42,11 @@
"eslint-plugin-vue": "^9.23.0",
"jsdom": "^24.0.0",
"npm-run-all2": "^6.1.2",
"ogv": "^1.9.0",
"prettier": "^3.2.5",
"typescript": "~5.4.0",
"vite": "^5.2.8",
"vite-plugin-static-copy": "^1.0.5",
"vitest": "^1.4.0",
"vue-tsc": "^2.0.11"
},
7 changes: 6 additions & 1 deletion zimui/src/assets/vjs-youtube.css
Original file line number Diff line number Diff line change
@@ -8,7 +8,8 @@
border-bottom-right-radius: 8px;
}

.vjs-youtube .vjs-poster img {
.vjs-youtube .vjs-poster img,
.vjs-youtube .ogvjs-poster {
border-radius: 8px;
}

@@ -47,3 +48,7 @@
padding-left: 5px;
border-radius: 8px;
}

.vjs-youtube .vjs-tech canvas {
border-radius: 8px;
}
1 change: 1 addition & 0 deletions zimui/src/components/video/VideoPlayer.vue
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import type Player from 'video.js/dist/types/player'
import 'video.js/dist/video-js.css'
import '@/assets/vjs-youtube.css'
import '@/plugins/videojs-ogvjs.js'
const props = defineProps({
options: {
764 changes: 764 additions & 0 deletions zimui/src/plugins/videojs-ogvjs.js

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions zimui/src/views/VideoPlayerView.vue
Original file line number Diff line number Diff line change
@@ -75,6 +75,12 @@ const videoURL = computed<string>(() => {
return video.value?.videoPath || ''
})
// This computes the video format from the video URL
// For example, if videoURL is "/some_path/video.webm", then videoFormat will be "video/webm"
const videoFormat = computed<string>(() => {
return 'video/' + videoURL.value?.split('.').pop()
})
const videoPoster = computed<string>(() => {
return video.value?.thumbnailPath || ''
})
@@ -99,11 +105,15 @@ const videoOptions = ref({
enableSmoothSeeking: true,
controlBar: { pictureInPictureToggle: false },
playbackRates: [0.25, 0.5, 1, 1.5, 2],
techOrder: ['html5'],
techOrder: ['html5', 'ogvjs'],
ogvjs: {
base: './assets/ogvjs'
},
poster: videoPoster,
sources: [
{
src: videoURL
src: videoURL,
type: videoFormat
}
],
tracks: subtitles
14 changes: 13 additions & 1 deletion zimui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -3,11 +3,23 @@ import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vuetify from 'vite-plugin-vuetify'
import { viteStaticCopy } from 'vite-plugin-static-copy'

// https://vitejs.dev/config/
export default defineConfig({
base: './',
plugins: [vue(), vuetify({ autoImport: true })],
plugins: [
vue(),
vuetify({ autoImport: true }),
viteStaticCopy({
targets: [
{
src: 'node_modules/ogv/dist/*',
dest: 'assets/ogvjs' // videojs-ogvjs-plugin needs access to ogvjs files at runtime
}
]
})
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
85 changes: 79 additions & 6 deletions zimui/yarn.lock
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.6.tgz#5e030f440c3c6c78d195528c3b688b101a365328"
integrity sha512-eNZXdfU35nJC2h24RznROuOpO94h6x8sg9ju0tT9biNtLZ2vuP8SduLqqV+/8+cebSLV9SJEAN5Z3zQbJG/M+Q==

"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.5.5":
"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.7", "@babel/runtime@^7.5.5":
version "7.24.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.24.7.tgz#f4f0d5530e8dbdf59b3451b9b3e594b6ba082e12"
integrity sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==
@@ -856,6 +856,14 @@ ansi-styles@^6.1.0, ansi-styles@^6.2.1:
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5"
integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==

anymatch@~3.1.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e"
integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==
dependencies:
normalize-path "^3.0.0"
picomatch "^2.0.4"

arch@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/arch/-/arch-2.2.0.tgz#1bc47818f305764f23ab3306b0bfc086c5a29d11"
@@ -944,6 +952,11 @@ bcrypt-pbkdf@^1.0.0:
dependencies:
tweetnacl "^0.14.3"

binary-extensions@^2.0.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522"
integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==

blob-util@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/blob-util/-/blob-util-2.0.2.tgz#3b4e3c281111bb7f11128518006cdc60b403a1eb"
@@ -974,7 +987,7 @@ brace-expansion@^2.0.1:
dependencies:
balanced-match "^1.0.0"

braces@^3.0.3:
braces@^3.0.3, braces@~3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
@@ -1058,6 +1071,21 @@ check-more-types@^2.24.0:
resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600"
integrity sha512-Pj779qHxV2tuapviy1bSZNEL1maXr13bPYpsvSDB68HlYcYuhlDrmGd63i0JHMCLKzc7rUSNIrpdJlhVlNwrxA==

chokidar@^3.5.3:
version "3.6.0"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b"
integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.3.2"

ci-info@^3.2.0:
version "3.9.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-3.9.0.tgz#4279a62028a7b1f262f3473fc9605f5e218c59b4"
@@ -1645,7 +1673,7 @@ fast-diff@^1.1.2:
resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.3.0.tgz#ece407fa550a64d638536cd727e129c61616e0f0"
integrity sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==

fast-glob@^3.2.9:
fast-glob@^3.2.11, fast-glob@^3.2.9:
version "3.3.2"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
@@ -1759,6 +1787,15 @@ form-data@~2.3.2:
combined-stream "^1.0.6"
mime-types "^2.1.12"

fs-extra@^11.1.0:
version "11.2.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b"
integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"

fs-extra@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
@@ -1826,7 +1863,7 @@ getpass@^0.1.1:
dependencies:
assert-plus "^1.0.0"

glob-parent@^5.1.2:
glob-parent@^5.1.2, glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
@@ -2053,6 +2090,13 @@ ini@^1.3.4:
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c"
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==

is-binary-path@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09"
integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==
dependencies:
binary-extensions "^2.0.0"

is-ci@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-3.0.1.tgz#db6ecbed1bd659c43dac0f45661e7674103d1867"
@@ -2075,7 +2119,7 @@ is-function@^1.0.1:
resolved "https://registry.yarnpkg.com/is-function/-/is-function-1.0.2.tgz#4f097f30abf6efadac9833b17ca5dc03f8144e08"
integrity sha512-lw7DUp0aWXYg+CBCN+JKkcE0Q2RayZnSvnZBlwgxHBQhqt5pZNVy4Ri7H9GmmXkdu7LUthszM+Tor1u/2iBcpQ==

is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3:
is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1:
version "4.0.3"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
@@ -2511,6 +2555,11 @@ nopt@^7.2.0:
dependencies:
abbrev "^2.0.0"

normalize-path@^3.0.0, normalize-path@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==

npm-normalize-package-bin@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/npm-normalize-package-bin/-/npm-normalize-package-bin-3.0.1.tgz#25447e32a9a7de1f51362c61a559233b89947832"
@@ -2560,6 +2609,13 @@ object-inspect@^1.13.1:
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2"
integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==

ogv@^1.9.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/ogv/-/ogv-1.9.0.tgz#ac1ea8f3e572709b376e8bf708e673803af3e0aa"
integrity sha512-Spjbi8spzaY5PCn7JDQm6HAP8XDRuOCMG/oCQy59IPFe4A0oXR0dDNPRpc6oj8gIjPgs5pL7hpE9prf27qztFw==
dependencies:
"@babel/runtime" "^7.16.7"

once@^1.3.0, once@^1.3.1, once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
@@ -2703,7 +2759,7 @@ picocolors@^1.0.0:
resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.1.tgz#a8ad579b571952f0e5d25892de5445bcfe25aaa1"
integrity sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==

picomatch@^2.3.1:
picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
@@ -2858,6 +2914,13 @@ read-package-json-fast@^3.0.2:
json-parse-even-better-errors "^3.0.0"
npm-normalize-package-bin "^3.0.0"

readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
dependencies:
picomatch "^2.2.1"

regenerator-runtime@^0.14.0:
version "0.14.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f"
@@ -3426,6 +3489,16 @@ vite-node@1.6.0:
picocolors "^1.0.0"
vite "^5.0.0"

vite-plugin-static-copy@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/vite-plugin-static-copy/-/vite-plugin-static-copy-1.0.5.tgz#6f695b9c02af09860cb8d40ee243167b6823e4a6"
integrity sha512-02k0Rox+buYdEOfeilKZSgs1gXfPf9RjVztZEIYZgVIxjsVZi6AXssjzdi+qW6zYt00d3bq+tpP2voVXN2fKLw==
dependencies:
chokidar "^3.5.3"
fast-glob "^3.2.11"
fs-extra "^11.1.0"
picocolors "^1.0.0"

vite-plugin-vuetify@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/vite-plugin-vuetify/-/vite-plugin-vuetify-2.0.3.tgz#b65ee4e05cfc6bf2b478a32b6d58b42398519f1e"

0 comments on commit 5ae8960

Please sign in to comment.