askwpcoach 0 Posted November 1, 2014 Report Share Posted November 1, 2014 (edited) Hello, I am working on writing a bot that will allow the user to gather Youtube videos to a list for posting on their WordPress website. My problem, is that this code: loop while($comparison(#stop, "!=", "Stop")) { set(#add_all_videos, "false", "Global") set(#add_video, "false", "Global") if($comparison(#add_all_videos, "=", "add")) { then { add list to list(%vid_urls, $scrape attribute(<class="contains-addto yt-uix-sessionlink spf-link ">, "fullhref"), "Delete", "Global") } else { } } if($comparison(#add_video, "=", "add")) { then { add item to list(%vid_titles, $scrape attribute(<id="eow-title">, "innertext"), "Delete", "Global") wait(3) click(<class="yt-uix-button yt-uix-button-size-default yt-uix-button-expander yt-uix-expander-head yt-uix-expander-collapsed-body yt-uix-gen204">, "Left Click", "No") wait(3) add item to list(%vid_description, $scrape attribute(<(tagname="p" AND id="eow-description")>, "innertext"), "Delete", "Global") } else { } } increment(#position) } The code above is causing my ubot studio to freeze. Below is the full code for my bot: ui save file("Where to save video data", #save_vid) ui stat monitor("Number of Youtube URLs:", $list total(%vid_urls)) ui stat monitor("Number of titles scrapped:", $list total(%vid_titles)) ui stat monitor("Number of desc scrapped:", $list total(%vid_description)) set(#position, 0, "Global") ui button("Add this video") { set(#add_video, "add", "Global") } ui button("Add all videos") { set(#add_all_videos, "add", "Global") } ui button("Done adding") { set(#stop, "Stop", "Global") } set(#stop, "Go", "Global") loop while($comparison(#stop, "!=", "Stop")) { set(#add_all_videos, "false", "Global") set(#add_video, "false", "Global") if($comparison(#add_all_videos, "=", "add")) { then { add list to list(%vid_urls, $scrape attribute(<class="contains-addto yt-uix-sessionlink spf-link ">, "fullhref"), "Delete", "Global") } else { } } if($comparison(#add_video, "=", "add")) { then { add item to list(%vid_titles, $scrape attribute(<id="eow-title">, "innertext"), "Delete", "Global") wait(3) click(<class="yt-uix-button yt-uix-button-size-default yt-uix-button-expander yt-uix-expander-head yt-uix-expander-collapsed-body yt-uix-gen204">, "Left Click", "No") wait(3) add item to list(%vid_description, $scrape attribute(<(tagname="p" AND id="eow-description")>, "innertext"), "Delete", "Global") } else { } } increment(#position) } wait(3) add list to table as column(&video_data, 0, 0, %vid_titles) add list to table as column(&video_data, 0, 1, %vid_description) add list to table as column(&video_data, 0, 2, %vid_category) add list to table as column(&video_data, 0, 3, %vid_urls) wait(3) save to file(#save_vid, &video_data) clear list(%vid_urls) Any idea what I am doing wrong here? Edited November 1, 2014 by askwpcoach Quote Link to post Share on other sites
UBotDev 276 Posted November 1, 2014 Report Share Posted November 1, 2014 I think none of the if conditions are meet, so your code is looping like crazy, freezing the UI. Solution: Try to add 1s delay at the end of the loop. Quote Link to post Share on other sites
askwpcoach 0 Posted November 2, 2014 Author Report Share Posted November 2, 2014 Thanks for your solution, you were correct about the problem. After adding wait commands, the script no longer freezes the UI. Thanks for your help. Quote Link to post Share on other sites
UBotDev 276 Posted November 2, 2014 Report Share Posted November 2, 2014 Great to hear! Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.