Compare commits
No commits in common. "da8b2a27fceeab07257f2f9c1da18c34a8da5d5f" and "805cc5088fd3b3f26503a5e3063a46562feedc80" have entirely different histories.
da8b2a27fc
...
805cc5088f
3 changed files with 6 additions and 27 deletions
|
@ -531,15 +531,8 @@ impl<T> YouTubeListMapper<T> {
|
||||||
});
|
});
|
||||||
|
|
||||||
let length = video.accessibility.and_then(|acc| {
|
let length = video.accessibility.and_then(|acc| {
|
||||||
// The video title has to be stripped from the beginning because in Swahili
|
let parts = ACCESSIBILITY_SEP_REGEX.split(&acc).collect::<Vec<_>>();
|
||||||
// the duration follows the title with no separator (probably a bug).
|
if parts.len() > 2 {
|
||||||
// Example: `what I do with leftoversdakika 1 - cheza video`
|
|
||||||
let parts = ACCESSIBILITY_SEP_REGEX
|
|
||||||
.split(acc.trim_start_matches(&video.headline))
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
if parts.len() > 1 {
|
|
||||||
// In Russian, the duration is the last part
|
|
||||||
// Example: `Воспроизвести видео – \"hangover food\". Его продолжительность – 58 секунд.`
|
|
||||||
let i = match self.lang {
|
let i = match self.lang {
|
||||||
Language::Ru => 1,
|
Language::Ru => 1,
|
||||||
_ => 2,
|
_ => 2,
|
||||||
|
|
|
@ -344,21 +344,7 @@ struct DurationTxtSegment {
|
||||||
word: String,
|
word: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Split a video duration string into its segments.
|
fn split_duration_txt(txt: &str, start_c: bool) -> Vec<DurationTxtSegment> {
|
||||||
///
|
|
||||||
/// Each segment consists of a word and a string of digits (one of them may be empty).
|
|
||||||
///
|
|
||||||
/// The `start_word` parameter determines whether the segments should start with a word
|
|
||||||
/// instead of a number. This is the case in Swahili and Singhalese.
|
|
||||||
///
|
|
||||||
/// Example (start_word=false):
|
|
||||||
/// - `1 minute, 13 seconds` -> `{1;minute} {13;seconds}`
|
|
||||||
/// - `foo 1 minute, 13 seconds bar` -> `{foo} {1;minute} {13;seconds bar}`
|
|
||||||
///
|
|
||||||
/// Example (start_word=true):
|
|
||||||
/// - `dakika 1 na sekunde 1` -> `{1;dakika} {1;na sekunde}`
|
|
||||||
/// - `foo dakika 1 na sekunde 1 bar` -> `{1;foo dakika} {1;na sekunde} {bar}`
|
|
||||||
fn split_duration_txt(txt: &str, start_word: bool) -> Vec<DurationTxtSegment> {
|
|
||||||
let mut segments = Vec::new();
|
let mut segments = Vec::new();
|
||||||
|
|
||||||
// 1: parse digits, 2: parse word
|
// 1: parse digits, 2: parse word
|
||||||
|
@ -367,14 +353,14 @@ fn split_duration_txt(txt: &str, start_word: bool) -> Vec<DurationTxtSegment> {
|
||||||
|
|
||||||
for c in txt.trim().chars() {
|
for c in txt.trim().chars() {
|
||||||
if c.is_ascii_digit() {
|
if c.is_ascii_digit() {
|
||||||
if state == 2 && (!seg.digits.is_empty() || (!start_word && segments.is_empty())) {
|
if state == 2 && (!seg.digits.is_empty() || (!start_c && segments.is_empty())) {
|
||||||
segments.push(seg);
|
segments.push(seg);
|
||||||
seg = DurationTxtSegment::default();
|
seg = DurationTxtSegment::default();
|
||||||
}
|
}
|
||||||
seg.digits.push(c);
|
seg.digits.push(c);
|
||||||
state = 1;
|
state = 1;
|
||||||
} else {
|
} else {
|
||||||
if (state == 1) && (!seg.word.is_empty() || (start_word && segments.is_empty())) {
|
if (state == 1) && (!seg.word.is_empty() || (start_c && segments.is_empty())) {
|
||||||
segments.push(seg);
|
segments.push(seg);
|
||||||
seg = DurationTxtSegment::default();
|
seg = DurationTxtSegment::default();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ fn channel_order(
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// Upload dates should be in descending order
|
// Upload dates should be in descending order
|
||||||
if tab == ChannelVideoTab::Videos {
|
if tab != ChannelVideoTab::Shorts {
|
||||||
let mut latest_items = latest.items.iter().peekable();
|
let mut latest_items = latest.items.iter().peekable();
|
||||||
while let (Some(v), Some(next_v)) = (latest_items.next(), latest_items.peek()) {
|
while let (Some(v), Some(next_v)) = (latest_items.next(), latest_items.peek()) {
|
||||||
if !v.is_upcoming && !v.is_live && !next_v.is_upcoming && !next_v.is_live {
|
if !v.is_upcoming && !v.is_live && !next_v.is_upcoming && !next_v.is_live {
|
||||||
|
|
Loading…
Reference in a new issue