Skip to content

Commit

Permalink
Change stream related function names and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Apr 3, 2024
1 parent 3b02268 commit ec449dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/media/anime/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ macro_rules! impl_media_video {
/// All streams are drm encrypted, decryption is not handled in this crate, so you
/// must do this yourself.
pub async fn stream(&self) -> Result<$crate::media::Stream> {
$crate::media::Stream::drm_from_id(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
$crate::media::Stream::from_id_drm(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
}

/// Streams for this episode / movie.
/// Unlike [`Self::stream`] the streams may not be DRM encrypted (at least at the
/// time of writing they aren't but this might change at any time).
pub async fn stream_maybe_without_drm(&self) -> Result<$crate::media::Stream> {
$crate::media::Stream::maybe_without_drm_from_id(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
$crate::media::Stream::from_id_maybe_without_drm(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
}

/// Check if the episode / movie can be watched.
Expand Down
4 changes: 2 additions & 2 deletions src/media/music/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ macro_rules! impl_media_music {
/// All streams are drm encrypted, decryption is not handled in this crate, so you
/// must do this yourself.
pub async fn stream(&self) -> Result<$crate::media::Stream> {
$crate::media::Stream::drm_from_id(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, Some("music".to_string())).await
$crate::media::Stream::from_id_drm(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, Some("music".to_string())).await
}

/// Streams for this episode / movie.
/// Unlike [`Self::stream`] the streams may not be DRM encrypted (at least at the
/// time of writing they aren't but this might change at any time).
pub async fn stream_maybe_without_drm(&self) -> Result<$crate::media::Stream> {
$crate::media::Stream::maybe_without_drm_from_id(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
$crate::media::Stream::from_id_maybe_without_drm(&$crate::Crunchyroll { executor: self.executor.clone() }, &self.id, None).await
}

/// Check if the music video / concert can be watched.
Expand Down
30 changes: 15 additions & 15 deletions src/media/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,19 @@ pub struct StreamSession {
}

impl Stream {
/// Uses the endpoint which is also used in the Chrome browser to receive streams. This endpoint
/// always returns DRM encrypted streams.
pub async fn drm_from_id(
/// Requests a stream from an id with is always DRM encrypted.
pub async fn from_id_drm(
crunchyroll: &Crunchyroll,
id: impl AsRef<str>,
optional_media_type: Option<String>,
) -> Result<Self> {
Self::from_id(crunchyroll, id, "web", "chrome", optional_media_type).await
}

/// Uses the endpoint which is also used in the Nintendo Switch to receive streams. At the time
/// of writing, this is the only known endpoint that still delivers streams without DRM, but
/// this might change at any time (hence the "mabye" in the function name).
pub async fn maybe_without_drm_from_id(
/// Requests a stream from an id with is maybe DRM free. Check
/// [`Stream::session::uses_stream_limits`], if its `true`, the stream is DRM encrypted, if
/// `false` not.
pub async fn from_id_maybe_without_drm(
crunchyroll: &Crunchyroll,
id: impl AsRef<str>,
optional_media_type: Option<String>,
Expand Down Expand Up @@ -133,10 +132,11 @@ impl Stream {
/// Requests all available video and audio streams. Returns [`None`] if the requested hardsub
/// isn't available. The first [`Vec<StreamData>`] contains only video streams, the second only
/// audio streams.
/// You will run into an error when requesting this function too often without invalidating the
/// data. Crunchyroll only allows a certain amount of stream data to be requested at the same
/// time, typically the exact amount depends on the type of (premium) subscription you have. You
/// can use [`Stream::invalidate`] to invalidate all stream data for this stream.
/// If the stream is DRM encrypted ([`Stream::session::uses_stream_limit`] is `true` if the
/// streams are encrypted) you will run into an error when requesting this function too often
/// without invalidating the data. Crunchyroll only allows a certain amount of stream data to be
/// requested at the same time, typically the exact amount depends on the type of (premium)
/// subscription you have. You can use [`Stream::invalidate`] to invalidate all stream data for this stream.
pub async fn stream_data(
&self,
hardsub: Option<Locale>,
Expand Down Expand Up @@ -213,7 +213,7 @@ impl Stream {
for id in version_ids {
if self.session.uses_stream_limits {
result.push(
Self::drm_from_id(
Self::from_id_drm(
&Crunchyroll {
executor: self.executor.clone(),
},
Expand All @@ -224,7 +224,7 @@ impl Stream {
)
} else {
result.push(
Self::maybe_without_drm_from_id(
Self::from_id_maybe_without_drm(
&Crunchyroll {
executor: self.executor.clone(),
},
Expand All @@ -251,7 +251,7 @@ impl Stream {
for id in version_ids {
if self.session.uses_stream_limits {
result.push(
Self::drm_from_id(
Self::from_id_drm(
&Crunchyroll {
executor: self.executor.clone(),
},
Expand All @@ -262,7 +262,7 @@ impl Stream {
)
} else {
result.push(
Self::maybe_without_drm_from_id(
Self::from_id_maybe_without_drm(
&Crunchyroll {
executor: self.executor.clone(),
},
Expand Down

0 comments on commit ec449dc

Please sign in to comment.