use std::str::FromStr;
use tosho_macros::AutoGetter;
use crate::helper::SubscriptionPlan;
use super::{
Banner, Chapter, ChapterGroup, Label, Language, PublisherItem, Tag, TitleUpdateStatus,
UserSubscription, UserTickets,
};
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct Title {
#[prost(uint64, tag = "1")]
id: u64,
#[prost(string, tag = "2")]
title: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
author: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
portrait: ::prost::alloc::string::String,
#[prost(string, tag = "5")]
landscape: ::prost::alloc::string::String,
#[prost(uint64, tag = "6")]
view_count: u64,
#[prost(enumeration = "Language", tag = "7")]
#[skip_field]
language: i32,
#[prost(enumeration = "TitleUpdateStatus", tag = "8")]
#[skip_field]
status: i32,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleDetail {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(string, tag = "2")]
image: ::prost::alloc::string::String,
#[prost(string, tag = "3")]
overview: ::prost::alloc::string::String,
#[prost(string, tag = "4")]
background_image: ::prost::alloc::string::String,
#[prost(int64, optional, tag = "5")]
#[skip_field]
next_update: ::core::option::Option<i64>,
#[prost(uint64, optional, tag = "6")]
#[skip_field]
update_frequency: ::core::option::Option<u64>,
#[prost(string, optional, tag = "7")]
#[skip_field]
viewing_period: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "8")]
#[skip_field]
non_appearance_message: ::core::option::Option<::prost::alloc::string::String>,
#[prost(message, repeated, tag = "9")]
first_chapters: ::prost::alloc::vec::Vec<Chapter>,
#[prost(message, repeated, tag = "10")]
last_chapters: ::prost::alloc::vec::Vec<Chapter>,
#[prost(message, repeated, tag = "11")]
banners: ::prost::alloc::vec::Vec<Banner>,
#[prost(message, repeated, tag = "12")]
recommended_titles: ::prost::alloc::vec::Vec<Title>,
#[prost(bool, tag = "14")]
simulpublish: bool,
#[prost(bool, tag = "15")]
subscribed: bool,
#[prost(enumeration = "super::TitleRating", tag = "16")]
#[skip_field]
rating: i32,
#[prost(bool, tag = "17")]
descending: bool,
#[prost(uint64, tag = "18")]
view_count: u64,
#[prost(message, repeated, tag = "19")]
publishers: ::prost::alloc::vec::Vec<PublisherItem>,
#[prost(message, repeated, tag = "20")]
title_banners: ::prost::alloc::vec::Vec<Banner>,
#[prost(message, optional, tag = "21")]
#[copyable]
user_tickets: ::core::option::Option<UserTickets>,
#[prost(message, repeated, tag = "22")]
ticket_chapters: ::prost::alloc::vec::Vec<Chapter>,
#[prost(message, repeated, tag = "23")]
ticket_titles: ::prost::alloc::vec::Vec<Title>,
#[prost(bool, tag = "24")]
has_in_between: bool,
#[prost(message, optional, tag = "25")]
publisher_banner: ::core::option::Option<Banner>,
#[prost(message, repeated, tag = "27")]
other_languages: ::prost::alloc::vec::Vec<TitleLanguages>,
#[prost(message, repeated, tag = "28")]
chapter_groups: ::prost::alloc::vec::Vec<ChapterGroup>,
#[prost(string, tag = "30")]
region_code: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "31")]
tags: ::prost::alloc::vec::Vec<Tag>,
#[prost(message, tag = "32")]
title_labels: ::core::option::Option<TitleLabels>,
#[prost(message, optional, tag = "33")]
user_subscription: ::core::option::Option<UserSubscription>,
#[prost(message, optional, tag = "34")]
label: ::core::option::Option<Label>,
#[prost(bool, tag = "35")]
first_time_free: bool,
}
impl TitleDetail {
pub fn flat_chapters_group(&self) -> Vec<Chapter> {
self.chapter_groups
.iter()
.flat_map(|group| group.flatten())
.collect()
}
pub fn chapter_groups_mut(&mut self) -> &mut Vec<ChapterGroup> {
&mut self.chapter_groups
}
}
#[derive(Clone, Copy, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleLanguages {
#[prost(uint64, tag = "1")]
id: u64,
#[prost(enumeration = "Language", tag = "2")]
#[skip_field]
language: i32,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleLabels {
#[prost(enumeration = "super::TitleReleaseSchedule", tag = "1")]
#[skip_field]
release_schedule: i32,
#[prost(bool, tag = "2")]
simulpublish: bool,
#[prost(string, tag = "3")]
#[skip_field]
plan_type: ::prost::alloc::string::String,
}
impl TitleLabels {
pub fn plan_type(&self) -> SubscriptionPlan {
match SubscriptionPlan::from_str(&self.plan_type) {
Ok(plan) => plan,
Err(_) => SubscriptionPlan::Basic,
}
}
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleList {
#[prost(string, tag = "1")]
name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<Title>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleListV2 {
#[prost(string, tag = "1")]
name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<Title>,
#[prost(message, repeated, tag = "3")]
tags: ::prost::alloc::vec::Vec<Tag>,
#[prost(message, optional, tag = "4")]
label: ::core::option::Option<Label>,
#[prost(int64, optional, tag = "5")]
#[skip_field]
next_start_at: ::core::option::Option<i64>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleListOnly {
#[prost(message, repeated, tag = "1")]
titles: ::prost::alloc::vec::Vec<Title>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleListOnlyV2 {
#[prost(message, repeated, tag = "1")]
titles: ::prost::alloc::vec::Vec<TitleListV2>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpdatedTitle {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(uint64, tag = "2")]
chapter_id: u64,
#[prost(string, optional, tag = "3")]
#[skip_field]
chapter_title: ::core::option::Option<::prost::alloc::string::String>,
#[prost(string, optional, tag = "4")]
#[skip_field]
chapter_subtitle: ::core::option::Option<::prost::alloc::string::String>,
#[prost(bool, tag = "5")]
latest: bool,
#[prost(bool, tag = "6")]
long_strip_only: bool,
#[prost(bool, tag = "7")]
horizontal_only: bool,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpdatedTitleGroup {
#[prost(string, tag = "1")]
name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<UpdatedTitle>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpdatedTitleList {
#[prost(message, repeated, tag = "1")]
updates: ::prost::alloc::vec::Vec<UpdatedTitleGroup>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpdatedTitleGroupOriginal {
#[prost(string, tag = "1")]
name: ::prost::alloc::string::String,
#[prost(string, tag = "2")]
chapter_number: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "3")]
titles: ::prost::alloc::vec::Vec<UpdatedTitle>,
#[prost(uint64, tag = "4")]
view_count: u64,
#[prost(enumeration = "TitleUpdateStatus", tag = "5")]
#[skip_field]
status: i32,
#[prost(int64, tag = "6")]
start_at: i64,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpdatedTitleGroupV2 {
#[prost(string, tag = "1")]
name: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<UpdatedTitleGroupOriginal>,
#[prost(uint64, tag = "3")]
days: u64,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FeaturedTitleContents {
#[prost(message, optional, tag = "1")]
banner: ::core::option::Option<Banner>,
#[prost(message, optional, tag = "2")]
titles: ::core::option::Option<TitleList>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FeaturedTitles {
#[prost(message, optional, tag = "1")]
main: ::core::option::Option<Banner>,
#[prost(message, optional, tag = "2")]
sub1: ::core::option::Option<Banner>,
#[prost(message, optional, tag = "3")]
sub2: ::core::option::Option<Banner>,
#[prost(message, repeated, tag = "4")]
contents: ::prost::alloc::vec::Vec<FeaturedTitleContents>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FeaturedTitleContentsV2 {
#[prost(message, optional, tag = "1")]
banner: ::core::option::Option<Banner>,
#[prost(message, optional, tag = "2")]
titles: ::core::option::Option<TitleList>,
#[prost(message, repeated, tag = "3")]
ranked_titles: ::prost::alloc::vec::Vec<TitleRankingGroup>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FeaturedTitlesV2 {
#[prost(message, repeated, tag = "1")]
banners: ::prost::alloc::vec::Vec<Banner>,
#[prost(message, repeated, tag = "4")]
contents: ::prost::alloc::vec::Vec<FeaturedTitleContentsV2>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct SubscribedTitle {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(bool, tag = "2")]
latest: bool,
#[prost(bool, tag = "3")]
subscribed: bool,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct UpcomingChapterTitle {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(string, tag = "2")]
chapter_name: ::prost::alloc::string::String,
#[prost(int64, tag = "3")]
release_at: i64,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleUpdated {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(string, tag = "2")]
updated_at: ::prost::alloc::string::String,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleUpdatedV2 {
#[prost(message, repeated, tag = "1")]
titles: ::prost::alloc::vec::Vec<TitleListV2>,
#[prost(string, tag = "2")]
updated_at: ::prost::alloc::string::String,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleUpdates {
#[prost(message, repeated, tag = "1")]
updates: ::prost::alloc::vec::Vec<TitleUpdated>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleUpdatesV2 {
#[prost(message, repeated, tag = "1")]
updates: ::prost::alloc::vec::Vec<TitleUpdatedV2>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleTicket {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(uint64, tag = "2")]
first_chapter: u64,
#[prost(uint64, tag = "3")]
last_chapter: u64,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleTicketList {
#[prost(message, repeated, tag = "1")]
titles: ::prost::alloc::vec::Vec<TitleTicket>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct HighlightedTitle {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(uint64, tag = "2")]
chapter_id: u64,
#[prost(string, repeated, tag = "3")]
pages: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(uint64, tag = "4")]
height: u64,
#[prost(uint64, tag = "5")]
width: u64,
#[prost(bool, tag = "6")]
vertical_only: bool,
#[prost(bool, tag = "7")]
horizontal_only: bool,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FreeTitle {
#[prost(message, tag = "1")]
title: ::core::option::Option<Title>,
#[prost(string, tag = "2")]
updated_at: ::prost::alloc::string::String,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct FreeTitles {
#[prost(message, repeated, tag = "1")]
titles: ::prost::alloc::vec::Vec<FreeTitle>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct LabelledTitle {
#[prost(string, tag = "1")]
label: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<Title>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct LabelledTitles {
#[prost(message, tag = "1")]
label: ::core::option::Option<Label>,
#[prost(message, repeated, tag = "2")]
labels: ::prost::alloc::vec::Vec<LabelledTitle>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleRankingGroup {
#[prost(uint64, tag = "1")]
original_title: u64,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<Title>,
#[prost(uint64, tag = "3")]
ranking: u64,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct TitleRankingList {
#[prost(message, repeated, tag = "1")]
banners: ::prost::alloc::vec::Vec<Banner>,
#[prost(int64, tag = "2")]
updated_at: i64,
#[prost(message, repeated, tag = "3")]
titles: ::prost::alloc::vec::Vec<TitleRankingGroup>,
}
#[derive(Clone, AutoGetter, PartialEq, ::prost::Message)]
pub struct SubscriptionTitles {
#[prost(string, tag = "1")]
#[skip_field]
plan: ::prost::alloc::string::String,
#[prost(message, repeated, tag = "2")]
titles: ::prost::alloc::vec::Vec<Title>,
}
impl SubscriptionTitles {
pub fn plan(&self) -> SubscriptionPlan {
match SubscriptionPlan::from_str(&self.plan) {
Ok(plan) => plan,
Err(_) => SubscriptionPlan::Basic,
}
}
}