Page 1 of 1

Making a macro that likes all the videos in a YouTube playlist

Posted: Mon Apr 05, 2021 9:26 am
by nclm
Hi,

I’m new to iMacros, and I’m trying to make a macro that could transfer all the videos from my old “Favorites” playlist on YouTube to the “Liked videos” section.
The idea is to go through all the videos of the playlist, and press the like button on each video, unless it is already pressed.

Config info:
  • iMacros version 10.0.2.1450 (free version)
  • Ubuntu 20.10, English
  • Firefox 89.0a1 (2021-04-05) (64-bit)
Difficulties:
  • Some videos are already liked, so the button should not be pressed in that case.
  • On the already-liked videos, the “Dislike” button should never be pressed, even if it is the first matching unpressed button.
  • If the button is already pressed and the selector therefore doesn’t match, it should just skip to the next video.
  • The playlist page has infinite scroll, so to be able to index all the videos, it should be scrolled down.
The way I see the script working would be:
  • Open the playlist.
  • Scroll down and down and down until all the list is loaded.
  • Index all the URLs for all the videos in the list.
  • Visit all the videos one by one, and for each of them:
  • Locate the first button in the “Like/Dislike” pair of buttons.
  • If, and only if, the button is not pressed already, press it.
  • Go the the next video, etc.
Being new at this, it’s pretty trick for me. I get some of it working, but definitely not all.

To kickstart the thing, some CSS selectors that can select the right button in the right state:

Code: Select all

#top-level-buttons > ytd-toggle-button-renderer:first-child yt-icon-button.style-text:not(.style-default-active")

Code: Select all

#top-level-buttons yt-icon-button button[aria-label^="like"][aria-pressed="false"]:not([aria-label^="dislike"]):not([aria-pressed="true"])
My current script is something like:

Code: Select all

URL GOTO=https://www.youtube.com/playlist?list=URL-OF-PLAYLIST
TAG POS={{!LOOP}} TYPE=A ATTR=ID:video-title
SET !ERRORIGNORE YES
TAG SELECTOR="#top-level-buttons > ytd-toggle-button-renderer:first-child yt-icon-button.style-text"
SET !ERRORIGNORE NO
but it does not work properly, and does not implement the scroll thing yet/anymore, which I think should happen first and only once?

Can someone more experienced help me build this?
Thanks!!

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Mon Apr 05, 2021 2:06 pm
by chivracq
nclm wrote:
Mon Apr 05, 2021 9:26 am
Hi,

I’m new to iMacros, and I’m trying to make a macro that could transfer all the videos from my old “Favorites” playlist on YouTube to the “Liked videos” section.
The idea is to go through all the videos of the playlist, and press the like button on each video, unless it is already pressed.

Difficulties:
  • Some videos are already liked, so the button should not be pressed in that case.
  • On the already-liked videos, the “Dislike” button should never be pressed, even if it is the first matching unpressed button.
  • If the button is already pressed and the selector therefore doesn’t match, it should just skip to the next video.
  • The playlist page has infinite scroll, so to be able to index all the videos, it should be scrolled down.
The way I see the script working would be:
  • Open the playlist.
  • Scroll down and down and down until all the list is loaded.
  • Index all the URLs for all the videos in the list.
  • Visit all the videos one by one, and for each of them:
  • Locate the first button in the “Like/Dislike” pair of buttons.
  • If, and only if, the button is not pressed already, press it.
  • Go the the next video, etc.
Being new at this, it’s pretty trick for me. I get some of it working, but definitely not all.

To kickstart the thing, some CSS selectors that can select the right button in the right state:

Code: Select all

#top-level-buttons > ytd-toggle-button-renderer:first-child yt-icon-button.style-text:not(.style-default-active")

Code: Select all

#top-level-buttons yt-icon-button button[aria-label^="like"][aria-pressed="false"]:not([aria-label^="dislike"]):not([aria-pressed="true"])
My current script is something like:

Code: Select all

URL GOTO=https://www.youtube.com/playlist?list=URL-OF-PLAYLIST
TAG POS={{!LOOP}} TYPE=A ATTR=ID:video-title
SET !ERRORIGNORE YES
TAG SELECTOR="#top-level-buttons > ytd-toggle-button-renderer:first-child yt-icon-button.style-text"
SET !ERRORIGNORE NO
but it does not work properly, and does not implement the scroll thing yet/anymore, which I think should happen first and only once?

Can someone more experienced help me build this?
Thanks!!

Alright, good Quality for a first Post/Thread, good...! :D
... But "CIM" for me to have a Look... (Read my Sig..., ... and the Forum Rules... :idea: )

And I usually don't help for Social Media and 'Like'/'Follow'/etc..., but this one sounds "a bit interesting"..., and I will have a few other Qt's, but mention first your FCI (preferably at the very Top of your OP, this is the first Info "we" need about a Thread...) for me to "dig" any further... :|

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Mon Apr 05, 2021 2:15 pm
by nclm
Hi, thanks for your reply and your help!
Oops, sorry for the config info missing, I just added it in the original post :)

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Mon Apr 05, 2021 2:26 pm
by chivracq
nclm wrote:
Mon Apr 05, 2021 2:15 pm
Hi, thanks for your reply and your help!
Oops, sorry for the config info missing, I just added it in the original post :)
Config info:
  • iMacros version 10.0.2.1450
  • Ubuntu 20.10, English
  • Firefox 89.0a1 (2021-04-05) (64-bit)

OK, "nearly" good, but 'Free'/'PE' is still missing from your FCI...?

Hum..., and I didn't know/wasn't sure that the 'TAG SELECTOR' Mode was supported by v10.0.2 for FF..., OK, good to know... (I don't use this Version...)

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Mon Apr 05, 2021 2:30 pm
by nclm
I’m using the free browser add-on version.
Note that if for any reason, something works better on another browser or operating system, I can switch to that just for running the macro.

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Tue Apr 06, 2021 4:56 am
by chivracq
nclm wrote:
Mon Apr 05, 2021 2:30 pm
I’m using the free browser add-on version.
Note that if for any reason, something works better on another browser or operating system, I can switch to that just for running the macro.

Ah..., OK, then update your 'Config info' Section in your OP to include that Info pfff...! :roll: :idea: :twisted:

And you've (already) "lost one day" before getting a "Chance" to get an Answer/Solution... Pity because your "original OP" was "petty good"... :(
(With (+1) for the perfect Follow-up, apart from the last bit of Info in your FCI in your OP...)

Re: Making a macro that likes all the videos in a YouTube playlist

Posted: Tue Apr 06, 2021 7:44 am
by nclm
Here you go, I added it.