feat: change to url
This commit is contained in:
parent
69435a5530
commit
3f3157c35c
|
|
@ -173,7 +173,7 @@ export class FacebookProvider extends SocialAbstract implements SocialProvider {
|
|||
|
||||
let finalId = '';
|
||||
let finalUrl = '';
|
||||
if ((firstPost?.media?.[0]?.path?.indexOf('mp4') || -2) > -1) {
|
||||
if ((firstPost?.media?.[0]?.url?.indexOf('mp4') || -2) > -1) {
|
||||
const { id: videoId, permalink_url, ...all } = await (
|
||||
await this.fetch(
|
||||
`https://graph.facebook.com/v20.0/${id}/videos?access_token=${accessToken}&fields=id,permalink_url`,
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ export class InstagramProvider
|
|||
const isCarousel =
|
||||
(firstPost?.media?.length || 0) > 1 ? `&is_carousel_item=true` : ``;
|
||||
const mediaType =
|
||||
m.path.indexOf('.mp4') > -1
|
||||
m.url.indexOf('.mp4') > -1
|
||||
? firstPost?.media?.length === 1
|
||||
? `video_url=${m.url}&media_type=REELS`
|
||||
: `video_url=${m.url}&media_type=VIDEO`
|
||||
|
|
|
|||
|
|
@ -299,13 +299,13 @@ export class LinkedinProvider extends SocialAbstract implements SocialProvider {
|
|||
p?.media?.flatMap(async (m) => {
|
||||
return {
|
||||
id: await this.uploadPicture(
|
||||
m.path,
|
||||
m.url,
|
||||
accessToken,
|
||||
id,
|
||||
m.path.indexOf('mp4') > -1
|
||||
? Buffer.from(await readOrFetch(m.path))
|
||||
: await sharp(await readOrFetch(m.path), {
|
||||
animated: lookup(m.path) === 'image/gif',
|
||||
m.url.indexOf('mp4') > -1
|
||||
? Buffer.from(await readOrFetch(m.url))
|
||||
: await sharp(await readOrFetch(m.url), {
|
||||
animated: lookup(m.url) === 'image/gif',
|
||||
})
|
||||
.resize({
|
||||
width: 1000,
|
||||
|
|
|
|||
|
|
@ -153,10 +153,10 @@ export class PinterestProvider
|
|||
): Promise<PostResponse[]> {
|
||||
let mediaId = '';
|
||||
const findMp4 = postDetails?.[0]?.media?.find(
|
||||
(p) => (p.path?.indexOf('mp4') || -1) > -1
|
||||
(p) => (p.url?.indexOf('mp4') || -1) > -1
|
||||
);
|
||||
const picture = postDetails?.[0]?.media?.find(
|
||||
(p) => (p.path?.indexOf('mp4') || -1) === -1
|
||||
(p) => (p.url?.indexOf('mp4') || -1) === -1
|
||||
);
|
||||
|
||||
if (findMp4) {
|
||||
|
|
|
|||
|
|
@ -154,18 +154,18 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
|
|||
let link = '';
|
||||
|
||||
if (firstPost?.media?.length! <= 1) {
|
||||
const type = !firstPost?.media?.[0]?.path
|
||||
const type = !firstPost?.media?.[0]?.url
|
||||
? undefined
|
||||
: firstPost?.media![0].path.indexOf('.mp4') > -1
|
||||
: firstPost?.media![0].url.indexOf('.mp4') > -1
|
||||
? 'video_url'
|
||||
: 'image_url';
|
||||
|
||||
const media = new URLSearchParams({
|
||||
...(type === 'video_url'
|
||||
? { video_url: firstPost?.media![0].path }
|
||||
? { video_url: firstPost?.media![0].url }
|
||||
: {}),
|
||||
...(type === 'image_url'
|
||||
? { image_url: firstPost?.media![0].path }
|
||||
? { image_url: firstPost?.media![0].url }
|
||||
: {}),
|
||||
media_type:
|
||||
type === 'video_url'
|
||||
|
|
@ -209,11 +209,11 @@ export class ThreadsProvider extends SocialAbstract implements SocialProvider {
|
|||
const medias = [];
|
||||
for (const mediaLoad of firstPost.media!) {
|
||||
const type =
|
||||
mediaLoad.path.indexOf('.mp4') > -1 ? 'video_url' : 'image_url';
|
||||
mediaLoad.url.indexOf('.mp4') > -1 ? 'video_url' : 'image_url';
|
||||
|
||||
const media = new URLSearchParams({
|
||||
...(type === 'video_url' ? { video_url: mediaLoad.path } : {}),
|
||||
...(type === 'image_url' ? { image_url: mediaLoad.path } : {}),
|
||||
...(type === 'video_url' ? { video_url: mediaLoad.url } : {}),
|
||||
...(type === 'image_url' ? { image_url: mediaLoad.url } : {}),
|
||||
is_carousel_item: 'true',
|
||||
media_type:
|
||||
type === 'video_url'
|
||||
|
|
|
|||
|
|
@ -132,10 +132,10 @@ export class XProvider extends SocialAbstract implements SocialProvider {
|
|||
p?.media?.flatMap(async (m) => {
|
||||
return {
|
||||
id: await client.v1.uploadMedia(
|
||||
m.path.indexOf('mp4') > -1
|
||||
? Buffer.from(await readOrFetch(m.path))
|
||||
: await sharp(await readOrFetch(m.path), {
|
||||
animated: lookup(m.path) === 'image/gif',
|
||||
m.url.indexOf('mp4') > -1
|
||||
? Buffer.from(await readOrFetch(m.url))
|
||||
: await sharp(await readOrFetch(m.url), {
|
||||
animated: lookup(m.url) === 'image/gif',
|
||||
})
|
||||
.resize({
|
||||
width: 1000,
|
||||
|
|
@ -143,7 +143,7 @@ export class XProvider extends SocialAbstract implements SocialProvider {
|
|||
.gif()
|
||||
.toBuffer(),
|
||||
{
|
||||
mimeType: lookup(m.path) || '',
|
||||
mimeType: lookup(m.url) || '',
|
||||
}
|
||||
),
|
||||
postId: p.id,
|
||||
|
|
|
|||
|
|
@ -158,11 +158,11 @@ export class YoutubeProvider extends SocialAbstract implements SocialProvider {
|
|||
...(settings?.tags?.length
|
||||
? { tags: settings.tags.map((p) => p.label) }
|
||||
: {}),
|
||||
// ...(settings?.thumbnail?.path
|
||||
// ...(settings?.thumbnail?.url
|
||||
// ? {
|
||||
// thumbnails: {
|
||||
// default: {
|
||||
// url: settings?.thumbnail?.path,
|
||||
// url: settings?.thumbnail?.url,
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
|
|
|
|||
Loading…
Reference in New Issue