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 video (webm or mp4 format – optionnaly recompress them in lower-quality, smaller size), the thumbnails, the subtitles and the authors' profile pictures ; then, it create a static HTML files folder of it before creating a ZIM off of it.
Requirements
ffmpegfor video transcoding (only used with--lower-quality).zimwriterfsfor ZIM file packaging. Use--no-zimto skip this step.curlandunzipto install JS dependencies. Seeget_js_deps.shif you want to do it manually.
Installation
youtube2zim is a python program. if you are not using the docker image, you are advised to use it in a virtualenv. See requirements.txt for the list of python dependencies.
docker
docker run -v my_dir:/output openzim/youtube youtube2zim --help
pip
pip install youtube2zim
youtube2zim --help
source
python 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:
- 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)
youtube2zim --api-key "<your-api-key>" --type user --id "Vsauce"
Notes
- Your API_KEY is subject to usage quotas (10,000 requests/day) so use
--keep --skip-downloadwhen adjusting parameters and branding to not waste your quota. - On macOS, the locale setting is buggy. You need to launch it with
LANGUAGEenvironment variable (as ISO-639-1) for the translations to work.
LANGUAGE=fr youtube2zim --language fra
Developers note
In order to support all platform, we default to webm video format. mp4 one (h264), is not available in Webview on most platform due to patent restrictions.
On the other hand, webm is not supported in Safari (macOS, iOS).
We thus use ogv.js, to play webm videos on browsers that don't support it. Using video.js, we default to native playback if supported.
ogv.js is an emscripten-based JS decoder for webm and thus dynamically loads differents parts at run-time on platforms that needs them. It has two consequences:
file://scheme doesn't work as the binary.wasmfiles are sent naively astext/htmlinstead ofapplication/oct-stream. If you want to use the HTML generated folder instead of ZIM, serve it through a web server and configure the Content-Type response.- ZIM places JS files under the
/-/namespace and binary ones under the/I/one. Dynamically loading of JS and WASM files withinogv.jsrequires us to tweak it to introduce some ZIM-specific logic. Seefix_ogvjs_dist.py.
Because the pagination system is implemented in JS, we also need to generate links there. For that to work both in static HTML and in-ZIM, we detect it using a <link id="favicon"> in HTML files. This link needs to be present and parsed before loading the help zim_prefix.js script.
i18n
youtube2zim has very minimal non-content text but still uses gettext through babel to internationalize.
To add a new locale (fr in this example, use only ISO-639-1):
- init for your locale:
pybabel init -d locale -l fr - make sure the POT is up to date
pybabel extract -o youtube2zim/locale/messages.pot youtube2zim - update your locale's catalog
pybabel update -d youtube2zim/locale/ -l fr -i youtube2zim/locale/messages.pot - translate the PO file (poedit is your friend)
- compile updated translation
pybabel compile -d youtube2zim/locale -l fr
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-2.0.0.tar.gz.
File metadata
- Download URL: youtube2zim-2.0.0.tar.gz
- Upload date:
- Size: 3.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cc7a896f96a5588d4a1bbffe207c3219364332fcdae4e946e5bc533ed2cf642
|
|
| MD5 |
9f11aea1b561094955e423c01036781b
|
|
| BLAKE2b-256 |
95ebdf5bf8e71b5d7330111270df724180e1a38d8b87108a34fd3ed3928a74c9
|
File details
Details for the file youtube2zim-2.0.0-py3-none-any.whl.
File metadata
- Download URL: youtube2zim-2.0.0-py3-none-any.whl
- Upload date:
- Size: 3.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04142aa70f8997810b9215b9fc5e8f536183c28899413021d69354e73424a28c
|
|
| MD5 |
cfc91a6b407b741700bbe99c4efcc324
|
|
| BLAKE2b-256 |
aef59dc868e5a7e21032be35a0de07a77c936b6529d09aaab6a76578a4b162df
|