Updating DailyMotion to work with new website design

This commit is contained in:
2023-07-29 19:00:14 -04:00
parent bf46f44442
commit 34e7ed72ed
2 changed files with 49 additions and 96 deletions

View File

@@ -3913,7 +3913,8 @@ Loop, 5 { ; make a couple attempts to input description
; Make a couple attempts to Click on Drop down menu and select the "Education" Category
TooltipThis("Selecting Education Category")
Message = Selecting Education Category
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Loop, 3 {
if(A_index = 3){
@@ -3938,7 +3939,6 @@ Loop, 3 {
}
Message = Inputting Tags
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
@@ -3958,45 +3958,19 @@ try, inputTags := driver.executeScript(js)
Message = Tags that got input: %inputTags% (Will be doubled b/c of js)
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; DevModeMsgBox(message)
/*sleep, 2000 ; sleep 2 seconds for everything to catch up GUI wise
loop, 5 {
if(A_index = 4) ; if this is attempt number 5 then category wasn't able to be selected
{
Message = Upload Incomplete (E#5874)`nUnable to Select "Education" category`nPlease Select it and click the save button to finalize upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; Return ; Kick out of the gosub
}
; msgbox
Message = Clicking Next Button to Move on to next input screen
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
; ; click dropdown menu
; JsToExecute = document.getElementsByClassName('ant-select-selection__rendered')[1].click(); ; Save Video Button
; Status := JS_TryToExecute(JsToExecute)
xpath = (//div[@role='combobox'])[3]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
; driver.FindElementByXPath(Xpath).click()
; select "educaiton" category
Xpath = //li[normalize-space()='Education']
Xpath = //button[@type='button']//span[contains(text(),'Next')]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
; msgbox, click work?
jsCheck = return document.getElementsByClassName('ant-select-selection-selected-value')[1].textContent;
try SelectedCategory := driver.executeScript(jsCheck)
if(SelectedCategory = "Education")
Break
Message = Selecting "Not For Kids" checkbox
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
try SelectedCategory := driver.findelementbyxpath(CategoryBoxXpath).Attribute("innerText") ;GREAT FOR GRABBING INNER CONTENTS/Values
if(SelectedCategory = "Education")
Break
}
*/
TooltipThis("Checking Not for Kids checkbox")
try driver.findElementsByName("is_created_for_kids").item[2].click()
catch e {
sleep, 2000
@@ -4022,12 +3996,12 @@ if(Status = "Failed"){
*/
SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile")
; SaveOrPostProgress(Message:="Unchecking monetizaton checkbox",PostType:="Tooltip,ErrorLoggingTextFile")
; switch over to advanced tab
js = document.getElementsByName('advanced')[0].click();
try driver.executeScript(js)
; js = document.getElementsByName('advanced')[0].click();
; try driver.executeScript(js)
/*
sleep, 1000
Loop, 5 { ; Loop to uncheck the "monetization button"
@@ -4047,74 +4021,53 @@ Break
Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
}
*/
/*
; Switch back to Basic tab
js = document.getElementsByName('basic')[0].click();
try driver.executeScript(js)
*/
; Grab the Share URL and pull out the Video Link from it and save it to the Video Linsk ini file, so double uploads are not tried if fialure occurs
Message = Grabbing Share URL
Message = Clicking Next Button to Move on to third video settings screen
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //button[@type='button']//span[contains(text(),'Next')]
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
Message = Clicking Save Button to Finalize Upload
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //span[normalize-space()='Save']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=2,SleepLength:=1000)
if(Status){
Message = Upload was ALMOST successfuly. Failed to Click Final Save button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
}
; Grab the Share URL and pull out the Video Link from it and save it to the Video links ini file, so double uploads are not tried if fialure occurs
Message = Waiting 30 seconds before grabbing Video URL
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile")
Xpath = //span[contains(text(),'Share link:')]
try ShareLink := driver.findelementbyxpath(Xpath).Attribute("innerText")
; Message = %ShareLink%
SaveOrPostProgress(Message:=ShareLink,PostType:="Tooltip,ErrorLoggingTextFile")
DailyMotionURL := StrReplace(ShareLink, "Share link: ","") ; remove the share link text from string
IniWrite, %DailyMotionURL%, %VideoLinksIniFile%, URLs, DailyMotionURL ; save URL
sleep, 30000
Message = Clicking Publish Button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //span[normalize-space()='Publish']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1500)
if(Status){
Message = Failed to submit with Publish //span button. Trying with //button
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
Xpath = //button[@name='submit']
Status := Selenium_LoopToClickXpath(Xpath:=Xpath,NumOfLoops:=10,SleepLength:=1500)
if(Status){
Message = Failed to submit with //button button. Trying with JS
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,DiscordErrorLogging")
js = document.getElementsByClassName('ant-btn ant-btn-primary ant-btn-sm')[1].click();
try driver.executeScript(js)
Message = Most likely failed to click the Publish button on video. Please click Publish on the DailyMotion tab to finalize.
Xpath = //ul[@data-test-id='videos-media-list']//li//div//div//div//div//h3//a
try, DailyMotionInternalURL := driver.findelementbyxpath(Xpath).Attribute("href")
if(DailyMotionInternalURL = ""){
Message = Failed to Grab Video URL. Upload Most likely Failed.
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
SaveDriverURLOFErrorPage()
}
Return
}
; Progress Percentage
; TooltipThis("Waiting for Video to Finish Uploading`nChecking Progress Every 5 seconds")
; Xpath = //span[contains(text(),'Upload at')]
; jsCheck = return document.getElementsByClassName('src-routes-media-pages-upload-components-slot-index__shareLink--nc1-O')[0].textContent;
; try ShareLink := driver.executeScript(jsCheck)
; Message = ShareLink: %ShareLink%
; SaveOrPostProgress(Message:=Message,PostType:="ErrorLoggingTextFile")
if(!InStr(ShareLink, "https")){
Message = Upload Successful but Failed to Grab Video URL
SaveOrPostProgress(Message:=Message,PostType:="Tooltip,ErrorLoggingTextFile,ErrorSummaryVar,DiscordErrorLogging")
; Return
}
DailyMotionURL := StrReplace(ShareLink, "Share link: ","") ; remove the share link text from string
; Pull out URL slug from internal video URL and create dailymotion share URL from it
DailyMotionURL := StrSplit(DailyMotionInternalURL, "/video/details/")[2]
DailyMotionURL := "https://www.dailymotion.com/video/" . DailyMotionURL
Message = Upload Complete: %DailyMotionURL%