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

source

pub fn new(config: KMConfig) -> Self

Create a new KMClient with the given config.

§Arguments
  • config - The config to use for the client
source

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.

source

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
source

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
source

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
source

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
source

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
source

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 claim
  • wallet - The user’s point wallet (mutable).
source

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 claim
  • wallet - The user’s point wallet (mutable).
source

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 claim
  • ticket - The ticket to use to claim the episode
source

pub async fn get_user_point(&self) -> Result<UserPointResponse>

Get the user’s point.

source

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 for
  • limit - The limit of results to return
source

pub async fn get_weekly(&self) -> Result<WeeklyListResponse>

Get the weekly ranking/list.

source

pub async fn get_account(&self) -> Result<UserAccount>

Get the current user’s account information.

source

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.

source

pub async fn get_purchased(&self) -> Result<Vec<TitlePurchaseNode>>

Get the user’s purchased titles.

source

pub async fn get_favorites(&self) -> Result<TitleFavoriteResponse>

Get the user’s favorites.

source

pub async fn get_magazines(&self) -> Result<MagazineCategoryResponse>

Get the magazine list.

source

pub async fn get_genres(&self) -> Result<GenreSearchResponse>

Get the genre list.

source

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 get
  • limit - The limit of results to return
  • offset - The offset of results to return
source

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 from
  • scramble_seed - The scramble seed to use to descramble the image (only for Web, please provide it!)
  • writer - The writer to write the image to
source

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 with
  • password - The password to login with
  • mobile - Whether to login as mobile or not

Trait Implementations§

source§

impl Clone for KMClient

source§

fn clone(&self) -> KMClient

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more