|
1 | 1 | //! # crunchyroll-rs
|
2 | 2 | //!
|
3 |
| -//! A easy-to-use, batteries-included library for the undocumented |
| 3 | +//! An easy-to-use, batteries-included library for the undocumented |
4 | 4 | //! [Crunchyroll](https://www.crunchyroll.com/) api, completely written in Rust.
|
5 | 5 | //!
|
6 | 6 | //! You can use a premium account as well as a non-premium account to use this library, but you
|
|
61 | 61 | //! [`media::Stream`] has all required information to access the streams.
|
62 | 62 | //!
|
63 | 63 | //! ```
|
64 |
| -//! let streams = episode |
65 |
| -//! .streams() |
| 64 | +//! let stream = episode |
| 65 | +//! .stream() |
66 | 66 | //! .await?;
|
67 | 67 | //! ```
|
68 | 68 | //!
|
69 |
| -//! Crunchyroll uses the [HLS] and [DASH] video streaming formats to distribute their streams. The |
70 |
| -//! logic to work with this formats is already implemented |
71 |
| -//! into this crate. |
72 |
| -//! |
73 |
| -//! The feature `hls-stream` and / or `dash-stream` must be activated to get streams. `hls-stream` |
74 |
| -//! is activated by default and should be used if you want to get the video + audio combined |
75 |
| -//! ([`media::Stream::hls_streaming_data`]). `dash-stream` should be used if you want to get |
76 |
| -//! the audio and video streams separately ([`media::Stream::dash_streaming_data`]). |
| 69 | +//! Crunchyroll uses the [DASH] video streaming format to distribute their streams. The logic to |
| 70 | +//! work with this formats is already implemented into this crate. |
77 | 71 | //!
|
78 | 72 | //! ```
|
79 |
| -//! let streaming_data = streams |
80 |
| -//! .hls_streaming_data(None) |
81 |
| -//! .await?; |
| 73 | +//! let (video_streams, audio_streams) = stream |
| 74 | +//! .stream_data(None) |
| 75 | +//! .await? |
| 76 | +//! .unwrap(); |
82 | 77 | //!
|
83 |
| -//! // sort the streams to get the stream with the best resolution at first |
84 |
| -//! streaming_data.sort_by(|a, b| a.resolution.width.cmp(&b.resolution.width).reverse()); |
| 78 | +//! // sort the streams to get the stream with the best resolution / bitrate at first |
| 79 | +//! video_streams.sort_by(|a, b| a.bandwidth.cmp(&b.bandwidth).reverse()); |
| 80 | +//! audio_streams.sort_by(|a, b| a.bandwidth.cmp(&b.bandwidth).reverse()); |
85 | 81 | //!
|
86 | 82 | //! let sink = &mut std::io::sink();
|
87 | 83 | //!
|
88 | 84 | //! // get the segments / video chunks of the first stream (which is the best after it got sorted
|
89 | 85 | //! // above)
|
90 |
| -//! let segments = streaming_data[0].segments().await?; |
| 86 | +//! let video_segments = video_streams[0].segments(); |
| 87 | +//! let audio_segments = audio_streams[0].segments(); |
91 | 88 | //! // iterate through every segment and write it to the provided writer (which is a sink in this
|
92 | 89 | //! // case; it drops its input immediately). writer can be anything which implements `std::io::Write`
|
93 | 90 | //! // like a file, a pipe, ...
|
94 |
| -//! for segment in segments { |
95 |
| -//! segment.write_to(sink).await?; |
| 91 | +//! for video_segment in video_segments { |
| 92 | +//! video_segment.write_to(sink).await?; |
| 93 | +//! } |
| 94 | +//! for audio_segment in audio_segments { |
| 95 | +//! audio_segments.write_to(sink).await?; |
96 | 96 | //! }
|
97 | 97 | //! ```
|
98 | 98 | //!
|
|
117 | 117 | //!
|
118 | 118 | //! # Features
|
119 | 119 | //!
|
120 |
| -//! - **hls-stream** *(enabled by default)*: Enables processing of [HLS] video streams. |
121 |
| -//! - **dash-stream**: Enables processing of [DASH] video streams. |
122 | 120 | //! - **parse** *(enabled by default)*: Enables url parsing.
|
123 | 121 | //! - **tower**: Enables the usage of a [tower](https://docs.rs/tower) compatible middleware.
|
124 | 122 | //! - **experimental-stabilizations**: Provides some functions to maybe fix broken api results. See
|
|
130 | 128 | //! that no fields were added or removed from an api response, otherwise the associated test will
|
131 | 129 | //! fail.
|
132 | 130 | //!
|
133 |
| -//! [HLS]: https://en.wikipedia.org/wiki/HTTP_Live_Streaming |
134 | 131 | //! [DASH]: https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP
|
135 | 132 |
|
136 | 133 | #![cfg_attr(docsrs, feature(doc_cfg))]
|
|
0 commit comments