Make ZIM file from a Youtube channel, user or playlist(s)
Project description
Youtube2zim
youtube2zim allows you to create a ZIM file
from a Youtube Channel/Username or one-or-more Playlists.
It downloads the videos (webm or mp4 extension – optionally
recompress them in lower-quality, smaller size), the thumbnails, the
subtitles and the authors' profile pictures; It then produces JSON files containing content for the channel, playlists, and videos, which are used by the UI, which is a Vue.js application that needs to be compiled as a static website with Vite and is then embedded inside the ZIM.
youtube2zim adheres to openZIM's Contribution Guidelines.
youtube2zim has implemented openZIM's Python bootstrap, conventions and policies v1.0.2.
Documentation
For more details / advanced usage than what is in this README, see the Manual and FAQ/FEE.
# Requirements
ffmpegfor video transcoding.deno(or another Javascript runtime, see https://github.com/yt-dlp/yt-dlp/issues/15012) for yt-dlp operations when fetching Youtube videos.Yarnto install Javascript dependencies for the Vue.js UI.
Installation
Here comes a few different ways to install youtube2zim.
Virtualenv
youtube2zim is a Python3 software. If you are not using the Docker image,
you are advised to use it in a virtualenv to avoid installing software
dependencies on your system. Hatch 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 as well, especially regarding how to configure hatch globally for proper detection of its virtual environments by Visual Studio Code).
pip3 install hatch
Start a hatch shell: this will install software including dependencies in an isolated virtual environment.
cd scraper
hatch shell
youtube2zim --help # Display youtube2zim help
Docker
docker run -v my_dir:/output ghcr.io/openzim/youtube youtube2zim --help
Usage
youtube2zim uses Youtube API v3 to fetch data from Youtube. You thus need to provide an API_KEY to use the scraper.
To get an API Key:
- Connect to Google Developers Console
- Create a new Project then Select it.
- When asked, choose Create Credentials and select the API Key type. (Credentials page)
You can then create a ZIM from a singe channel / user / handle like Vsauce:
youtube2zim --api-key "<your-api-key>" --id "Vsauce" --name "tests_hi_avanti"
When scraping a channel, you must pass one single value in --id and it can be the handle, user, or even the corresponding technical ID (see FAQ/FEE for more details).
Or you can create a ZIM from two playlists like PL3rEvTTL-Jm8cBdskZoQaDTlDT4t7F6kp and PL3rEvTTL-Jm_OuyYpMfxtJW3Mcr9fFS2Z:
youtube2zim --api-key "<your-api-key>" --id "PL3rEvTTL-Jm8cBdskZoQaDTlDT4t7F6kp,PL3rEvTTL-Jm_OuyYpMfxtJW3Mcr9fFS2Z" --name "tests_hi_avanti"
When scraping playlists, you can pass multiple playlist IDs separated by a comma in --id.
For more details / advanced usage, see the Manual.
Notes
- Your API_KEY is subject to usage quotas (10,000 requests/day by default). Be careful to not waste your quota, especially when scraping large channels.
youtube2zim-playlists
youtube2zim produces a single ZIM file for a youtube request (channel, user, handle, playlist).
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.
Usage
Sample usage:
youtube2zim-playlists --indiv-playlists --api-key XXX --id Vsauce --playlists-name="vsauce_en_playlist-{playlist_id}"
Those are the required arguments for youtube2zim-playlists but you can also pass any regular youtube2zim argument. Those will be forwarded to youtube2zim (which will be run independently for each playlist).
For more details / advanced usage, see the Manual.
Development
Before contributing be sure to check out the CONTRIBUTING.md guidelines.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file youtube2zim-3.5.0.tar.gz.
File metadata
- Download URL: youtube2zim-3.5.0.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f1b018ba879d0cf70ce53429df8863a894045bcfd3f034e30eaf6bf6bf3a884
|
|
| MD5 |
718bdd5e0bf8e0010ab3d2722fec3c9c
|
|
| BLAKE2b-256 |
d3854cf62f4b6892f9421b05a91fc2cb9b3f95c60c9017b607caf13130eb87eb
|
Provenance
The following attestation bundles were made for youtube2zim-3.5.0.tar.gz:
Publisher:
Publish.yml on openzim/youtube
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
youtube2zim-3.5.0.tar.gz -
Subject digest:
4f1b018ba879d0cf70ce53429df8863a894045bcfd3f034e30eaf6bf6bf3a884 - Sigstore transparency entry: 704996965
- Sigstore integration time:
-
Permalink:
openzim/youtube@d8ce1af19da41ebe42a52820ec96930b77734ada -
Branch / Tag:
refs/tags/v3.5.0 - Owner: https://github.com/openzim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yml@d8ce1af19da41ebe42a52820ec96930b77734ada -
Trigger Event:
release
-
Statement type:
File details
Details for the file youtube2zim-3.5.0-py3-none-any.whl.
File metadata
- Download URL: youtube2zim-3.5.0-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5cfe0fb284d64d6b47b76b257f6bef5da64ea4ee82e6ba6ab5282f761aee9cb
|
|
| MD5 |
ada1295a7812630cddf960d3087d217e
|
|
| BLAKE2b-256 |
e6b95dd5a7bc6c99b8cea7948bfea96e18cbd9ca785d848fb26b505fb18fe77a
|
Provenance
The following attestation bundles were made for youtube2zim-3.5.0-py3-none-any.whl:
Publisher:
Publish.yml on openzim/youtube
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
youtube2zim-3.5.0-py3-none-any.whl -
Subject digest:
a5cfe0fb284d64d6b47b76b257f6bef5da64ea4ee82e6ba6ab5282f761aee9cb - Sigstore transparency entry: 704996986
- Sigstore integration time:
-
Permalink:
openzim/youtube@d8ce1af19da41ebe42a52820ec96930b77734ada -
Branch / Tag:
refs/tags/v3.5.0 - Owner: https://github.com/openzim
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
Publish.yml@d8ce1af19da41ebe42a52820ec96930b77734ada -
Trigger Event:
release
-
Statement type: