refactor: use fancy-regex only for backtracking

This commit is contained in:
ThetaDev 2023-01-23 15:33:05 +01:00
parent 4cc069fba2
commit 92a358a079
12 changed files with 69 additions and 108 deletions

View file

@ -1,5 +1,5 @@
use fancy_regex::Regex;
use once_cell::sync::Lazy;
use regex::Regex;
use serde::Deserialize;
use serde_with::{
json::JsonString, rust::deserialize_ignore_any, serde_as, DefaultOnError, VecSkipError,
@ -503,20 +503,12 @@ impl<T> YouTubeListMapper<T> {
id: video.video_id,
name: video.headline,
length: video.accessibility.and_then(|acc| {
ACCESSIBILITY_SEP_REGEX
.captures(&acc)
.ok()
.flatten()
.and_then(|cap| {
cap.get(1).and_then(|c| {
timeago::parse_timeago_or_warn(
self.lang,
c.as_str(),
&mut self.warnings,
)
ACCESSIBILITY_SEP_REGEX.captures(&acc).and_then(|cap| {
cap.get(1).and_then(|c| {
timeago::parse_timeago_or_warn(self.lang, c.as_str(), &mut self.warnings)
.map(|ta| Duration::from(ta).whole_seconds() as u32)
})
})
})
}),
thumbnail: video.thumbnail.into(),
channel: self.channel.clone(),