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

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
nclm
Posts: 4
Joined: Mon Apr 05, 2021 9:07 am

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

Post by nclm » 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.

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!!
Last edited by nclm on Tue Apr 06, 2021 7:44 am, edited 2 times in total.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Mon Apr 05, 2021 2:06 pm

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... :|
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nclm
Posts: 4
Joined: Mon Apr 05, 2021 9:07 am

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

Post by nclm » 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 :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Mon Apr 05, 2021 2:26 pm

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...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nclm
Posts: 4
Joined: Mon Apr 05, 2021 9:07 am

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

Post by nclm » 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.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Tue Apr 06, 2021 4:56 am

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...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
nclm
Posts: 4
Joined: Mon Apr 05, 2021 9:07 am

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

Post by nclm » Tue Apr 06, 2021 7:44 am

Here you go, I added it.
Post Reply