mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-15 17:58:31 +00:00
wow that did not merge well
This commit is contained in:
parent
acd04d18ae
commit
687649a5e4
@ -234,7 +234,7 @@ export default async function({ host, patternMatch, params }) {
|
|||||||
case "threads":
|
case "threads":
|
||||||
r = await threads({
|
r = await threads({
|
||||||
...patternMatch,
|
...patternMatch,
|
||||||
quality: obj.vQuality,
|
quality: params.videoQuality,
|
||||||
dispatcher
|
dispatcher
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -108,6 +108,10 @@ export const services = {
|
|||||||
"s/:id"
|
"s/:id"
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
threads: {
|
||||||
|
patterns: [":user/post/:id"],
|
||||||
|
tld: "net",
|
||||||
|
},
|
||||||
tiktok: {
|
tiktok: {
|
||||||
patterns: [
|
patterns: [
|
||||||
":user/video/:postId",
|
":user/video/:postId",
|
||||||
|
@ -38,6 +38,9 @@ export const testers = {
|
|||||||
"streamable": pattern =>
|
"streamable": pattern =>
|
||||||
pattern.id?.length === 6,
|
pattern.id?.length === 6,
|
||||||
|
|
||||||
|
"threads": pattern =>
|
||||||
|
pattern.user?.length <= 33 && pattern.id?.length <= 32,
|
||||||
|
|
||||||
"tiktok": pattern =>
|
"tiktok": pattern =>
|
||||||
pattern.postId?.length <= 21 || pattern.id?.length <= 13,
|
pattern.postId?.length <= 21 || pattern.id?.length <= 13,
|
||||||
|
|
||||||
|
@ -34,31 +34,31 @@ export default async function({ user, id, quality, dispatcher }) {
|
|||||||
if (cookie) updateCookie(cookie, response.headers);
|
if (cookie) updateCookie(cookie, response.headers);
|
||||||
|
|
||||||
if (response.status !== 200) {
|
if (response.status !== 200) {
|
||||||
return { error: 'ErrorCouldntFetch' };
|
return { error: 'fetch.fail' };
|
||||||
}
|
}
|
||||||
const html = await response.text();
|
const html = await response.text();
|
||||||
const dataString = html.match(DATA_REGEX)?.[1];
|
const dataString = html.match(DATA_REGEX)?.[1];
|
||||||
if (!dataString) {
|
if (!dataString) {
|
||||||
return { error: 'ErrorCouldntFetch' };
|
return { error: 'fetch.fail' };
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = JSON.parse(dataString);
|
const data = JSON.parse(dataString);
|
||||||
const post = data?.require?.[0]?.[3]?.[0]?.__bbox?.require?.[0]?.[3]?.[1]?.__bbox?.result?.data?.data?.edges[0]?.node?.thread_items[0]?.post;
|
const post = data?.require?.[0]?.[3]?.[0]?.__bbox?.require?.[0]?.[3]?.[1]?.__bbox?.result?.data?.data?.edges[0]?.node?.thread_items[0]?.post;
|
||||||
if (!post) {
|
if (!post) {
|
||||||
return { error: 'ErrorCouldntFetch' };
|
return { error: 'fetch.fail' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Video
|
// Video
|
||||||
if (post.media_type === 2) {
|
if (post.media_type === 2) {
|
||||||
if (!post.video_versions) {
|
if (!post.video_versions) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'fetch.empty' };
|
||||||
}
|
}
|
||||||
|
|
||||||
// types: 640p = 101, 480p = 102, 480p-low = 103
|
// types: 640p = 101, 480p = 102, 480p-low = 103
|
||||||
const selectedQualityType = quality === 'max' ? 101 : quality && parseInt(quality) <= 480 ? 102 : 101;
|
const selectedQualityType = quality === 'max' ? 101 : quality && parseInt(quality) <= 480 ? 102 : 101;
|
||||||
const video = post.video_versions.find((v) => v.type === selectedQualityType) || post.video_versions.sort((a, b) => a.type - b.type)[0];
|
const video = post.video_versions.find((v) => v.type === selectedQualityType) || post.video_versions.sort((a, b) => a.type - b.type)[0];
|
||||||
if (!video) {
|
if (!video) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'fetch.empty' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -71,7 +71,7 @@ export default async function({ user, id, quality, dispatcher }) {
|
|||||||
// Photo
|
// Photo
|
||||||
if (post.media_type === 1) {
|
if (post.media_type === 1) {
|
||||||
if (!post.image_versions2?.candidates) {
|
if (!post.image_versions2?.candidates) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'fetch.empty' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -83,7 +83,7 @@ export default async function({ user, id, quality, dispatcher }) {
|
|||||||
// Mixed
|
// Mixed
|
||||||
if (post.media_type === 8) {
|
if (post.media_type === 8) {
|
||||||
if (!post.carousel_media) {
|
if (!post.carousel_media) {
|
||||||
return { error: 'ErrorEmptyDownload' };
|
return { error: 'fetch.empty' };
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -94,13 +94,12 @@ export default async function({ user, id, quality, dispatcher }) {
|
|||||||
** set to `same-origin`, so we need to proxy them */
|
** set to `same-origin`, so we need to proxy them */
|
||||||
thumb: createStream({
|
thumb: createStream({
|
||||||
service: "threads",
|
service: "threads",
|
||||||
type: "default",
|
type: "proxy",
|
||||||
u: media.image_versions2.candidates[0].url,
|
u: media.image_versions2.candidates[0].url
|
||||||
filename: "image.jpg"
|
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { error: 'ErrorUnsupported' };
|
return { error: 'fetch.fail' };
|
||||||
}
|
}
|
||||||
|
@ -1493,5 +1493,30 @@
|
|||||||
"status": "error"
|
"status": "error"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"threads": [{
|
||||||
|
"name": "video",
|
||||||
|
"url": "https://www.threads.net/@zuck/post/CzecNnZPaxr",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "photo",
|
||||||
|
"url": "https://www.threads.net/@soren.iverson/post/C8PdJ59pMLr",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "redirect"
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
"name": "mixed media",
|
||||||
|
"url": "https://www.threads.net/@snazzahguy/post/C8Q7UZDseWz",
|
||||||
|
"params": {},
|
||||||
|
"expected": {
|
||||||
|
"code": 200,
|
||||||
|
"status": "picker"
|
||||||
|
}
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user