mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-18 19:28:29 +00:00
Merge 29ee3a6e7e
into cb2bde5b51
This commit is contained in:
commit
d25aad8d32
17
docs/api.md
17
docs/api.md
@ -35,14 +35,15 @@ Content-Type: application/json
|
|||||||
| `tiktokH265` | `boolean` | `true / false` | `false` | changes whether 1080p h265 videos are preferred or not. |
|
| `tiktokH265` | `boolean` | `true / false` | `false` | changes whether 1080p h265 videos are preferred or not. |
|
||||||
|
|
||||||
### 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`, `views`, `title` |
|
||||||
|
|
||||||
### 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;
|
||||||
|
|
||||||
|
@ -36,6 +36,17 @@ function bestQuality(arr) {
|
|||||||
.url
|
.url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildMediaMetadata(tweetResult, media){
|
||||||
|
return {
|
||||||
|
duration: Math.round(media.video_info.duration_millis / 1000) || 0,
|
||||||
|
likes: tweetResult.legacy.favorite_count || 0,
|
||||||
|
views: Number(tweetResult.views.count) || 0,
|
||||||
|
title: (tweetResult.legacy && tweetResult.legacy.full_text && Array.isArray(tweetResult.legacy.display_text_range) && tweetResult.legacy.display_text_range[0] !== undefined && tweetResult.legacy.display_text_range[1] !== undefined)
|
||||||
|
? tweetResult.legacy.full_text.substr(tweetResult.legacy.display_text_range[0], tweetResult.legacy.display_text_range[1] - tweetResult.legacy.display_text_range[0])
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let _cachedToken;
|
let _cachedToken;
|
||||||
const getGuestToken = async (dispatcher, forceReload = false) => {
|
const getGuestToken = async (dispatcher, forceReload = false) => {
|
||||||
if (_cachedToken && !forceReload) {
|
if (_cachedToken && !forceReload) {
|
||||||
@ -164,7 +175,8 @@ export default async function({ id, index, toGif, dispatcher }) {
|
|||||||
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: buildMediaMetadata(tweetResult, media[0])
|
||||||
};
|
};
|
||||||
default:
|
default:
|
||||||
const picker = media.map((content, i) => {
|
const picker = media.map((content, i) => {
|
||||||
@ -184,6 +196,7 @@ export default async function({ id, index, toGif, dispatcher }) {
|
|||||||
type: 'video',
|
type: 'video',
|
||||||
url,
|
url,
|
||||||
thumb: content.media_url_https,
|
thumb: content.media_url_https,
|
||||||
|
mediaMetadata: buildMediaMetadata(tweetResult, content)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return { picker };
|
return { picker };
|
||||||
|
@ -49,6 +49,12 @@ export default async function(o) {
|
|||||||
resolution: `${quality}p`,
|
resolution: `${quality}p`,
|
||||||
qualityLabel: `${quality}p`,
|
qualityLabel: `${quality}p`,
|
||||||
extension: "mp4"
|
extension: "mp4"
|
||||||
|
},
|
||||||
|
mediaMetadata: {
|
||||||
|
duration: js.player.params[0].duration,
|
||||||
|
likes: js.mvData.likes,
|
||||||
|
views: js.videoModalInfoData.views,
|
||||||
|
title: js.mvData.title
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { error: 'ErrorEmptyDownload' }
|
return { error: 'ErrorEmptyDownload' }
|
||||||
|
@ -224,16 +224,26 @@ 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,
|
||||||
|
title: info.basic_info.title,
|
||||||
|
};
|
||||||
|
|
||||||
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