Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade zimscraperlib and other dependencies #201

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/psf/black
rev: "23.7.0"
rev: "24.4.2"
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
rev: v0.4.4
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.331
rev: v1.1.363
hooks:
- id: pyright
name: pyright (system)
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- New `long_description` CLI argument to set the ZIM long description
- New `disable_metadata_check` CLI argument to disable the metadata checks which are automated since zimscraperlib 3.x

### Changed

- Changed default publisher metadata to 'openZIM'
- Validate ZIM metadata (tags, title, description, long_description) as early as possible
- Migrate to zimscraperlib 3.3.2
- Upgrade Python dependencies, including migration to Python 3.12

## [2.2.0] - 2023-11-17

Expand All @@ -23,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed local path media (profile, banner) not working (#178)
- Unset `metadata_from` in `youtube2zim-playlists` (#185)
- Do not move local banner and profile images, copy them instead #179

## [2.1.18] - 2022-11-09

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10-bookworm
FROM python:3.12-bookworm
LABEL org.opencontainers.image.source https://github.com/openzim/youtube

# Install necessary packages
Expand All @@ -20,7 +20,7 @@ RUN mkdir -p /output
WORKDIR /output

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

# Install Python dependencies
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ Here comes a few different ways to install `youtube2zim`.

`youtube2zim` is a Python3 software. If you are not using the [Docker](https://docker.com) image,
you are advised to use it in a [virtualenv](https://virtualenv.pypa.io) to avoid installing software
dependences on your system. [Hatch](https://hatch.pypa.io/) is the proper tool to create the
dependencies on your system. [Hatch](https://hatch.pypa.io/) is the proper tool to create the
virtualenv and install the software locally. Ensure to use proper Python version as well (see
pyproject.toml).

If you do not already have it on your system, install hatch to build the software and manage virtual
environments (you might be interested by our detailed
[Developer Setup](https://github.com/openzim/_python-bootstrap/wiki/Developer-Setup) as well,
especially regarding how to configure hatch globaly for proper detection of its virtual environments
especially regarding how to configure hatch globally for proper detection of its virtual environments
by Visual Studio Code).

``` bash
Expand Down Expand Up @@ -84,11 +84,11 @@ youtube2zim-playlists

`youtube2zim` produces a single ZIM file for a youtube request (`channel`, `user`, `playlist`).

`youtube2zim-playlists` allows you to ** automatically create one ZIM file per playlist** of a given channel or user instead.
`youtube2zim-playlists` allows you to **automatically create one ZIM file per playlist** of a given channel or user instead.

This script is a wrapper around `youtube2zim` and is bundled with the main package.

The difference between a channel and a user is due to Youtube legacy. Some old users have to be searched as a user, while more recent ones have to be searched as a channel. Try your best bet, and if it fails try the ohter type.
The difference between a channel and a user is due to Youtube legacy. Some old users have to be searched as a user, while more recent ones have to be searched as a channel. Try your best bet, and if it fails try the other type.

## Usage

Expand Down
66 changes: 0 additions & 66 deletions get_js_deps.sh

This file was deleted.

43 changes: 0 additions & 43 deletions hatch_build.py

This file was deleted.

45 changes: 45 additions & 0 deletions openzim.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[files.assets.config]
target_dir="src/youtube2zim/templates/assets"
execute_after=[
"fix_ogvjs_dist .",
]

[files.assets.actions."video.js"]
action="extract_all"
source="https://github.com/videojs/video.js/releases/download/v7.8.1/video-js-7.8.1.zip"
target_dir="videojs"
remove = ["alt","examples",]

[files.assets.actions."chosen.jquery.js"]
action="extract_all"
source="https://github.com/harvesthq/chosen/releases/download/v1.8.7/chosen_v1.8.7.zip"
target_dir="chosen"
remove = ["docsupport","chosen.proto.*","*.html","*.md"]

[files.assets.actions."jquery.min.js"]
action="get_file"
source="https://code.jquery.com/jquery-3.5.1.min.js"
target_file="jquery.min.js"

[files.assets.actions."ogv.js"]
action="extract_items"
source="https://github.com/brion/ogv.js/releases/download/1.8.9/ogvjs-1.8.9.zip"
zip_paths=["ogvjs-1.8.9"]
target_paths=["ogvjs"]
remove = ["ogvjs/COPYING","ogvjs/*.txt","ogvjs/*.md",]

[files.assets.actions."videojs-ogvjs.js"]
action="extract_items"
source="https://github.com/hartman/videojs-ogvjs/archive/v1.3.1.zip"
zip_paths=["videojs-ogvjs-1.3.1/dist/videojs-ogvjs.js"]
target_paths=["videojs-ogvjs.js"]

[files.assets.actions."webp-hero.polyfills.js"]
action="get_file"
source="https://unpkg.com/[email protected]/dist-cjs/polyfills.js"
target_file="polyfills.js"

[files.assets.actions."webp-hero.bundle.js"]
action="get_file"
source="https://unpkg.com/[email protected]/dist-cjs/webp-hero.bundle.js"
target_file="webp-hero.bundle.js"
70 changes: 34 additions & 36 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-openzim==0.2.1"]
build-backend = "hatchling.build"

[project]
name = "youtube2zim"
authors = [{ name = "Kiwix", email = "[email protected]" }]
keywords = ["kiwix", "zim", "offline", "youtube"]
requires-python = ">=3.10,<3.11"
requires-python = ">=3.12,<3.13"
description = "Make ZIM file from a Youtube channel, user or playlist(s)"
readme = "README.md"
license = { text = "GPL-3.0-or-later" }
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
]
dependencies = [
"python-slugify==3.0.3",
"yt-dlp", # youtube-dl should be updated as frequently as possible
"python-dateutil==2.8.0",
"jinja2>=2.11,<3.0",
"python-dateutil==2.9.0.post0",
"jinja2==3.1.4",
"MarkupSafe==2.0.1", # jinja2 dependency (https://github.com/pallets/markupsafe/issues/284)
"zimscraperlib>=2.0.0,<2.1.0",
"zimscraperlib==3.3.2",
"requests==2.31.0",
"kiwixstorage==0.8.3",
"pif==0.8.2",
]
dynamic = ["version"]
dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"]

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.metadata.hooks.openzim-metadata]
kind = "scraper"
additional-keywords = ["youtube"]

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

[project.optional-dependencies]
scripts = ["invoke==2.2.0"]
lint = ["black==23.9.1", "ruff==0.0.292"]
check = ["pyright==1.1.331"]
test = ["pytest==7.4.2", "coverage==7.3.2"]
lint = ["black==24.4.2", "ruff==0.4.4"]
check = ["pyright==1.1.363"]
test = ["pytest==8.1.1", "coverage==7.4.4"]
dev = [
"pre-commit==3.4.0",
"debugpy==1.8.0",
"pre-commit==3.7.1",
"debugpy==1.8.1",
"youtube2zim[scripts]",
"youtube2zim[lint]",
"youtube2zim[test]",
"youtube2zim[check]",
# hatchling is a dev dependency only needed for hook development on developer machine
"hatchling==1.18.0",
"humanfriendly==10.0"
]

[project.urls]
Homepage = "https://github.com/openzim/youtube"
Donate = "https://www.kiwix.org/en/support-us/"

[project.scripts]
youtube2zim = "youtube2zim.__main__:main"
youtube2zim-playlists = "youtube2zim.playlists.__main__:main"
Expand All @@ -59,12 +55,11 @@ path = "src/youtube2zim/__about__.py"
[tool.hatch.build]
exclude = ["/.github"]

[tool.hatch.build.hooks.custom]
path = "hatch_build.py"
dependencies = ["zimscraperlib>=2.0.0,<2.1.0"]

[tool.hatch.build.targets.wheel]
packages = ["src/youtube2zim"]
artifacts = [
"src/youtube2zim/templates/assets/**",
]

[tool.hatch.envs.default]
features = ["dev"]
Expand All @@ -81,7 +76,7 @@ html = "inv coverage --html --args '{args}'"

[tool.hatch.envs.lint]
template = "lint"
python = "py311"
python = "py312"
skip-install = false
features = ["scripts", "lint"]

Expand All @@ -102,13 +97,15 @@ all = "inv checkall --args '{args}'"

[tool.black]
line-length = 88
target-version = ['py311']
target-version = ['py312']
exclude = "(src/youtube2zim/templates/.*|.hatch/.*)"

[tool.ruff]
target-version = "py311"
target-version = "py312"
line-length = 88
src = ["src"]

[tool.ruff.lint]
select = [
"A", # flake8-builtins
# "ANN", # flake8-annotations
Expand Down Expand Up @@ -193,13 +190,13 @@ unfixable = [
"F401",
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
known-first-party = ["youtube2zim"]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Tests can use magic values, assertions, and relative imports
"tests/**/*" = ["PLR2004", "S101", "TID252"]

Expand All @@ -225,5 +222,6 @@ exclude_lines = ["no cov", "if __name__ == .__main__.:", "if TYPE_CHECKING:"]
include = ["src", "tests", "tasks.py"]
exclude = [".env/**", ".venv/**", "src/youtube2zim/templates", ".hatch"]
extraPaths = ["src"]
pythonVersion = "3.10"
pythonVersion = "3.12"
typeCheckingMode = "basic"
disableBytesTypePromotions = true
Loading