mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-15 17:58:31 +00:00
Also provide mediaMetadata
This commit is contained in:
parent
87783a4c86
commit
4284661afe
13
docs/api.md
13
docs/api.md
@ -37,12 +37,13 @@ Content-Type: application/json
|
|||||||
### response body variables
|
### response body variables
|
||||||
| key | type | variables |
|
| key | type | variables |
|
||||||
|:-------------|:---------|:------------------------------------------------------------|
|
|:-------------|:---------|:------------------------------------------------------------|
|
||||||
| `status` | `string` | `error / redirect / stream / success / rate-limit / picker` |
|
| `status` | `string` | `error / redirect / stream / success / rate-limit / picker` |
|
||||||
| `text` | `string` | various text, mostly used for errors |
|
| `text` | `string` | various text, mostly used for errors |
|
||||||
| `url` | `string` | direct link to a file or a link to cobalt's live render |
|
| `url` | `string` | direct link to a file or a link to cobalt's live render |
|
||||||
| `pickerType` | `string` | `various / images` |
|
| `pickerType` | `string` | `various / images` |
|
||||||
| `picker` | `array` | array of picker items |
|
| `picker` | `array` | array of picker items |
|
||||||
| `audio` | `string` | direct link to a file or a link to cobalt's live render |
|
| `audio` | `string` | direct link to a file or a link to cobalt's live render |
|
||||||
|
| `mediaMetadata` | `object` | Supported only on YouTube and Twitter videos. Object, that contains values `duration` (duration of the video in seconds), `likes` and `views` |
|
||||||
|
|
||||||
### picker item variables
|
### picker item variables
|
||||||
item type: `object`
|
item type: `object`
|
||||||
|
@ -14,6 +14,7 @@ export default function(r, host, userFormat, isAudioOnly, lang, isAudioMuted, di
|
|||||||
filename: r.filenameAttributes ?
|
filename: r.filenameAttributes ?
|
||||||
createFilename(r.filenameAttributes, filenamePattern, isAudioOnly, isAudioMuted) : r.filename,
|
createFilename(r.filenameAttributes, filenamePattern, isAudioOnly, isAudioMuted) : r.filename,
|
||||||
fileMetadata: !disableMetadata ? r.fileMetadata : false,
|
fileMetadata: !disableMetadata ? r.fileMetadata : false,
|
||||||
|
mediaMetadata: r.mediaMetadata,
|
||||||
requestIP
|
requestIP
|
||||||
},
|
},
|
||||||
params = {},
|
params = {},
|
||||||
|
@ -59,13 +59,15 @@ export function createResponse(responseType, responseData) {
|
|||||||
|
|
||||||
case "redirect":
|
case "redirect":
|
||||||
response = {
|
response = {
|
||||||
url: responseData.u
|
url: responseData.u,
|
||||||
|
mediaMetadata: responseData.mediaMetadata,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "stream":
|
case "stream":
|
||||||
response = {
|
response = {
|
||||||
url: createStream(responseData)
|
url: createStream(responseData),
|
||||||
|
mediaMetadata: responseData.mediaMetadata,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -159,12 +159,18 @@ export default async function({ id, index, toGif, dispatcher }) {
|
|||||||
case 0:
|
case 0:
|
||||||
return { error: 'ErrorNoVideosInTweet' };
|
return { error: 'ErrorNoVideosInTweet' };
|
||||||
case 1:
|
case 1:
|
||||||
|
const mediaMetadata = {
|
||||||
|
duration: Math.round(media[0].video_info.duration_millis / 1000),
|
||||||
|
likes: baseTweet.favorite_count,
|
||||||
|
views: Number(tweetResult.views.count)
|
||||||
|
};
|
||||||
return {
|
return {
|
||||||
type: needsFixing(media[0]) ? "remux" : "normal",
|
type: needsFixing(media[0]) ? "remux" : "normal",
|
||||||
urls: bestQuality(media[0].video_info.variants),
|
urls: bestQuality(media[0].video_info.variants),
|
||||||
filename: `twitter_${id}.mp4`,
|
filename: `twitter_${id}.mp4`,
|
||||||
audioFilename: `twitter_${id}_audio`,
|
audioFilename: `twitter_${id}_audio`,
|
||||||
isGif: media[0].type === "animated_gif"
|
isGif: media[0].type === "animated_gif",
|
||||||
|
mediaMetadata
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
const picker = media.map((content, i) => {
|
const picker = media.map((content, i) => {
|
||||||
@ -180,10 +186,17 @@ export default async function({ id, index, toGif, dispatcher }) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mediaMetadata = {
|
||||||
|
duration: Math.round(content.video_info.duration_millis / 1000),
|
||||||
|
likes: baseTweet.favorite_count,
|
||||||
|
views: Number(tweetResult.views.count)
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: 'video',
|
type: 'video',
|
||||||
url,
|
url,
|
||||||
thumb: content.media_url_https,
|
thumb: content.media_url_https,
|
||||||
|
mediaMetadata
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { picker };
|
return { picker };
|
||||||
|
@ -218,16 +218,25 @@ export default async function(o) {
|
|||||||
urls = [video.decipher(yt.session.player), audio.decipher(yt.session.player)];
|
urls = [video.decipher(yt.session.player), audio.decipher(yt.session.player)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mediaMetadata = {
|
||||||
|
duration: info.basic_info.duration,
|
||||||
|
likes: info.basic_info.like_count,
|
||||||
|
views: info.basic_info.view_count
|
||||||
|
};
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
filenameAttributes.qualityLabel = match.quality_label;
|
filenameAttributes.qualityLabel = match.quality_label;
|
||||||
filenameAttributes.resolution = `${match.width}x${match.height}`;
|
filenameAttributes.resolution = `${match.width}x${match.height}`;
|
||||||
filenameAttributes.extension = codecMatch[format].container;
|
filenameAttributes.extension = codecMatch[format].container;
|
||||||
filenameAttributes.youtubeFormat = format;
|
filenameAttributes.youtubeFormat = format;
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type,
|
type,
|
||||||
urls,
|
urls,
|
||||||
filenameAttributes,
|
filenameAttributes,
|
||||||
fileMetadata
|
fileMetadata,
|
||||||
|
mediaMetadata,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user