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

Generate JSON files to be consumed by Vue.js UI #219

Merged
merged 3 commits into from
Jun 11, 2024
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move scraper files to `scraper` subfolder and update workflows
- Bump `requests` package from 2.32.0 to 2.32.2
- Initialize new Vue.js project in `zimui` subfolder
- Update dependencies in pyproject.toml (pydantic, pyhumps, python-slugify)
- Update scraper to generate JSON files for `zimui` (#212)
- Remove old UI files and methods: template files (home.html, article.html) and `make_html_files` method in scraper.py
- Remove broken locale folder and files used for translation; translation will be restored with #222

## [2.3.0] - 2024-05-22

Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ LABEL org.opencontainers.image.source https://github.com/openzim/youtube
# Install necessary packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
locales-all \
wget \
unzip \
ffmpeg \
Expand Down
4 changes: 3 additions & 1 deletion scraper/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ requires-python = ">=3.12,<3.13"
description = "Make ZIM file from a Youtube channel, user or playlist(s)"
readme = "../README.md"
dependencies = [
"python-slugify==3.0.3",
"python-slugify==8.0.4",
"yt-dlp", # youtube-dl should be updated as frequently as possible
"python-dateutil==2.9.0.post0",
"jinja2==3.1.4",
"zimscraperlib==3.3.2",
"requests==2.32.2",
"kiwixstorage==0.8.3",
"pif==0.8.2",
"pydantic==2.7.2",
"pyhumps==3.8.0",
]
dynamic = ["authors", "classifiers", "keywords", "license", "version", "urls"]

Expand Down
35 changes: 0 additions & 35 deletions scraper/src/youtube2zim/locale/fr/LC_MESSAGES/messages.po

This file was deleted.

94 changes: 94 additions & 0 deletions scraper/src/youtube2zim/schemas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from humps import camelize
from pydantic import BaseModel


class CamelModel(BaseModel):
"""Model to transform Python snake_case into JSON camelCase."""

class Config:
alias_generator = camelize
populate_by_name = True


class Author(CamelModel):
channel_id: str
channel_title: str
profile_path: str | None = None
banner_path: str | None = None


class Subtitle(CamelModel):
"""Class to serialize data about a YouTube video subtitle."""

code: str
name: str


class Video(CamelModel):
"""Class to serialize data about a YouTube video."""

id: str
title: str
description: str
author: Author
publication_date: str
video_path: str
thumbnail_path: str | None = None
subtitle_path: str | None = None
subtitle_list: list[Subtitle]
duration: str


class VideoPreview(CamelModel):
"""Class to serialize data about a YouTube video for preview."""

slug: str
id: str
title: str
thumbnail_path: str | None = None
duration: str


class Playlist(CamelModel):
"""Class to serialize data about a YouTube playlist."""

id: str
author: Author
title: str
description: str
publication_date: str
thumbnail_path: str | None = None
videos: list[VideoPreview]
videos_count: int


class PlaylistPreview(CamelModel):
"""Class to serialize data about a YouTube playlist for preview."""

slug: str
id: str
title: str
thumbnail_path: str | None = None
videos_count: int
main_video_slug: str


class Playlists(CamelModel):
"""Class to serialize data about a list of YouTube playlists."""

playlists: list[PlaylistPreview]


class Channel(CamelModel):
"""Class to serialize data about a YouTube channel."""

id: str
title: str
description: str
channel_name: str
channel_description: str
profile_path: str | None = None
banner_path: str | None = None
joined_date: str
collection_type: str
main_playlist: str | None = None
Loading
Loading