Created
November 30, 2021 22:49
-
-
Save ninadpchaudhari/0140410cc7647f58055d686e692d921a to your computer and use it in GitHub Desktop.
Move liked videos from one Google Account to another, using YT Music
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get array of links which are videos/music from current YT music playlist. | |
const allLinks = Array.from($$(".yt-formatted-string")).map(x => String(x).includes("/watch?")? x.href : false).filter(Boolean) | |
//Reverse the same, so that the oldest item is on the top. This helps as we transfer this list to SeleniumIDE to automate and like the same videos in same order | |
allLinks.reverse() | |
//slice the last 8 chars from the strings, as they contain the playlis info. | |
// If you keep this, the Like / dislike button will not be visible. | |
allLinks.map(x => x.slice(0,-8)) | |
// Tip Copy the Object from Console! using right click | |
Then use seleniumIDE to loop through this list and like each of these videos. | |
note we, remove like, then relike the video, in case it is already liked. This ensures we maintain history of likes. | |
Selenium IDE .side file attached. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": "d3bd1779-ae2d-4280-9097-59d19a749eb7", | |
"version": "2.0", | |
"name": "YT", | |
"url": "https://music.youtube.com", | |
"tests": [{ | |
"id": "7068f654-77ec-4f6e-bfd6-03c4d5a20a1c", | |
"name": "1", | |
"commands": [{ | |
"id": "995220d1-7b08-461f-8fa8-e1b8c3e81cb1", | |
"comment": "", | |
"command": "open", | |
"target": "https://music.youtube.com", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "1c9c1561-6d5c-4d62-b71a-dbe579555533", | |
"comment": "", | |
"command": "executeScript", | |
"target": "return [ ]", | |
"targets": [], | |
"value": "allLinks" | |
}, { | |
"id": "c6f9eda9-a3d5-4b1c-89d2-3e7f2e828484", | |
"comment": "", | |
"command": "echo", | |
"target": "${allLinks.length}", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "d072d15c-0acb-43e8-83cb-d8dd69ccadab", | |
"comment": "", | |
"command": "store", | |
"target": "0", | |
"targets": [], | |
"value": "countDone" | |
}, { | |
"id": "d2d0eec5-a290-4ea2-9fbf-5ac1fe19a185", | |
"comment": "", | |
"command": "forEach", | |
"target": "allLinks", | |
"targets": [], | |
"value": "alink" | |
}, { | |
"id": "b8bd9015-6e2a-4d93-91a8-4071aa9fbe5f", | |
"comment": "", | |
"command": "executeScript", | |
"target": "return parseInt(${countDone}) + 1", | |
"targets": [], | |
"value": "countDone" | |
}, { | |
"id": "f63dc939-693d-4897-9d9a-4d2a934807a4", | |
"comment": "", | |
"command": "echo", | |
"target": "${countDone}", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "f1814734-ce6c-4577-ab16-246132f21fbb", | |
"comment": "", | |
"command": "echo", | |
"target": "${alink}", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "75762776-ab96-4569-91c1-c049354c7e48", | |
"comment": "", | |
"command": "open", | |
"target": "${alink}", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "52c97cf3-5117-46f0-8851-e4b67e9e7c3c", | |
"comment": "", | |
"command": "waitForElementVisible", | |
"target": "css=.like > #icon", | |
"targets": [ | |
["css=.dislike > #icon", "css:finder"], | |
["xpath=(//tp-yt-iron-icon[@id='icon'])[119]", "xpath:attributes"], | |
["xpath=//ytmusic-like-button-renderer[@id='like-button-renderer']/tp-yt-paper-icon-button/tp-yt-iron-icon", "xpath:idRelative"], | |
["xpath=//ytmusic-like-button-renderer/tp-yt-paper-icon-button/tp-yt-iron-icon", "xpath:position"] | |
], | |
"value": "30000" | |
}, { | |
"id": "1f1f71dd-8248-42c7-8ecd-9047b3c21ce3", | |
"comment": "", | |
"command": "storeAttribute", | |
"target": "css=.like@aria-pressed", | |
"targets": [], | |
"value": "isLiked" | |
}, { | |
"id": "b4365288-2cc9-433a-9bb2-ed76ed6f8482", | |
"comment": "", | |
"command": "//echo", | |
"target": "${isLiked}", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "96e37f83-e498-4696-ae41-9fb4b95af7c4", | |
"comment": "", | |
"command": "if", | |
"target": "${isLiked} === \"false\"", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "4c12f20e-ec93-4967-a451-601510b391f6", | |
"comment": "", | |
"command": "click", | |
"target": "css=.like > #icon", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "f838bd8f-b344-42d8-929a-0a4c15942e97", | |
"comment": "", | |
"command": "else", | |
"target": "", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "69c300a2-b76e-4640-a7e9-8caf7acc4cdd", | |
"comment": "", | |
"command": "click", | |
"target": "css=.like > #icon", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "7bae37f0-7b5f-422a-8af8-38fc1a49c840", | |
"comment": "", | |
"command": "click", | |
"target": "css=.like > #icon", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "d2e397fc-9895-4fe3-9a46-deefab455d27", | |
"comment": "", | |
"command": "end", | |
"target": "", | |
"targets": [], | |
"value": "" | |
}, { | |
"id": "a63ee849-5824-4eac-b6de-9bd28bab281a", | |
"comment": "", | |
"command": "end", | |
"target": "", | |
"targets": [], | |
"value": "" | |
}] | |
}], | |
"suites": [{ | |
"id": "7ca6e23c-c5e7-440c-9492-7fb611c99a29", | |
"name": "Default Suite", | |
"persistSession": false, | |
"parallel": false, | |
"timeout": 300, | |
"tests": ["7068f654-77ec-4f6e-bfd6-03c4d5a20a1c"] | |
}], | |
"urls": ["https://music.youtube.com/"], | |
"plugins": [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment