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

Upload Failed But Return Success #608

Open
4 tasks done
3IMAD69 opened this issue Feb 28, 2024 · 0 comments
Open
4 tasks done

Upload Failed But Return Success #608

3IMAD69 opened this issue Feb 28, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@3IMAD69
Copy link

3IMAD69 commented Feb 28, 2024

Steps to reproduce

im using the upload template

import { readFileSync, writeFileSync, existsSync } from 'fs';
import { Innertube, UniversalCache } from 'youtubei.js';
import { DeleteLink } from './db/WaitList';
import { updateStatus } from './server';

const creds_path = './client_secret.json';
const creds = existsSync(creds_path) ? JSON.parse(readFileSync(creds_path).toString()) : undefined;

export async function UploadShorts (filename:string,ShortTitle:string,desc:string | undefined,LinkID:string) {
  const yt = await Innertube.create({ cache: new UniversalCache(false) });
  
  yt.session.on('auth-pending', (data) => {
    console.info(`Hello!\nOn your phone or computer, go to ${data.verification_url} and enter the code ${data.user_code}`);
  });

  yt.session.on('auth', (data) => {
    writeFileSync(creds_path, JSON.stringify(data.credentials));
    console.info('Successfully signed in!');
  });

  yt.session.on('update-credentials', (data) => {
    writeFileSync(creds_path, JSON.stringify(data.credentials));
    console.info('Credentials updated!', data);
  });

  await yt.session.signIn(creds);
  
  const file = readFileSync('./ffmpeg-auto/'+filename+'.mp4');
  
  updateStatus("UPLOADING ...");
  console.log(`UPLOADING ...`);
  try{
    const upload = await yt.studio.upload(file.buffer, {
      title: ShortTitle,
      description: desc || hashtags,
      privacy: 'PUBLIC'
      // privacy: 'PRIVATE'
    });
    
  
    console.info('Done!', upload);
    if(upload.success){
      updateStatus("IDLE");
      console.log('Uploaded Succesfully')
      await DeleteLink(LinkID);
      return true
  
    }else{
      updateStatus("ERROR While Uploading");
      console.log('error while uploading')
      return false
    }
  }catch(error){
      console.log('Error While Uploading , '+error)
      updateStatus("ERROR While Uploading");
      //UploadShorts(filename,ShortTitle,desc,LinkID)
  }
 
  //delete file
}

output =>

UPLOADING ...
Done! {
  success: true,
  status_code: 200,
  data: {
    responseContext: {
      visitorData: 'CgtIb1ptMTJBc3l6ayiv3P2uBjIOCgJTRRIIEgQSAgsMIDE6CiCLxLrQh8bb72U%3D',
      serviceTrackingParams: [Array]
    },
    contents: { uploadFeedbackItemRenderer: [Object] }
  }
}
Uploaded Succesfully
Deleted from db 65df6aafe75bc5e2cbc95931

A good response should look like this with an ID to the uploaded video

UPLOADING ...
Done! {
  success: true,
  status_code: 200,
  data: {
    responseContext: {
      visitorData: 'CgtOcUNISTdHS2hVYyiojfquBjIOCgJTRRIIEgQSAgsMIGQ6CiCGmfazoNWh72U%3D',
      serviceTrackingParams: [Array],
      consistencyTokenJar: [Object]
    },
    videoId: 'CuLEWNkzgmM',
    contents: { uploadFeedbackItemRenderer: [Object] }
  }
}
Uploaded Succesfully
Deleted from db 65de1fbde75bc5e2cbc958c0

Failure Logs

the problem with this bug is that it only happend sometimes so to reproduce it , it will be hard , but im guessing that it could be when the video is too short and the upload is fast

Expected behavior

.

Current behavior

.

Version

Default

Anything else?

.

Checklist

  • I am running the latest version.
  • I checked the documentation and found no answer.
  • I have searched the existing issues and made sure this is not a duplicate.
  • I have provided sufficient information.
@3IMAD69 3IMAD69 added the bug Something isn't working label Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant