Mikescops / pixelswap

📖 PixelSwap Blog
https://pixelswap.fr/
0 stars 0 forks source link

How to upload a video on Youtube with NodeJS | PixelSwap #2

Closed utterances-bot closed 10 months ago

utterances-bot commented 4 years ago

How to upload a video on Youtube with NodeJS | PixelSwap

I recently worked on a simple project for a Twitter user that wanted a way to reshare videos over Youtube. The Google documentation was not really clear so …

https://pixelswap.fr/entry/how-to-upload-a-video-on-youtube-with-nodejs

Mikescops commented 4 years ago

Waiting for your comments on this one!

muniv11111 commented 4 years ago

Hello,

I have problem with last step. How exactly call method uploadVideo?

Mikescops commented 4 years ago

Hey,

You can do something like:

uploadVideo(
    auth, // which is the result of the authorize method, you need to call prior to this
    (error, videoID) => {
        if(error) {
            return console.error(error);
        }

        return console.log('Success upload, video ID is ' + videoID);
    }
)

Let me know if that helps!

popeyebot commented 4 years ago

I have this error : errors: [ { message: 'Login Required.', domain: 'global', reason: 'required', location: 'Authorization', debugInfo: 'Authentication error: missing credentials.', locationType: 'header' } ] }

Can you help me ?

popeyebot commented 4 years ago

Problem solved.

Mikescops commented 4 years ago

Problem solved.

Sorry, I wasn't quick enough :sweat_smile:

nicolapreda commented 3 years ago

In index.js: cb is not defined.... how can i define that?

Mikescops commented 3 years ago

cb is usually a function like (error, result) => {console.log(error, result)}

If you give more context about your issue, I think I can give a better advice.

Glutch commented 3 years ago

Great article! How would i add support for multiple youtube accounts? (on the same email, if that matters, accessable here: https://www.youtube.com/channel_switcher)

Mikescops commented 3 years ago

@Glutch Instead of storing one token in a file you could store them all in a JSON file for instance.

Something like:

{
    "account1" : "token",
    "account2" : "token2"
}

Then you could add a new param to your program to define which account you want to use. Is that clear?

Glutch commented 3 years ago

@Mikescops Thank you, that worked nicely. However, i got quite a big problem. Whenever i upload a video with this script it gets automatically locked and privated, with a message about policy. With the only option to apply for an appeal. If i try to appeal i am instantly greeted with "This violation cannot be appealed". I have never before tinkered with the youtube api or done any spooky spam related things.

In the response from service.videos.insert i get status 200 with no error messages.

Now, if i upload the exact same video manually, to the same account, through youtube studio, the video is approved, public, no problems

Mikescops commented 3 years ago

@Glutch I don't know about this issue, it's mostly related to YouTube policy than the API, maybe you can ask this question to the YouTube support team. If you get any answer, please share here, I'm interested to know!

eliteval commented 3 years ago

In index.js: cb is not defined.... how can i define that?

Mikescops commented 3 years ago

Hey @onecodestar give examples of how you implement it!

DoVuDung commented 3 years ago

How is structure file look like ?

lonefox-xxx commented 1 year ago

I have this error : errors: [ { message: 'Login Required.', domain: 'global', reason: 'required', location: 'Authorization', debugInfo: 'Authentication error: missing credentials.', locationType: 'header' } ] }

Can you help me ?

bragiApp commented 1 year ago

Hi! I have a question. Does the callback function that the insert method accepts is fired after the uploading is done? Because i've uploaded this on an API route and it takes quite long before returning anything. If that's so then how do i return a response as soon as the uploading begins and show the progress as it continues? I am uploading directly from a server to YouTube, so nothing is being uploaded from client.