Skip to content

Commit 9321592

Browse files
committed
Fix more clippy warnings.
1 parent 84d0995 commit 9321592

12 files changed

Lines changed: 58 additions & 232 deletions

File tree

cli/src/main.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -744,21 +744,21 @@ fn print_comments(comments: &[Comment]) {
744744
fn print_richtext(text: &RichText) {
745745
for c in &text.0 {
746746
match c {
747-
rustypipe::model::richtext::TextComponent::Text { text, style } => {
748-
if !text.is_empty() {
749-
let mut tstyle = owo_colors::Style::new();
747+
rustypipe::model::richtext::TextComponent::Text { text, style }
748+
if !text.is_empty() =>
749+
{
750+
let mut tstyle = owo_colors::Style::new();
750751

751-
if style.bold {
752-
tstyle = tstyle.bold();
753-
}
754-
if style.italic {
755-
tstyle = tstyle.italic();
756-
}
757-
if style.strikethrough {
758-
tstyle = tstyle.strikethrough();
759-
}
760-
anstream::print!("{}", text.style(tstyle));
752+
if style.bold {
753+
tstyle = tstyle.bold();
754+
}
755+
if style.italic {
756+
tstyle = tstyle.italic();
757+
}
758+
if style.strikethrough {
759+
tstyle = tstyle.strikethrough();
761760
}
761+
anstream::print!("{}", text.style(tstyle));
762762
}
763763
rustypipe::model::richtext::TextComponent::Web { url, .. } => {
764764
anstream::print!("{}", url.underline());

codegen/src/gen_dictionary.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fn ta_token_value(n: u8, unit: Option<TimeUnit>) -> String {
4141
}
4242
}
4343

44-
fn phf_map_from_str_tokens(tokens: &OrderedHashMap<String, String>) -> phf_codegen::Map<&str> {
44+
fn phf_map_from_str_tokens(tokens: &OrderedHashMap<String, String>) -> phf_codegen::Map<'_, &str> {
4545
tokens
4646
.iter()
4747
.map(|(txt, tu_str)| {
@@ -51,14 +51,14 @@ fn phf_map_from_str_tokens(tokens: &OrderedHashMap<String, String>) -> phf_codeg
5151
.collect()
5252
}
5353

54-
fn phf_map_from_str_u8(tokens: &BTreeMap<String, u8>) -> phf_codegen::Map<&str> {
54+
fn phf_map_from_str_u8(tokens: &BTreeMap<String, u8>) -> phf_codegen::Map<'_, &str> {
5555
tokens
5656
.iter()
5757
.map(|(txt, n)| (txt.as_str(), n.to_string()))
5858
.collect()
5959
}
6060

61-
fn phf_map_from_album_types(tokens: &BTreeMap<String, AlbumType>) -> phf_codegen::Map<&str> {
61+
fn phf_map_from_album_types(tokens: &BTreeMap<String, AlbumType>) -> phf_codegen::Map<'_, &str> {
6262
tokens
6363
.iter()
6464
.map(|(txt, album_type)| (txt.as_str(), format!("AlbumType::{album_type:?}")))

codegen/src/model.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,6 @@ impl TimeUnit {
117117
}
118118
}
119119

120-
#[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
121-
pub enum ExtItemType {
122-
Track,
123-
Video,
124-
Episode,
125-
Playlist,
126-
Artist,
127-
}
128-
129120
#[derive(Debug, Serialize)]
130121
#[serde(rename_all = "camelCase")]
131122
pub struct QBrowse<'a> {

downloader/src/lib.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,8 @@ impl DownloadQuery {
10351035

10361036
let crop = smartcrop::find_best_crop_no_borders(
10371037
&img,
1038-
NonZeroU32::MIN,
1039-
NonZeroU32::MIN,
1038+
NonZeroU32::new(1).unwrap(),
1039+
NonZeroU32::new(1).unwrap(),
10401040
)
10411041
.map_err(|e| DownloadError::AudioTag(format!("image crop: {e}").into()))?
10421042
.crop;
@@ -1209,18 +1209,32 @@ async fn download_single_file(
12091209
.open(&output_path_tmp)
12101210
.await?;
12111211

1212-
let res = if is_gvideo && size.is_some() {
1213-
download_chunks_by_param(
1214-
http,
1215-
&mut file,
1216-
url,
1217-
size.unwrap(),
1218-
offset,
1219-
user_agent,
1220-
#[cfg(feature = "indicatif")]
1221-
pb,
1222-
)
1223-
.await
1212+
let res = if is_gvideo {
1213+
if let Some(size) = size {
1214+
download_chunks_by_param(
1215+
http,
1216+
&mut file,
1217+
url,
1218+
size,
1219+
offset,
1220+
user_agent,
1221+
#[cfg(feature = "indicatif")]
1222+
pb,
1223+
)
1224+
.await
1225+
} else {
1226+
download_chunks_by_header(
1227+
http,
1228+
&mut file,
1229+
url,
1230+
size,
1231+
offset,
1232+
user_agent,
1233+
#[cfg(feature = "indicatif")]
1234+
pb,
1235+
)
1236+
.await
1237+
}
12241238
} else {
12251239
download_chunks_by_header(
12261240
http,

src/client/pagination.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,10 @@ impl MapJsonResponse<Paginator<HistoryItem<VideoItem>>> for ContinuationJson {
318318
&mut map_res,
319319
);
320320
}
321-
response::YouTubeListItem::ContinuationItemRenderer(ep) => {
322-
if ctoken.is_none() {
323-
ctoken = ep.continuation_endpoint.into_token();
324-
}
321+
response::YouTubeListItem::ContinuationItemRenderer(ep) if ctoken.is_none() => {
322+
ctoken = ep.continuation_endpoint.into_token();
325323
}
324+
response::YouTubeListItem::ContinuationItemRenderer(_) => {}
326325
_ => {}
327326
}
328327
}

src/client/response/channel.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ pub(crate) struct PhBannerView {
108108
pub image_banner_view_model: ImageView,
109109
}
110110

111-
#[derive(Debug, Deserialize)]
112-
#[serde(rename_all = "camelCase")]
113-
pub(crate) struct Metadata {
114-
pub channel_metadata_renderer: ChannelMetadataRenderer,
115-
}
116-
117111
#[derive(Debug, Deserialize)]
118112
#[serde(rename_all = "camelCase")]
119113
pub(crate) struct ChannelMetadataRenderer {
@@ -124,12 +118,6 @@ pub(crate) struct ChannelMetadataRenderer {
124118
pub vanity_channel_url: Option<String>,
125119
}
126120

127-
#[derive(Debug, Deserialize)]
128-
#[serde(rename_all = "camelCase")]
129-
pub(crate) struct Microformat {
130-
pub microformat_data_renderer: MicroformatDataRenderer,
131-
}
132-
133121
#[derive(Debug, Deserialize)]
134122
#[serde(rename_all = "camelCase")]
135123
pub(crate) struct MicroformatDataRenderer {

src/client/response/mod.rs

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,12 @@ use serde::{
2626
de::{IgnoredAny, Visitor},
2727
Deserialize,
2828
};
29-
use serde_with::{serde_as, DisplayFromStr, VecSkipError};
29+
use serde_with::{serde_as, VecSkipError};
3030

3131
use crate::error::ExtractionError;
3232
use crate::serializer::text::{AttributedText, Text, TextComponent};
3333
use crate::serializer::{MapResult, VecSkipErrorWrap};
3434

35-
use self::video_item::YouTubeListRenderer;
36-
3735
#[derive(Debug, Deserialize)]
3836
#[serde(rename_all = "camelCase")]
3937
pub(crate) struct ContentRenderer<T> {
@@ -66,12 +64,6 @@ pub(crate) struct SectionList<T> {
6664
pub section_list_renderer: ContentsRenderer<T>,
6765
}
6866

69-
#[derive(Debug, Deserialize)]
70-
#[serde(rename_all = "camelCase")]
71-
pub(crate) struct TwoColumnBrowseResults<T> {
72-
pub two_column_browse_results_renderer: ContentsRenderer<T>,
73-
}
74-
7567
#[derive(Default, Debug, Deserialize)]
7668
#[serde(rename_all = "camelCase")]
7769
pub(crate) struct ThumbnailsWrap {
@@ -229,12 +221,6 @@ pub(crate) struct TextComponentBox {
229221
pub text: TextComponent,
230222
}
231223

232-
#[derive(Debug, Deserialize)]
233-
#[serde(rename_all = "camelCase")]
234-
pub(crate) struct ResponseContext {
235-
pub visitor_data: Option<String>,
236-
}
237-
238224
#[derive(Debug, Deserialize)]
239225
#[serde(rename_all = "camelCase")]
240226
pub(crate) struct AttachmentRun {
@@ -290,25 +276,6 @@ pub enum IconName {
290276

291277
// CONTINUATION
292278

293-
#[serde_as]
294-
#[derive(Debug, Deserialize)]
295-
#[serde(rename_all = "camelCase")]
296-
pub(crate) struct Continuation {
297-
/// Number of search results
298-
#[serde_as(as = "Option<DisplayFromStr>")]
299-
pub estimated_results: Option<u64>,
300-
#[serde(
301-
alias = "onResponseReceivedCommands",
302-
alias = "onResponseReceivedEndpoints"
303-
)]
304-
#[serde_as(as = "Option<VecSkipError<_>>")]
305-
pub on_response_received_actions: Option<Vec<ContinuationActionWrap<YouTubeListItem>>>,
306-
/// Used for channel video rich grid renderer
307-
///
308-
/// A/B test seen on 19.10.2022
309-
pub continuation_contents: Option<RichGridContinuationContents>,
310-
}
311-
312279
#[derive(Debug, Deserialize)]
313280
#[serde(rename_all = "camelCase")]
314281
pub(crate) struct ContinuationActionWrap<T> {
@@ -322,12 +289,6 @@ pub(crate) struct ContinuationAction<T> {
322289
pub continuation_items: MapResult<Vec<T>>,
323290
}
324291

325-
#[derive(Debug, Deserialize)]
326-
#[serde(rename_all = "camelCase")]
327-
pub(crate) struct RichGridContinuationContents {
328-
pub rich_grid_continuation: YouTubeListRenderer,
329-
}
330-
331292
#[derive(Debug, Deserialize)]
332293
#[serde(rename_all = "camelCase")]
333294
pub(crate) struct MusicContinuationData {

src/client/response/music_item.rs

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use super::{
1919
url_endpoint::{
2020
BrowseEndpointWrap, MusicPage, MusicPageType, MusicVideoType, NavigationEndpoint, PageType,
2121
},
22-
ContentsRenderer, ContinuationActionWrap, ContinuationEndpoint, MusicContinuationData,
22+
ContentsRenderer, ContinuationEndpoint, MusicContinuationData,
2323
SimpleHeaderRenderer, Thumbnails, ThumbnailsWrap,
2424
};
2525

@@ -34,6 +34,7 @@ pub(crate) enum ItemSection {
3434
#[serde(alias = "musicPlaylistShelfRenderer")]
3535
MusicShelfRenderer(MusicShelf),
3636
MusicCarouselShelfRenderer(MusicCarouselShelf),
37+
#[allow(dead_code)]
3738
GridRenderer(GridRenderer),
3839
#[serde(other, deserialize_with = "deserialize_ignore_any")]
3940
None,
@@ -249,6 +250,7 @@ pub(crate) struct PlaylistPanelRenderer {
249250
/// Continuation token for fetching more radio items
250251
#[serde(default)]
251252
#[serde_as(as = "VecSkipError<_>")]
253+
#[allow(dead_code)]
252254
pub continuations: Vec<MusicContinuationData>,
253255
}
254256

@@ -333,28 +335,6 @@ impl From<MusicThumbnailRenderer> for Vec<model::Thumbnail> {
333335
}
334336
}
335337

336-
/// Music list continuation response model
337-
#[serde_as]
338-
#[derive(Debug, Deserialize)]
339-
#[serde(rename_all = "camelCase")]
340-
pub(crate) struct MusicContinuation {
341-
pub continuation_contents: Option<ContinuationContents>,
342-
#[serde(default)]
343-
#[serde_as(as = "VecSkipError<_>")]
344-
pub on_response_received_actions: Vec<ContinuationActionWrap<MusicResponseItem>>,
345-
}
346-
347-
#[derive(Debug, Deserialize)]
348-
#[serde(rename_all = "camelCase")]
349-
#[allow(clippy::enum_variant_names)]
350-
pub(crate) enum ContinuationContents {
351-
#[serde(alias = "musicPlaylistShelfContinuation")]
352-
MusicShelfContinuation(MusicShelf),
353-
SectionListContinuation(ContentsRenderer<ItemSection>),
354-
PlaylistPanelContinuation(PlaylistPanelRenderer),
355-
GridContinuation(GridRenderer),
356-
}
357-
358338
#[derive(Debug, Deserialize)]
359339
#[serde(rename_all = "camelCase")]
360340
pub(crate) struct MusicCarouselShelfHeader {
@@ -404,6 +384,7 @@ pub(crate) struct Grid {
404384
#[serde(rename_all = "camelCase")]
405385
pub(crate) struct GridRenderer {
406386
pub items: MapResult<Vec<MusicResponseItem>>,
387+
#[allow(dead_code)]
407388
pub header: Option<GridHeader>,
408389
#[serde(default)]
409390
#[serde_as(as = "VecSkipError<_>")]
@@ -413,6 +394,7 @@ pub(crate) struct GridRenderer {
413394
#[derive(Debug, Deserialize)]
414395
#[serde(rename_all = "camelCase")]
415396
pub(crate) struct GridHeader {
397+
#[allow(dead_code)]
416398
pub grid_header_renderer: SimpleHeaderRenderer,
417399
}
418400

@@ -580,25 +562,6 @@ impl MusicListMapper {
580562
self.map_response(MapResult { c: items, warnings })
581563
}
582564

583-
pub fn map_section_node(&mut self, section: &JsonNode<'_>) -> Option<MusicItemType> {
584-
if let Ok(section) = section.deserialize::<ItemSection>() {
585-
return self.map_item_section(section);
586-
}
587-
None
588-
}
589-
590-
fn map_item_section(&mut self, section: ItemSection) -> Option<MusicItemType> {
591-
match section {
592-
ItemSection::MusicShelfRenderer(shelf) => {
593-
self.map_response(shelf.contents);
594-
None
595-
}
596-
ItemSection::MusicCarouselShelfRenderer(shelf) => self.map_response(shelf.contents),
597-
ItemSection::GridRenderer(grid) => self.map_response(grid.items),
598-
ItemSection::None => None,
599-
}
600-
}
601-
602565
/// Map a ListMusicItem (album/playlist item, search result)
603566
fn map_list_item(&mut self, item: ListMusicItem) -> Result<Option<MusicItemType>, String> {
604567
let mut columns = item.flex_columns.into_iter();

src/client/response/playlist.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use serde_with::{serde_as, DefaultOnError, VecSkipError};
44
use crate::serializer::text::{AttributedText, Text, TextComponent, TextComponents};
55

66
use super::{
7-
url_endpoint::OnTapWrap, ContentRenderer, ContentsRenderer, ImageView,
7+
url_endpoint::OnTapWrap, ContentRenderer, ImageView,
88
PageHeaderRendererContent, PhMetadataView, TextBox, ThumbnailsWrap,
99
};
1010

@@ -47,39 +47,6 @@ pub(crate) struct Byline {
4747
pub playlist_byline_renderer: TextBox,
4848
}
4949

50-
#[derive(Debug, Deserialize)]
51-
#[serde(rename_all = "camelCase")]
52-
pub(crate) struct Sidebar {
53-
pub playlist_sidebar_renderer: ContentsRenderer<SidebarItemPrimary>,
54-
}
55-
56-
#[derive(Debug, Deserialize)]
57-
#[serde(rename_all = "camelCase")]
58-
pub(crate) struct SidebarItemPrimary {
59-
pub playlist_sidebar_primary_info_renderer: SidebarPrimaryInfoRenderer,
60-
}
61-
62-
#[serde_as]
63-
#[derive(Debug, Deserialize)]
64-
#[serde(rename_all = "camelCase")]
65-
pub(crate) struct SidebarPrimaryInfoRenderer {
66-
pub description: Option<TextComponents>,
67-
pub thumbnail_renderer: PlaylistThumbnailRenderer,
68-
/// - `"495", " videos"`
69-
/// - `"3,310,996 views"`
70-
/// - `"Last updated on ", "Aug 7, 2022"`
71-
#[serde_as(as = "Vec<Text>")]
72-
pub stats: Vec<String>,
73-
}
74-
75-
#[derive(Debug, Deserialize)]
76-
#[serde(rename_all = "camelCase")]
77-
pub(crate) struct PlaylistThumbnailRenderer {
78-
// the alternative field name is used by YTM playlists
79-
#[serde(alias = "playlistCustomThumbnailRenderer")]
80-
pub playlist_video_thumbnail_renderer: ThumbnailsWrap,
81-
}
82-
8350
#[derive(Debug, Deserialize)]
8451
#[serde(rename_all = "camelCase")]
8552
pub(crate) struct PageHeaderRendererInner {

0 commit comments

Comments
 (0)