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 extension – 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).curlandunzipto install Javascript dependencies. Seeget_js_deps.shif you want to do it manually.
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
dependences on your system.
virtualenv -p python3 ./ # Create virtualenv
source bin/activate # Activate the virtualenv
pip3 install youtube2zim # Install dependencies
youtube2zim --help # Display youtube2zim help
At the end, call deactivate to quit the virtual environment.
See requirements.txt for the list of python dependencies.
Docker
docker run -v my_dir:/output openzim/youtube youtube2zim --help
Globally (on GNU/Linux)
sudo pip3 install -U youtube2zim
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
--only_test_brandingwhen adjusting parameters and branding to not waste your quota. - If you encounter issues reading ZIM files created using this scraper, please take a look at the Compatibility Matrix before opening a ticket.
youtube2zim-playlists
youtube2zim produces a single ZIM file for a youtube request (channel, user, playlists.
youtube2zim-playlists allows you to create one ZIM file per playlist instead.
This script is a wrapper around youtube2zim and is bundled with the main package.
Usage
youtube2zim-playlists --help
Sample usage:
youtube2zim-playlists --indiv-playlists --api-key XXX --type user --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).
Specificities:
--titleand--descriptionare mutually exclusive with--playlists-titleand--playlists-description.- If using
--titleor--description, all your playlists ZIMs will have the same, static metadata. This is rarely wanted. --playlists-titleand--playlists-descriptionallows you to dynamically customize them via some playlist-related variables:{title}: the playlist title{description}: the playlist description{slug}: slugified version of the playlist title{playlist_id}: playlist ID on youtube{creator_id}: playlist's owner channel/user ID.{creator_name}: playlist's owner channel/user name.
- You can omit them and
youtube2zimwill auto-generate those. - you must specify
--playlists-name(supports variables listed above). --playlists-nameis used to set theNamemetadata of the ZIM (should be unique) and if not set separately, the output file name for the ZIM.--metadata-fromallows to specify a path or URL to a JSON file specifying custom static metadata for individual playlists. Format:
{
"<playlist-id>": {
"name": "",
"zim-file": "",
"title": "",
"description": "",
"tags": "",
"creator": "",
"profile": "",
"banner": ""
}
}
All fields are optional and taken from command-line/default if not found. <playlist-id> represents the Youtube Playlist ID.
If you feel the need for setting additional details in this file, chances are you should run youtube2zim independently for that playlist (still possible!)
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-2.1.14.tar.gz.
File metadata
- Download URL: youtube2zim-2.1.14.tar.gz
- Upload date:
- Size: 4.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bfc86f85f2273d385054ac94dd5122f6abdf02ef9e72e039580bb654f49fea23
|
|
| MD5 |
0fc8a437ee92050566492f7a0d4240f1
|
|
| BLAKE2b-256 |
6ea0c1dca3787478f7fadc1259ef5a5b67bff647d18805b0b920b0dd96265c0c
|
File details
Details for the file youtube2zim-2.1.14-py3-none-any.whl.
File metadata
- Download URL: youtube2zim-2.1.14-py3-none-any.whl
- Upload date:
- Size: 4.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84340fa55604254d799e597dea01983c4c43f2d94308e9c47d0293d2a95d55bc
|
|
| MD5 |
685540e507757863e0e73c639c336135
|
|
| BLAKE2b-256 |
74870381c435087e47afffcc43ee8c568d47cf423a469fb8993f262afdb8ee5f
|