Skip to content

Commit

Permalink
Merge pull request #32 from charan0017/main
Browse files Browse the repository at this point in the history
onSuccess feature (#31)
  • Loading branch information
fawazahmed0 committed Aug 23, 2021
2 parents 197f0b9 + a9bec68 commit c6f7578
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
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

0 comments on commit c6f7578

Please sign in to comment.