-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from openzim/generate_json
Generate JSON files to be consumed by Vue.js UI
- Loading branch information
Showing
12 changed files
with
327 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.