Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SendVideoAsGif() returns "null a: a" ??? #3259

Open
1 task done
TVARecordings opened this issue Dec 4, 2024 · 0 comments
Open
1 task done

SendVideoAsGif() returns "null a: a" ??? #3259

TVARecordings opened this issue Dec 4, 2024 · 0 comments

Comments

@TVARecordings
Copy link

TVARecordings commented Dec 4, 2024

Are you using the latest version of the library?

  • I have checked and am using the latest version of the library.

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Business account

Mode

My own code

Current Behavior

It's returning this error:

fetch(1/1): Attempting to send media 1 of type mp4 from hentai_gif
Sending "A fun gathering " as sendFile() from E:\AmecaCore\media\GetReddit\MP4\Da_Darius_1733273220.mp4
sendVideoAsGif: Received data:
{
"type": "mp4",
"filePath": "E:\AmecaCore\media\GetReddit\MP4\Da_Darius_1733273220.mp4",
"source": "hentai_gif",
"title": "A fun gathering ",
"author": "Da_Darius"
}
Error on first try to SendVideoAsGif([email protected],
Path: E:\AmecaCore\media\GetRedditMP4\Da_Darius_1733273220.mp4
SendMP4Results = null a: a
at #evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:388:56)
at async ExecutionContext.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\ExecutionContext.js:275:16)
at async IsolatedWorld.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\cdp\IsolatedWorld.js:100:16)
at async CdpFrame.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Frame.js:341:20)
at async CdpPage.evaluate (E:\AmecaCore\node_modules\puppeteer-core\lib\cjs\puppeteer\api\Page.js:807:20)

Code: (Snippits)
One part:

for (let index = 0; index < maxSources; index++) {
       await sleep(2500);
       progressLog(`fetch(${index}/${maxSources})`, `mediaQueue = ${JSON.stringify(mediaQueue, null, 2)}`);
       console.log(`Processed ${index} of ${maxSources}`);
       if (index < maxSources) {
           const source = sources[index];

           progressLog(`fetch(${source} ${index}/${maxSources})`, `Processing source ${index} of ${maxSources}: ${source}`);
           try {
               const media = await getMedia(source);  // Haal de media op met await
               progressLog(`fetch(${source} ${index}/${maxSources})`, `media? ${media ? true : false}`);
               let filePath
               if (media) {
                   progressLog(`fetch(${source} ${index}/${maxSources})`, `Entered if (media) {`);
                   const {
                       mediaUrl: videoUrl,    // De URL van de media
                       mediaType: mediaType,  // Type van de media ('image' of 'gif')
                       author: videoAuthor,   // Auteur van de media
                       title: videoTitle,     // Titel van de media
                       description: videoDescription,  // Beschrijving van de media
                       upvotes: videoUpvotes, // Aantal upvotes
                       downvotes: videoDownvotes, // Aantal downvotes
                       numComments: videoNumComments, // Aantal reacties
                       postUrl: videoPostUrl  // URL naar de Reddit post
                   } = media;  // Haal het eerste object uit de media
                   progressLog(`fetch(${source} ${index}/${maxSources})`, `Fetched media-data = ${JSON.stringify(media)}`);

                   progressLog(`fetch(${source} ${index}/${maxSources})`, `media.mediaType = ${media.mediaType}\nmediaType = ${mediaType}`);
                   if (mediaType === 'gif') {
                       progressLog(`fetch(${source} ${index}/${maxSources})`, `Entered if (mediaType === 'gif')`);
                       

                       const {
                           outputFilePath,  // Path to the compressed video
                       } = await DownloadVideo(media.mediaUrl, `E:/AmecaCore/media/GetReddit/MP4/`, videoAuthor, videoTitle)
                       await waitForPath(outputFilePath);
                       await sleep(1000)
                       progressLog(`fetch(${source} ${index}/${maxSources})`, `Adding the following to mediaQueue: \ntype = mp4\nfilePath = ${outputFilePath}\nsource: ${source}`);
                       mediaQueue.push({
                           type: 'mp4',
                           filePath: outputFilePath,
                           source: source,
                           title: videoTitle,
                           author: videoAuthor,

                       });

Another bit

   for (const media of mediaQueue) {
        await sleep(250)
        if (logs) progressLog(`fetch(${sentFilesCount}/${totalMedia})`, `Attempting to send media ${sentFilesCount} of type ${media.type} from ${media.source}`)
        try {
            if (media.type === 'mp4') {
                let SendMP4Results = null
                try {
                    if (logs) console.log(`${colors.whiteBright.bold(`Sending`)} "${media.title}" ${colors.whiteBright.bold(`as sendFile()`)} from ${media.filePath}`);
                    console.log(`sendVideoAsGif: Received data:\n${JSON.stringify(media, null, 2)}`)
                    const messageText = `\`#${sentFilesCount}\` *r/${media.source}* ${media.title}${isTVACommunity || SilentMode ? '' : '\n\nVia Bot-Ameca: https://www.tva-community.chat/'}`;

                    SendMP4Results = await Client.sendVideoAsGif(ChatID, media.filePath, `${media.title}.mp4`, messageText);

                    if (logs) console.log(`${colors.whiteBright.bold(`Successfully sent`)} "${media.filePath}" ${colors.whiteBright.bold(`as sendVideoAsGif()`)}`);
                    fs.unlinkSync(media.filePath);
                } catch (error) {
                    console.error(`Error on first try to SendVideoAsGif(${ChatID}, \nPath: ${media.filePath}\nSendMP4Results = ${SendMP4Results}`, error)
                }
            }

Expected Behavior

Expected it to send the MP4-file as a GIF...

Steps To Reproduce

Check code

create() code OR full CLI command + CONFIG

No response

DEBUG INFO

{
  "WA_VERSION": "2.3000.1018583339",
  "WA_AUTOMATE_VERSION": "4.74.2",
  "BROWSER_VERSION": "Chrome/131.0.6778.86",
  "START_TS": 1733273171982,
  "RAM_INFO": "Total: 68.62 GB | Free: 47.92 GB",
  "PPTR_VERSION": "23.6.0",
  "LATEST_VERSION": true,
  "CLI": false,
  "PATCH_HASH": "CACHED-58bbb",
  "LAUNCH_TIME_MS": 6897,
  "ACC_TYPE": "BUSINESS",
  "chats": 113,
  "messages": 147,
  "contacts": 14144,
  "isBiz": true,
  "isMd": true,
  "INSTANCE_ID": "f1ea2cd0-84ac-473e-a392-ee81a06ce59a"
}

Environment

- OS: Windows 10
- Node: 20.17.0
- npm: 10.8.3

Screenshots/Logs

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant