Skip to content

Commit

Permalink
Merge pull request #219 from openzim/generate_json
Browse files Browse the repository at this point in the history
Generate JSON files to be consumed by Vue.js UI
  • Loading branch information
benoit74 authored Jun 11, 2024
2 parents 43b0fa2 + 0d7050f commit dff542d
Show file tree
Hide file tree
Showing 12 changed files with 327 additions and 322 deletions.
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

0 comments on commit dff542d

Please sign in to comment.