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

Throw error when an invalid character was used in the title #99

Merged
merged 1 commit into from
May 18, 2022
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
10 changes: 6 additions & 4 deletions package-lock.json

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

5 changes: 5 additions & 0 deletions src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ let browser: Browser, page: Page
let cookiesDirPath: string
let cookiesFilePath: string

const invalidCharacters = [ '<', '>' ]

const uploadURL = 'https://www.youtube.com/upload'
const homePageURL = 'https://www.youtube.com'
/**
Expand Down Expand Up @@ -65,6 +67,9 @@ async function uploadVideo(videoJSON: Video) {
if (!pathToFile) {
throw new Error("function `upload`'s second param `videos`'s item `video` must include `path` property.")
}
for (let i in invalidCharacters)
if (videoJSON.title.includes(invalidCharacters[i]))
throw new Error(`"${videoJSON.title}" includes a character not allowed in youtube titles (${invalidCharacters[i]})`)

if (videoJSON.channelName) {
await changeChannel(videoJSON.channelName);
Expand Down