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

onSuccess feature (https://github.com/fawazahmed0/youtube-uploader/issues/31) #32

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ const credentials = { email: 'email', pass: 'pass', recoveryemail: 'recoveryemai
const video1 = { path: 'video1.mp4', title: 'title 1', description: 'description 1' }

// Extra options like tags, thumbnail, language, playlist etc
const video2 = { path: 'video2.mp4', title: 'title 2', description: 'description 2', thumbnail:'thumbnail.png', language: 'english', tags: ['video', 'github'], playlist: 'playlist name' }
const video2 = { path: 'video2.mp4', title: 'title 2', description: 'description 2', thumbnail:'thumbnail.png', language: 'english', tags: ['video', 'github'], playlist: 'playlist name', onSuccess:onVideoUploadSuccess }

const onVideoUploadSuccess = (videoUrl) => {
// ..do something..
}
// Returns uploaded video links in array
upload (credentials, [video1, video2]).then(console.log)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "youtube-videos-uploader",
"version": "1.3.7",
"version": "1.3.8",
"description": "Uploads videos to youtube without any limits",
"main": "upload.js",
"dependencies": {
Expand Down
14 changes: 13 additions & 1 deletion upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ const credentials = { email: 'email', pass: 'pass', recoveryemail: 'recoveryemai
const video1 = { path: 'video1.mp4', title: 'title 1', description: 'description 1' }

// Extra options like tags, thumbnail, language, playlist etc
const video2 = { path: 'video2.mp4', title: 'title 2', description: 'description 2', thumbnail:'thumbnail.png', language: 'english', tags: ['video', 'github'], playlist: 'playlist name' }
const video2 = { path: 'video2.mp4', title: 'title 2', description: 'description 2', thumbnail:'thumbnail.png', language: 'english', tags: ['video', 'github'], playlist: 'playlist name', onSuccess:onVideoUploadSuccess }

const onVideoUploadSuccess = (videoUrl) => {
// ..do something..
}


// Returns uploaded video links in array
upload (credentials, [video1, video2]).then(console.log)
Expand Down Expand Up @@ -60,6 +65,7 @@ module.exports.upload = upload
* @property {string[]|undefined} tags
* @property {string|undefined} language
* @property {string|undefined} playlist
* @property {function|undefined} onSuccess
*/

/**
Expand Down Expand Up @@ -92,6 +98,12 @@ async function upload (credentials, videos, puppeteerLaunch) {

for (const video of videos) {
const link = await uploadVideo(video)

const { onSuccess } = video
if (typeof onSuccess === 'function') {
onSuccess(link)
}

uploadedYTLink.push(link)
}

Expand Down