Skip to content

Commit

Permalink
Merge pull request #180 from DaddyFrosty/main
Browse files Browse the repository at this point in the history
Fixed issue where uploading would result in Show More being toggled incorrectly…
  • Loading branch information
fawazahmed0 committed Jan 7, 2023
2 parents 7878839 + 9890efc commit d129f7f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ comment(credentials, [comment1], {headless:false}).then(console.log)
- [Sai Charan](https://github.com/charan0017) - For [onSuccess Option](https://github.com/fawazahmed0/youtube-uploader/pull/32)
- [Tue Nguyen](https://github.com/TueeNguyen) - For [Better error messages](https://github.com/fawazahmed0/youtube-uploader/pull/46)
- [weizhiqimail](https://github.com/weizhiqimail) - For [Extra Debug messages](https://github.com/fawazahmed0/youtube-uploader/pull/47)
- [DaddyFrosty](https://github.com/DaddyFrosty) - For [Path Escaping](https://github.com/fawazahmed0/youtube-uploader/pull/55), [Skip Processing wait](https://github.com/fawazahmed0/youtube-uploader/pull/57) and [onProgress event](https://github.com/fawazahmed0/youtube-uploader/pull/60)
- [DaddyFrosty](https://github.com/DaddyFrosty) - For [Path Escaping](https://github.com/fawazahmed0/youtube-uploader/pull/55), [Skip Processing wait](https://github.com/fawazahmed0/youtube-uploader/pull/57), [onProgress event](https://github.com/fawazahmed0/youtube-uploader/pull/60) and [Show More being toggled incorrectly…](https://github.com/fawazahmed0/youtube-uploader/pull/180)
- [Owl Burger](https://github.com/Zebraslive) - For [Create Channel](https://github.com/fawazahmed0/youtube-uploader/pull/66)
- [Ítalo Andrade](https://github.com/italodeandra) - For [Channel Switcher](https://github.com/fawazahmed0/youtube-uploader/pull/73)
- [Dominic Findlay](https://github.com/DominicFindlay) - For Supporting [Single Quotes in playlist name](https://github.com/fawazahmed0/youtube-uploader/pull/82) and [skip processing bug fix](https://github.com/fawazahmed0/youtube-uploader/pull/162)
Expand Down
31 changes: 26 additions & 5 deletions src/upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Credentials, Video, VideoToEdit, Comment, VideoProgress, ProgressEnum, MessageTransport } from './types'
import puppeteer from 'puppeteer-extra'
import { PuppeteerNodeLaunchOptions, Browser, Page } from 'puppeteer'
import { PuppeteerNodeLaunchOptions, Browser, Page, ElementHandle } from 'puppeteer'
import fs from 'fs-extra'
import path from 'path'

Expand Down Expand Up @@ -217,11 +217,13 @@ async function uploadVideo(videoJSON: Video, messageTransport: MessageTransport)
await textBoxes[0].evaluate(e => (e as any).__shady_native_textContent = "")
await textBoxes[1].type(description.substring(0, maxDescLen))


const childOption = await page.$x('//*[contains(text(),"No, it\'s")]')
await childOption[0].click()
const moreOption = await page.$x("//*[normalize-space(text())='Show more']")
await moreOption[0].click()

// There is no reason for this to be called. Also you should be using #toggle-button not going by the text...
// const moreOption = await page.$x("//*[normalize-space(text())='Show more']")
// await moreOption[0]?.click()

const playlist = await page.$x("//*[normalize-space(text())='Select']")
let createplaylistdone
if (playlistName) {
Expand Down Expand Up @@ -262,6 +264,7 @@ async function uploadVideo(videoJSON: Video, messageTransport: MessageTransport)
}
}
}

if (!videoJSON.isNotForKid) {
await page.click("tp-yt-paper-radio-button[name='VIDEO_MADE_FOR_KIDS_MFK']").catch(()=>{})
} else if (videoJSON.isAgeRestriction) {
Expand All @@ -270,7 +273,25 @@ async function uploadVideo(videoJSON: Video, messageTransport: MessageTransport)
await page.click("tp-yt-paper-radio-button[name='VIDEO_MADE_FOR_KIDS_NOT_MFK']").catch(()=>{})
}
// await page.waitForXPath('//ytcp-badge[contains(@class,"draft-badge")]//div[contains(text(),"Saved as private")]', { timeout: 0})
await page.click("#toggle-button")

// await page.click("#toggle-button")
// Was having issues because of await page.$x("//*[normalize-space(text())='Show more']").click(), so I started messing with the line above.
// The issue was obviously not the line above but I either way created code to ensure that Show more has been pressed before proceeding.
let showMoreButton = await page.$( "#toggle-button" )
if ( showMoreButton == undefined )
throw `uploadVideo - Toggle button not found.`
else {
// console.log( "Show more start." )
let moreInformation: ElementHandle
while ( ( moreInformation = await page.$( "ytcp-video-metadata-editor-advanced" ) ) == undefined )
{
// console.log( "Show more while." )
await showMoreButton.click()
await sleep( 1000 )
}
// console.log( "Show more finished." )
}

// Add tags
if (tags) {
//show more
Expand Down

0 comments on commit d129f7f

Please sign in to comment.