omgxxx fix
This commit is contained in:
@@ -650,6 +650,48 @@ impl OmgxxxProvider {
|
||||
ranked
|
||||
}
|
||||
|
||||
fn uploader_target_from_href_and_title(&self, href: &str, title: &str) -> Option<OmgUploaderTarget> {
|
||||
if href.contains("/sites/") {
|
||||
let id = href
|
||||
.split("/sites/")
|
||||
.nth(1)
|
||||
.unwrap_or_default()
|
||||
.split('/')
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
if id.is_empty() {
|
||||
return None;
|
||||
}
|
||||
return Some(OmgUploaderTarget {
|
||||
kind: OmgUploaderTargetKind::Site,
|
||||
id,
|
||||
title: title.to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
if href.contains("/networks/") {
|
||||
let id = href
|
||||
.split("/networks/")
|
||||
.nth(1)
|
||||
.unwrap_or_default()
|
||||
.split('/')
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.to_string();
|
||||
if id.is_empty() {
|
||||
return None;
|
||||
}
|
||||
return Some(OmgUploaderTarget {
|
||||
kind: OmgUploaderTargetKind::Network,
|
||||
id,
|
||||
title: title.to_string(),
|
||||
});
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
async fn build_uploader_profile(
|
||||
&self,
|
||||
_cache: VideoCache,
|
||||
@@ -1124,6 +1166,8 @@ impl OmgxxxProvider {
|
||||
.get_site_id_from_name(site_name)
|
||||
.unwrap_or("".to_string());
|
||||
let mut tags = Vec::new();
|
||||
let mut site_uploader: Option<OmgUploaderTarget> = None;
|
||||
let mut network_uploader: Option<OmgUploaderTarget> = None;
|
||||
for (href, tag_title) in self.extract_tag_entries(video_segment) {
|
||||
if href.contains("/models/") {
|
||||
let model_id = href
|
||||
@@ -1163,6 +1207,20 @@ impl OmgxxxProvider {
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(target) = self.uploader_target_from_href_and_title(&href, &tag_title) {
|
||||
match target.kind {
|
||||
OmgUploaderTargetKind::Site => {
|
||||
if site_uploader.is_none() {
|
||||
site_uploader = Some(target.clone());
|
||||
}
|
||||
}
|
||||
OmgUploaderTargetKind::Network => {
|
||||
if network_uploader.is_none() {
|
||||
network_uploader = Some(target.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !tags.iter().any(|existing| existing == &tag_title) {
|
||||
tags.push(tag_title);
|
||||
}
|
||||
@@ -1171,13 +1229,20 @@ impl OmgxxxProvider {
|
||||
Self::push_unique(
|
||||
&self.sites,
|
||||
FilterOption {
|
||||
id: site_id,
|
||||
id: site_id.clone(),
|
||||
title: site_name.to_string(),
|
||||
},
|
||||
);
|
||||
if !tags.iter().any(|existing| existing == site_name) {
|
||||
tags.push(site_name.to_string());
|
||||
}
|
||||
if site_uploader.is_none() {
|
||||
site_uploader = Some(OmgUploaderTarget {
|
||||
kind: OmgUploaderTargetKind::Site,
|
||||
id: site_id.clone(),
|
||||
title: site_name.to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mut video_item = VideoItem::new(
|
||||
@@ -1190,6 +1255,23 @@ impl OmgxxxProvider {
|
||||
)
|
||||
.views(views)
|
||||
.preview(preview);
|
||||
let uploader_target = site_uploader.or(network_uploader);
|
||||
if let Some(uploader_target) = uploader_target {
|
||||
video_item.uploader = Some(uploader_target.title.clone());
|
||||
video_item.uploaderUrl = Some(format!(
|
||||
"{}/{}/{}/",
|
||||
self.url,
|
||||
match uploader_target.kind {
|
||||
OmgUploaderTargetKind::Site => "sites",
|
||||
OmgUploaderTargetKind::Network => "networks",
|
||||
},
|
||||
uploader_target.id
|
||||
));
|
||||
video_item.uploaderId = Some(Self::canonical_uploader_id(
|
||||
&uploader_target.kind,
|
||||
&uploader_target.id,
|
||||
));
|
||||
}
|
||||
if !tags.is_empty() {
|
||||
video_item.tags = Some(tags);
|
||||
}
|
||||
@@ -1304,6 +1386,15 @@ mod tests {
|
||||
.iter()
|
||||
.any(|tag| tag.id == "sara-bork" && tag.title == "Sara Bork")
|
||||
);
|
||||
assert_eq!(items[0].uploader.as_deref(), Some("Club Sweethearts"));
|
||||
assert_eq!(
|
||||
items[0].uploaderUrl.as_deref(),
|
||||
Some("https://www.omg.xxx/sites/clubsweethearts/")
|
||||
);
|
||||
assert_eq!(
|
||||
items[0].uploaderId.as_deref(),
|
||||
Some("omgxxx:site:clubsweethearts")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user