fix: parse view count on shorts

This commit is contained in:
ThetaDev 2023-03-21 22:54:47 +01:00
parent 9fbacb2318
commit 3a2e4c8abe
4 changed files with 61 additions and 54 deletions

View file

@ -486,7 +486,7 @@ impl<T> YouTubeListMapper<T> {
}
}
fn map_short_video(&mut self, video: ReelItemRenderer) -> VideoItem {
fn map_short_video(&mut self, video: ReelItemRenderer, lang: Language) -> VideoItem {
static ACCESSIBILITY_SEP_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(" [-\u{2013}] (.+) [-\u{2013}] ").unwrap());
@ -518,7 +518,7 @@ impl<T> YouTubeListMapper<T> {
publish_date_txt: pub_date_txt,
view_count: video
.view_count_text
.map(|txt| util::parse_numeric(&txt).unwrap_or_default()),
.map(|txt| util::parse_large_numstr(&txt, lang).unwrap_or_default()),
is_live: false,
is_short: true,
is_upcoming: false,
@ -589,7 +589,7 @@ impl YouTubeListMapper<YouTubeItem> {
self.items.push(mapped);
}
YouTubeListItem::ReelItemRenderer(video) => {
let mapped = self.map_short_video(video);
let mapped = self.map_short_video(video, self.lang);
self.items.push(YouTubeItem::Video(mapped));
}
YouTubeListItem::PlaylistRenderer(playlist) => {
@ -653,7 +653,7 @@ impl YouTubeListMapper<VideoItem> {
self.items.push(mapped);
}
YouTubeListItem::ReelItemRenderer(video) => {
let mapped = self.map_short_video(video);
let mapped = self.map_short_video(video, self.lang);
self.items.push(mapped);
}
YouTubeListItem::ContinuationItemRenderer {

View file

@ -139,7 +139,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 days ago"),
view_count: Some(593),
view_count: Some(593000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -165,7 +165,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("4 days ago"),
view_count: Some(141),
view_count: Some(141000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -191,7 +191,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("6 days ago"),
view_count: Some(652),
view_count: Some(652000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -217,7 +217,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("8 days ago"),
view_count: Some(795),
view_count: Some(795000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -243,7 +243,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("9 days ago"),
view_count: Some(17),
view_count: Some(1700000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -269,7 +269,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("11 days ago"),
view_count: Some(1),
view_count: Some(1000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -295,7 +295,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("13 days ago"),
view_count: Some(15),
view_count: Some(1500000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -321,7 +321,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 weeks ago"),
view_count: Some(26),
view_count: Some(2600000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -347,7 +347,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 weeks ago"),
view_count: Some(864),
view_count: Some(864000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -373,7 +373,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 weeks ago"),
view_count: Some(21),
view_count: Some(2100000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -399,7 +399,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 weeks ago"),
view_count: Some(1),
view_count: Some(1000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -425,7 +425,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 weeks ago"),
view_count: Some(45),
view_count: Some(4500000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -451,7 +451,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 weeks ago"),
view_count: Some(18),
view_count: Some(1800000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -477,7 +477,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 weeks ago"),
view_count: Some(16),
view_count: Some(1600000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -503,7 +503,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 weeks ago"),
view_count: Some(13),
view_count: Some(1300000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -529,7 +529,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(34),
view_count: Some(3400000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -555,7 +555,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(13),
view_count: Some(1300000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -581,7 +581,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(756),
view_count: Some(756000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -607,7 +607,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(13),
view_count: Some(1300000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -633,7 +633,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(39),
view_count: Some(3900000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -659,7 +659,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(18),
view_count: Some(1800000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -685,7 +685,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(31),
view_count: Some(3100000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -711,7 +711,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(17),
view_count: Some(1700000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -737,7 +737,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(18),
view_count: Some(1800000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -763,7 +763,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(18),
view_count: Some(1800000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -789,7 +789,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(11),
view_count: Some(11000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -815,7 +815,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(31),
view_count: Some(3100000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -841,7 +841,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("1 month ago"),
view_count: Some(688),
view_count: Some(688000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -867,7 +867,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(19),
view_count: Some(1900000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -893,7 +893,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(1),
view_count: Some(1000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -919,7 +919,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(64),
view_count: Some(6400000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -945,7 +945,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(16),
view_count: Some(16000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -971,7 +971,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(27),
view_count: Some(2700000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -997,7 +997,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(25),
view_count: Some(2500000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1023,7 +1023,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(2),
view_count: Some(2000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1049,7 +1049,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("2 months ago"),
view_count: Some(53),
view_count: Some(5300000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1075,7 +1075,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(2),
view_count: Some(2000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1101,7 +1101,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(91),
view_count: Some(9100000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1127,7 +1127,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(26),
view_count: Some(2600000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1153,7 +1153,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(65),
view_count: Some(6500000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1179,7 +1179,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(22),
view_count: Some(2200000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1205,7 +1205,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(66),
view_count: Some(6600000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1231,7 +1231,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(39),
view_count: Some(3900000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1257,7 +1257,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("3 months ago"),
view_count: Some(978),
view_count: Some(978000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1283,7 +1283,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("4 months ago"),
view_count: Some(45),
view_count: Some(4500000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1309,7 +1309,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("4 months ago"),
view_count: Some(21),
view_count: Some(2100000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1335,7 +1335,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("4 months ago"),
view_count: Some(4),
view_count: Some(4000000),
is_live: false,
is_short: true,
is_upcoming: false,
@ -1361,7 +1361,7 @@ Channel(
)),
publish_date: "[date]",
publish_date_txt: Some("4 months ago"),
view_count: Some(63),
view_count: Some(6300000),
is_live: false,
is_short: true,
is_upcoming: false,