视频与图片读取结果兼容处理
This commit is contained in:
parent
1364cdf71e
commit
e9454d095c
@ -257,9 +257,23 @@ export async function generateImages(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const imageUrls = item_list.map((item) => {
|
const imageUrls = item_list.map((item) => {
|
||||||
if(!item?.image?.large_images?.[0]?.image_url)
|
let res_url = null;
|
||||||
|
let idata = item?.image;
|
||||||
|
let idata2 = item?.image?.large_images;
|
||||||
|
if(!idata2 || !idata2.length){
|
||||||
|
for(let key in idata){
|
||||||
|
if(idata[key] && idata[key].length && idata[key].length > 0){
|
||||||
|
if(idata[key][0].image_url){
|
||||||
|
res_url = idata[key][0].image_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
res_url = idata2[0].image_url;
|
||||||
|
}
|
||||||
|
if(res_url) return res_url;
|
||||||
return item?.common_attr?.cover_url || null;
|
return item?.common_attr?.cover_url || null;
|
||||||
return item.image.large_images[0].image_url;
|
|
||||||
});
|
});
|
||||||
const validImageUrls = imageUrls.filter(url => url !== null);
|
const validImageUrls = imageUrls.filter(url => url !== null);
|
||||||
if (validImageUrls.length > 0) {
|
if (validImageUrls.length > 0) {
|
||||||
@ -503,9 +517,23 @@ export async function uploadImages(
|
|||||||
throw new APIException(EX.API_IMAGE_GENERATION_FAILED);
|
throw new APIException(EX.API_IMAGE_GENERATION_FAILED);
|
||||||
}
|
}
|
||||||
return item_list.map((item) => {
|
return item_list.map((item) => {
|
||||||
if(!item?.image?.large_images?.[0]?.image_url)
|
let res_url = null;
|
||||||
|
let idata = item?.image;
|
||||||
|
let idata2 = item?.image?.large_images;
|
||||||
|
if(!idata2 || !idata2.length){
|
||||||
|
for(let key in idata){
|
||||||
|
if(idata[key] && idata[key].length && idata[key].length > 0){
|
||||||
|
if(idata[key][0].image_url){
|
||||||
|
res_url = idata[key][0].image_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
res_url = idata2[0].image_url;
|
||||||
|
}
|
||||||
|
if(res_url) return res_url;
|
||||||
return item?.common_attr?.cover_url || null;
|
return item?.common_attr?.cover_url || null;
|
||||||
return item.image.large_images[0].image_url;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -238,9 +238,15 @@ export async function generateVideo(
|
|||||||
// and item_list is populated.
|
// and item_list is populated.
|
||||||
// A more robust check might be needed depending on actual API behavior for success.
|
// A more robust check might be needed depending on actual API behavior for success.
|
||||||
const videoUrls = item_list.map((item) => {
|
const videoUrls = item_list.map((item) => {
|
||||||
if(!item?.video?.transcoded_video?.origin?.video_url)
|
let res_url = null;
|
||||||
return null;
|
let vdata = item?.video?.transcoded_video||{};
|
||||||
return item.video.transcoded_video.origin.video_url;
|
for(let key in vdata){
|
||||||
|
if(vdata[key] && vdata[key].video_url){
|
||||||
|
res_url = vdata[key].video_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res_url || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter out nulls and check if any valid URL was generated
|
// Filter out nulls and check if any valid URL was generated
|
||||||
|
|||||||
@ -260,14 +260,35 @@ export class TaskPollingService {
|
|||||||
|
|
||||||
if (task.task_type === 'image') {
|
if (task.task_type === 'image') {
|
||||||
originalUrls = item_list.map((item) => {
|
originalUrls = item_list.map((item) => {
|
||||||
if (item?.image?.large_images?.[0]?.image_url) {
|
let res_url = null;
|
||||||
return item.image.large_images[0].image_url;
|
let idata = item?.image;
|
||||||
|
let idata2 = item?.image?.large_images;
|
||||||
|
if(!idata2 || !idata2.length){
|
||||||
|
for(let key in idata){
|
||||||
|
if(idata[key] && idata[key].length && idata[key].length > 0){
|
||||||
|
if(idata[key][0].image_url){
|
||||||
|
res_url = idata[key][0].image_url;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
res_url = idata2[0].image_url;
|
||||||
|
}
|
||||||
|
if(res_url) return res_url;
|
||||||
return item?.common_attr?.cover_url || null;
|
return item?.common_attr?.cover_url || null;
|
||||||
}).filter(url => url !== null);
|
}).filter(url => url !== null);
|
||||||
} else {
|
} else {
|
||||||
originalUrls = item_list.map((item) => {
|
originalUrls = item_list.map((item) => {
|
||||||
return item?.video?.transcoded_video?.origin?.video_url || null;
|
let res_url = null;
|
||||||
|
let vdata = item?.video?.transcoded_video||{};
|
||||||
|
for(let key in vdata){
|
||||||
|
if(vdata[key] && vdata[key].video_url){
|
||||||
|
res_url = vdata[key].video_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res_url || null;
|
||||||
}).filter(url => url !== null);
|
}).filter(url => url !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -415,14 +436,35 @@ export class TaskPollingService {
|
|||||||
|
|
||||||
if (task.task_type === 'image') {
|
if (task.task_type === 'image') {
|
||||||
originalUrls = itemList.map((item) => {
|
originalUrls = itemList.map((item) => {
|
||||||
if (item?.image?.large_images?.[0]?.image_url) {
|
let res_url = null;
|
||||||
return item.image.large_images[0].image_url;
|
let idata = item?.image;
|
||||||
|
let idata2 = item?.image?.large_images;
|
||||||
|
if(!idata2 || !idata2.length){
|
||||||
|
for(let key in idata){
|
||||||
|
if(idata[key] && idata[key].length && idata[key].length > 0){
|
||||||
|
if(idata[key][0].image_url){
|
||||||
|
res_url = idata[key][0].image_url;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
res_url = idata2[0].image_url;
|
||||||
|
}
|
||||||
|
if(res_url) return res_url;
|
||||||
return item?.common_attr?.cover_url || null;
|
return item?.common_attr?.cover_url || null;
|
||||||
}).filter(url => url !== null);
|
}).filter(url => url !== null);
|
||||||
} else {
|
} else {
|
||||||
originalUrls = itemList.map((item) => {
|
originalUrls = itemList.map((item) => {
|
||||||
return item?.video?.transcoded_video?.origin?.video_url || null;
|
let res_url = null;
|
||||||
|
let vdata = item?.video?.transcoded_video||{};
|
||||||
|
for(let key in vdata){
|
||||||
|
if(vdata[key] && vdata[key].video_url){
|
||||||
|
res_url = vdata[key].video_url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res_url || null;
|
||||||
}).filter(url => url !== null);
|
}).filter(url => url !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user