-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
116 changed files
with
7,901 additions
and
3,811 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# 03.03.24 | ||
|
||
from typing import Dict, Any, List | ||
|
||
|
||
# Internal utilities | ||
from Src.Util._jsonConfig import config_manager | ||
|
||
|
||
# Config | ||
SC_SITE_NAME = config_manager.get('SITE', 'streaming_site_name') | ||
SC_DOMAIN_NOW = config_manager.get('SITE', 'streaming_domain') | ||
|
||
|
||
|
||
class Image: | ||
def __init__(self, image_data: Dict[str, Any]): | ||
self.id: int = image_data.get('id', '') | ||
self.filename: str = image_data.get('filename', '') | ||
self.type: str = image_data.get('type', '') | ||
self.imageable_type: str = image_data.get('imageable_type', '') | ||
self.imageable_id: int = image_data.get('imageable_id', '') | ||
self.created_at: str = image_data.get('created_at', '') | ||
self.updated_at: str = image_data.get('updated_at', '') | ||
self.original_url_field: str = image_data.get('original_url_field', '') | ||
self.url: str = f"https://cdn.{SC_SITE_NAME}.{SC_DOMAIN_NOW}/images/{self.filename}" | ||
|
||
def __str__(self): | ||
return f"Image(id={self.id}, filename='{self.filename}', type='{self.type}', imageable_type='{self.imageable_type}', url='{self.url}')" | ||
|
||
|
||
class Episode: | ||
def __init__(self, data: Dict[str, Any]): | ||
self.id: int = data.get('id', '') | ||
self.number: int = data.get('number', '') | ||
self.name: str = data.get('name', '') | ||
self.plot: str = data.get('plot', '') | ||
self.duration: int = data.get('duration', '') | ||
self.scws_id: int = data.get('scws_id', '') | ||
self.season_id: int = data.get('season_id', '') | ||
self.created_by: str = data.get('created_by', '') | ||
self.created_at: str = data.get('created_at', '') | ||
self.updated_at: str = data.get('updated_at', '') | ||
self.images: List[Image] = [Image(image_data) for image_data in data.get('images', [])] | ||
|
||
def __str__(self): | ||
return f"Episode(id={self.id}, number={self.number}, name='{self.name}', plot='{self.plot}', duration={self.duration} sec)" | ||
|
||
|
||
class EpisodeManager: | ||
def __init__(self): | ||
self.episodes: List[Episode] = [] | ||
|
||
def add_episode(self, episode_data: Dict[str, Any]): | ||
""" | ||
Add a new episode to the manager. | ||
Args: | ||
- episode_data (Dict[str, Any]): A dictionary containing data for the new episode. | ||
""" | ||
episode = Episode(episode_data) | ||
self.episodes.append(episode) | ||
|
||
def get_episode_by_index(self, index: int) -> Episode: | ||
""" | ||
Get an episode by its index. | ||
Args: | ||
- index (int): Index of the episode to retrieve. | ||
Returns: | ||
Episode: The episode object. | ||
""" | ||
return self.episodes[index] | ||
|
||
def get_length(self) -> int: | ||
""" | ||
Get the number of episodes in the manager. | ||
Returns: | ||
int: Number of episodes. | ||
""" | ||
return len(self.episodes) | ||
|
||
def clear(self) -> None: | ||
""" | ||
This method clears the episodes list. | ||
Args: | ||
- self: The object instance. | ||
""" | ||
self.episodes.clear() | ||
|
||
def __str__(self): | ||
return f"EpisodeManager(num_episodes={len(self.episodes)})" |
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,63 @@ | ||
# 12.04.24 | ||
|
||
class Preview: | ||
def __init__(self, data): | ||
self.id = data.get("id") | ||
self.title_id = data.get("title_id") | ||
self.created_at = data.get("created_at") | ||
self.updated_at = data.get("updated_at") | ||
self.video_id = data.get("video_id") | ||
self.is_viewable = data.get("is_viewable") | ||
self.zoom_factor = data.get("zoom_factor") | ||
self.filename = data.get("filename") | ||
self.embed_url = data.get("embed_url") | ||
|
||
def __str__(self): | ||
return f"Preview: ID={self.id}, Title ID={self.title_id}, Created At={self.created_at}, Updated At={self.updated_at}, Video ID={self.video_id}, Viewable={self.is_viewable}, Zoom Factor={self.zoom_factor}, Filename={self.filename}, Embed URL={self.embed_url}" | ||
|
||
class Genre: | ||
def __init__(self, data): | ||
self.id = data.get("id") | ||
self.name = data.get("name") | ||
self.type = data.get("type") | ||
self.hidden = data.get("hidden") | ||
self.created_at = data.get("created_at") | ||
self.updated_at = data.get("updated_at") | ||
self.pivot = data.get("pivot") | ||
|
||
def __str__(self): | ||
return f"Genre: ID={self.id}, Name={self.name}, Type={self.type}, Hidden={self.hidden}, Created At={self.created_at}, Updated At={self.updated_at}, Pivot={self.pivot}" | ||
|
||
class Image: | ||
def __init__(self, data): | ||
self.id = data.get("id") | ||
self.filename = data.get("filename") | ||
self.type = data.get("type") | ||
self.imageable_type = data.get("imageable_type") | ||
self.imageable_id = data.get("imageable_id") | ||
self.created_at = data.get("created_at") | ||
self.updated_at = data.get("updated_at") | ||
self.original_url_field = data.get("original_url_field") | ||
|
||
def __str__(self): | ||
return f"Image: ID={self.id}, Filename={self.filename}, Type={self.type}, Imageable Type={self.imageable_type}, Imageable ID={self.imageable_id}, Created At={self.created_at}, Updated At={self.updated_at}, Original URL Field={self.original_url_field}" | ||
|
||
class PreviewManager: | ||
def __init__(self, json_data): | ||
self.id = json_data.get("id") | ||
self.type = json_data.get("type") | ||
self.runtime = json_data.get("runtime") | ||
self.release_date = json_data.get("release_date") | ||
self.quality = json_data.get("quality") | ||
self.plot = json_data.get("plot") | ||
self.seasons_count = json_data.get("seasons_count") | ||
self.genres = [Genre(genre_data) for genre_data in json_data.get("genres", [])] | ||
self.preview = Preview(json_data.get("preview")) | ||
self.images = [Image(image_data) for image_data in json_data.get("images", [])] | ||
|
||
def __str__(self): | ||
genres_str = "\n".join(str(genre) for genre in self.genres) | ||
images_str = "\n".join(str(image) for image in self.images) | ||
return f"Title: ID={self.id}, Type={self.type}, Runtime={self.runtime}, Release Date={self.release_date}, Quality={self.quality}, Plot={self.plot}, Seasons Count={self.seasons_count}\nGenres:\n{genres_str}\nPreview:\n{self.preview}\nImages:\n{images_str}" | ||
|
||
|
Oops, something went wrong.