Struct tosho_kmkc::KMClient
source · pub struct KMClient { /* private fields */ }
Expand description
Main client for interacting with the SQ MU!
§Example
use tosho_kmkc::{KMClient, KMConfig, KMConfigMobile, KMConfigMobilePlatform};
#[tokio::main]
async fn main() {
let config = KMConfigMobile {
user_id: "123".to_string(),
hash_key: "abcxyz".to_string(),
platform: KMConfigMobilePlatform::Android,
};
let client = KMClient::new(KMConfig::Mobile(config));
let manga = client.get_titles(vec![10007]).await.unwrap();
println!("{:?}", manga[0]);
}
Implementations§
source§impl KMClient
impl KMClient
sourcepub fn with_proxy(&self, proxy: Proxy) -> Self
pub fn with_proxy(&self, proxy: Proxy) -> Self
Attach a proxy to the client.
This will clone the client and return a new client with the proxy attached.
§Arguments
proxy
- The proxy to attach to the client
Get the underlying cookie store.
sourcepub async fn get_episodes(&self, episodes: Vec<i32>) -> Result<Vec<EpisodeNode>>
pub async fn get_episodes(&self, episodes: Vec<i32>) -> Result<Vec<EpisodeNode>>
Get the list of episodes from the given list of episode IDs
§Arguments
episodes
- The list of episode IDs to get
sourcepub async fn get_titles(&self, titles: Vec<i32>) -> Result<Vec<TitleNode>>
pub async fn get_titles(&self, titles: Vec<i32>) -> Result<Vec<TitleNode>>
Get the list of titles from the given list of title IDs
§Arguments
titles
- The list of title IDs to get
sourcepub async fn get_episode_viewer(
&self,
episode: &EpisodeNode,
) -> Result<EpisodeViewerResponse>
pub async fn get_episode_viewer( &self, episode: &EpisodeNode, ) -> Result<EpisodeViewerResponse>
Get the episode viewer for the given episode ID.
The following will return an enum depending on the config used.
If you’re using web config, please remember to descramble the images
with the imaging::descramble_image
function.
§Arguments
episode
- The episode to get the viewer for
sourcepub async fn finish_episode_viewer(
&self,
episode: &EpisodeNode,
) -> Result<EpisodeViewerFinishResponse>
pub async fn finish_episode_viewer( &self, episode: &EpisodeNode, ) -> Result<EpisodeViewerFinishResponse>
Finish the episode viewer for the given episode ID.
You should be using this after you fetch the episode viewer. The following would claim the bonus point available.
§Arguments
episode
- The episode to get the viewer for
sourcepub async fn get_title_ticket(
&self,
title_id: i32,
) -> Result<TitleTicketListNode>
pub async fn get_title_ticket( &self, title_id: i32, ) -> Result<TitleTicketListNode>
Get the title ticket for the given title ID.
§Arguments
title_id
- The title ID to get the ticket for
sourcepub async fn claim_episode(
&self,
episode: &EpisodeNode,
wallet: &mut UserPoint,
) -> Result<EpisodePurchaseResponse>
pub async fn claim_episode( &self, episode: &EpisodeNode, wallet: &mut UserPoint, ) -> Result<EpisodePurchaseResponse>
Claim or purchase an episode with a user’s point.
§Arguments
episode
- The episode to claimwallet
- The user’s point wallet (mutable).
sourcepub async fn claim_episodes(
&self,
episodes: Vec<&EpisodeNode>,
wallet: &mut UserPoint,
) -> Result<BulkEpisodePurchaseResponse>
pub async fn claim_episodes( &self, episodes: Vec<&EpisodeNode>, wallet: &mut UserPoint, ) -> Result<BulkEpisodePurchaseResponse>
Bulk claim or purchase episodes with a user’s point.
§Arguments
episodes
- The episodes to claimwallet
- The user’s point wallet (mutable).
sourcepub async fn claim_episode_with_ticket(
&self,
episode_id: i32,
ticket: &TicketInfoType,
) -> Result<(StatusResponse, bool)>
pub async fn claim_episode_with_ticket( &self, episode_id: i32, ticket: &TicketInfoType, ) -> Result<(StatusResponse, bool)>
Claim or purchase an episode with a ticket.
This will return the status of the claim, and whether or not the ticket is a title ticket.
§Arguments
episode_id
- The episode ID to claimticket
- The ticket to use to claim the episode
sourcepub async fn get_user_point(&self) -> Result<UserPointResponse>
pub async fn get_user_point(&self) -> Result<UserPointResponse>
Get the user’s point.
sourcepub async fn search(
&self,
query: &str,
limit: Option<u32>,
) -> Result<Vec<TitleNode>>
pub async fn search( &self, query: &str, limit: Option<u32>, ) -> Result<Vec<TitleNode>>
Search for a title by name.
§Arguments
query
- The query to search forlimit
- The limit of results to return
sourcepub async fn get_weekly(&self) -> Result<WeeklyListResponse>
pub async fn get_weekly(&self) -> Result<WeeklyListResponse>
Get the weekly ranking/list.
sourcepub async fn get_account(&self) -> Result<UserAccount>
pub async fn get_account(&self) -> Result<UserAccount>
Get the current user’s account information.
sourcepub async fn get_user(&self, user_id: u32) -> Result<UserInfoResponse>
pub async fn get_user(&self, user_id: u32) -> Result<UserInfoResponse>
Get a user information
This is different to Self::get_account
as it needs
the user ID to get the user information.
sourcepub async fn get_purchased(&self) -> Result<Vec<TitlePurchaseNode>>
pub async fn get_purchased(&self) -> Result<Vec<TitlePurchaseNode>>
Get the user’s purchased titles.
sourcepub async fn get_favorites(&self) -> Result<TitleFavoriteResponse>
pub async fn get_favorites(&self) -> Result<TitleFavoriteResponse>
Get the user’s favorites.
sourcepub async fn get_magazines(&self) -> Result<MagazineCategoryResponse>
pub async fn get_magazines(&self) -> Result<MagazineCategoryResponse>
Get the magazine list.
sourcepub async fn get_genres(&self) -> Result<GenreSearchResponse>
pub async fn get_genres(&self) -> Result<GenreSearchResponse>
Get the genre list.
sourcepub async fn get_all_rankings(
&self,
ranking_id: u32,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<RankingListResponse>
pub async fn get_all_rankings( &self, ranking_id: u32, limit: Option<u32>, offset: Option<u32>, ) -> Result<RankingListResponse>
Get title rankings for a specific ranking ID.
See [static@constants::RANKING_TABS
] for the list of available ranking IDs.
§Arguments
ranking_id
- The ranking ID to getlimit
- The limit of results to returnoffset
- The offset of results to return
sourcepub async fn stream_download(
&self,
url: &str,
scramble_seed: Option<u32>,
writer: impl AsyncWrite + Unpin,
) -> Result<()>
pub async fn stream_download( &self, url: &str, scramble_seed: Option<u32>, writer: impl AsyncWrite + Unpin, ) -> Result<()>
Stream download the image from the given URL.
The URL can be obtained from Self::get_episode_viewer
The Web version will be automatically descrambled, so it will not be a “stream” download.
§Arguments
url
- The URL to download the image fromscramble_seed
- The scramble seed to use to descramble the image (only for Web, please provide it!)writer
- The writer to write the image to
sourcepub async fn login(
email: &str,
password: &str,
mobile_platform: Option<KMConfigMobilePlatform>,
) -> Result<KMLoginResult>
pub async fn login( email: &str, password: &str, mobile_platform: Option<KMConfigMobilePlatform>, ) -> Result<KMLoginResult>
Login to the API with the given username and password.
You can use this to get either Web version of the token or the Mobile version of the token.
§Arguments
email
- The email to login withpassword
- The password to login withmobile
- Whether to login as mobile or not
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KMClient
impl !RefUnwindSafe for KMClient
impl Send for KMClient
impl Sync for KMClient
impl Unpin for KMClient
impl !UnwindSafe for KMClient
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more