Skip to content

Instantly share code, notes, and snippets.

@antoc0d3
Last active November 30, 2022 00:06
Show Gist options
  • Save antoc0d3/782b9fd913cf19b4529cdc5b64013db7 to your computer and use it in GitHub Desktop.
Save antoc0d3/782b9fd913cf19b4529cdc5b64013db7 to your computer and use it in GitHub Desktop.
javascript - spotify - get and mutate tranks favorites to other account via console browser
function addFavorite(trackId, token){
const body = {"variables": {
"uris":[trackId]
},
"operationName":"addToLibrary",
"extensions":{
"persistedQuery":
{
"version":1,
"sha256Hash":"656c491c3f65d9d08d259be6632f4ef1931540ebcf766488ed17f76bb9156d15"}
}
};
query(`https://api-partner.spotify.com/pathfinder/v1/query`, token, "POST", body)
.then(res => {
counterTrack += 1;
if(counterTrack <= trakslist.length-1){
console.log("added");
getIdSong(user, cleanerTextSearch(trakslist[counterTrack]))
}else console.log("finish")
}).catch(err => {
console.log(trackId)
counterTrack += 1;
getIdSong(user, cleanerTextSearch(trakslist[counterTrack]))
});
}
async function query(url = '', token = "", method = "GET", body = {}) {
let data = {};
Object.assign(data, {"method": method});
Object.assign(data, {"headers": {
"Content-Type": "application/json;charset=UTF-8",
"authorization": "Bearer "+ token,
"accept": "application/json",
"spotify-app-version": "1.2.0.558.g0810262a",
"app-platform": "WebPlayer",
"accept-language": "es-419",
"client-token": "AABb/q15sjQhX0NyRkJdPRpyYeu49JIPOnZurDVMqv3IJffmfZZJbmqVdURgOvxhCeSzG+lGAc3JbYgNUMwL5CEc9JDxIvgdeGWE/Ni+23GxU0bNFTIalhXZ0aAYL1QFz1jNfAIvFtAaAQ3jPHdDBlTBO0WEIKcjLSryK9e+hMm7Q3C/xUpDZhiGLaaZF4T1+ggi5RTijXkuVypOfcJcbui5486+s4fNsC8UB1GCzra51Ianb4wGgg6miCg8SmXPYvYozZPYMM7+cMxjpLNp813txIIE1uT+rt2z11MZSg+JzBGU"
}});
if( method == "POST"){
Object.assign(data, {"body": JSON.stringify(body)});
Object.assign(data, {"headers": {
"Content-Type": "application/json;charset=UTF-8",
"authorization": "Bearer "+ token
}});
}
const response = await fetch(url, data);
return response.json();
}
function getIdSong(user, keyword){
console.log(keyword);
const operation = 'operationName=searchTracks&variables=';
const variables = encodeURIComponent(`{"searchTerm":"ZZZZZ","offset":0,"limit":100,"numberOfTopResults":20,"includeAudiobooks":false}`).replace("ZZZZZ", keyword).replaceAll("/","%2F").replaceAll("\\","%5C").replaceAll("(", "%28").replaceAll(")", "%29");
const extensions = encodeURIComponent(`{"persistedQuery":{"version":1,"sha256Hash":"1d021289df50166c61630e02f002ec91182b518e56bcd681ac6b0640390c0245"}}`);
query("https://api-partner.spotify.com/pathfinder/v1/query?"+operation + (variables) + "&extensions="+ (extensions), user.token)
.then(res => {
let response = res.data;
if(response){
let items = response.searchV2.tracksV2.items;
const trackId = items[0].item.data.uri;
addFavorite(trackId,user.token);
}
});
}
function cleanerTextSearch(trackName){
return trackName.replaceAll("&", " ").replaceAll('"'," ").replaceAll(" ", "+").replaceAll(String("\\"), "\\\\");
}
// MAIN
let arrString = `["Dirty Rotten Bizkit - Limp Bizkit","Out Of Style - Limp Bizkit","Dad Vibes - Limp Bizkit","Alquien Que Bese Como Tu - Pedro Suárez-Vértiz","All This Love - Alesso, Noonie Bao","Last Dance (feat. Franz Novotny) - Steve Angello, AN21, Franz Novotny","Together - Duke Dumont, How To Dress Well","Together - Martin Garrix, Matisse & Sadko","Feel Good Inc. - Gorillaz","Hero - Nicky Romero Remix - Afrojack, David Guetta, Nicky Romero","Hold Me Down - Marc Benjamin, Timmo Hendriks, VY•DA, Alessia Labate","2 Live - Boys Noize","Overthrow - Boys Noize","Revolt - Boys Noize","Distort Me - Boys Noize","Trátame Suavemente - Remasterizado 2007 - Soda Stereo","Sugar - Maroon 5","Finale (feat. Nicholas Petricca) - Madeon, Nicholas Petricca","Be Fine - Madeon","Love You Back - Madeon","Gold Cobra - Limp Bizkit","Sólo Tú - Jaci Velasquez","Llegar A Ti - Jaci Velasquez","Louder Than Love - Tokio Hotel","Promises - Skrillex & Nero Remix - NERO","An deiner Seite (ich bin da) - Tokio Hotel","Forever Now - Tokio Hotel","Für immer jetzt - Tokio Hotel","Noise - Tokio Hotel","Stich ins Glück - Tokio Hotel","Screamin' - Tokio Hotel","Forever Now - Tokio Hotel","An deiner Seite (ich bin da) - Tokio Hotel","Vergessene Kinder - Live - Tokio Hotel","Easy - Tokio Hotel","On & On - Cartoon, Daniel Levi","Sal - Libido","Freedom - Edit - Afrojack, D-wayne, Jack McManus","Serious (feat. Matt Corby) - Kygo, Matt Corby","Could You Love Me - Kygo, Dreamlab","Stay (feat. Maty Noyes) - Kygo, Maty Noyes","Quisiera Poder Olvidarme De Ti - Luis Fonsi","Howl At The Moon - Radio Edit - Stadiumx, Taylr Renee","Rhinestone Eyes - Gorillaz","Get A Life - Limp Bizkit","Mobile - Avril Lavigne","Addicted To You - Avicii","Born To Die - Lana Del Rey","Lonely Together (feat. Rita Ora) - Avicii, Rita Ora","Sunflower - Spider-Man: Into the Spider-Verse - Post Malone, Swae Lee","Bite Me - Avril Lavigne","Dmente - Dmente Comun","Colgado - Cuchillazo","Monsoon - Tokio Hotel","The Nights - Avicii","SOS - Avicii, Aloe Blacc","Heaven - Avicii","Bad Habits (feat. Bring Me The Horizon) - Ed Sheeran, Bring Me The Horizon","Starving - Hailee Steinfeld, Grey, Zedd","Este Corazón - RBD, Anahí, Dulce María, Maite Perroni, Christian Chávez, Christopher von Uckermann, Alfonso Herrera","Aún Hay Algo - RBD, Anahí, Dulce María, Maite Perroni, Christian Chávez, Christopher von Uckermann, Alfonso Herrera","White Lies - Vicetone, Chloe Angelides","Unwanted - Avril Lavigne","you should see me in a crown - Billie Eilish","Don't Tell Me - Avril Lavigne","Breathe - Dimitri Vangelis & Wyman Remix - Seeb, Neev, Dimitri Vangelis & Wyman","The Moment (Novell) - Nicky Romero","Please Forgive Me - Bryan Adams","Abayarde - Tego Calderón","Ghost - Tom Swoon, Stadiumx, Rico & Miella","Blinding Lights - The Weeknd","Beautiful Now - Zedd, Jon Bellion","Heaven - Bryan Adams","Wish You Were Here - Avril Lavigne","Hace Mucho Tiempo - Arcangel","I'm with You - Avril Lavigne","Losing Grip - Avril Lavigne","Uprising - Muse","Together - Avril Lavigne","Wish You Were Here - Acoustic Version - Avril Lavigne","Keep Holding On - Avril Lavigne",null,"When You're Gone - Avril Lavigne","Ahora (feat. Angel Doze) - Zion & Lennox","Los Mate - Tego Calderón","Cuando Baila Reggaeton - Tego Calderón, Yandel","Nobody's Home - Avril Lavigne","Si No Le Contesto - Plan B","Yo Voy a Llegar - Zion","Get You The Moon (feat. Snøw) - Kina, Snøw","Burning in the Skies - Linkin Park","Lucky Man - The Verve","Welcome to My Life - Simple Plan","I Don't Want to Miss a Thing - From \\"Armageddon\\" Soundtrack - Aerosmith","Younger - Kygo Remix - Seinabo Sey, Kygo","Miami 82 - Kygo Remix - Syn Cole, Kygo","Starboy - Kygo Remix - The Weeknd, Daft Punk, Kygo","Carry Me (feat. Julia Michaels) - Kygo, Julia Michaels","Here for You (feat. Ella Henderson) - Kygo, Ella Henderson","Raging (feat. Kodaline) - Kygo, Kodaline","First Time - Kygo, Ellie Goulding","Take on Me - Kygo Remix - a-ha","The Only Exception - Paramore","BURN IT DOWN - Linkin Park","Grace - Steve Angello","Leave The World Behind - Radio Edit - Axwell, Sebastian Ingrosso, Steve Angello, Laidback Luke, Deborah Cox","ID8 - Dimitri Vangelis & Wyman, Sem Vox","Heaven Takes You Home (feat. Connie Constance) - Swedish House Mafia, Connie Constance","As It Was - Harry Styles","Rock DJ - Robbie Williams","Torn - Natalie Imbruglia","It Must Have Been Love - From the Film \\"Pretty Woman\\" - Roxette","Goodbyes (feat. Young Thug) - Post Malone, Young Thug","Payback - Dimitri Vangelis & Wyman, Steve Angello","Dreams (Will Come Alive) - 2 Brothers On The 4th Floor","What Is Love - 7\\" Mix - Haddaway","Nirvana - Madeon","Shelter - Porter Robinson, Madeon","Tengo un Amor - Pablo Herrera","Frankenstein (feat. A$AP Rocky) - Swedish House Mafia, A$AP Rocky","Glitter & Gloss - Skott","Breathe - Seeb, Neev","Mafia - Swedish House Mafia","Moth To A Flame (with The Weeknd) - Swedish House Mafia, The Weeknd","Circles - Post Malone","What's Wrong - PVRIS","Lifetime (with Ty Dolla $ign & 070 Shake) - Swedish House Mafia, Ty Dolla $ign, 070 Shake","Throne - Bring Me The Horizon","It Gets Better - Swedish House Mafia","See You Again (feat. Charlie Puth) - Wiz Khalifa, Charlie Puth","Born To Be Yours - Kygo, Imagine Dragons","The Ocean (feat. Shy Martin) - Mike Perry, shy martin","Roses - The Chainsmokers, ROZES","Superhero - Falling In Reverse","Saviour - Mallory Knox","Sleepwalking - The Chain Gang Of 1974","DiE4u - Bring Me The Horizon","Can You Feel My Heart - Bring Me The Horizon","Cuando Seas Grande - Miguel Mateos - Zas","Major Tom - Coming Home - Peter Schilling","Maria - Blondie","Lobo-hombre en París - La Unión","En algún lugar - Duncan Dhu","La Universidad (cosa de Locos) - Rio","Kingdom of Cards - Bad Omens","Itch For The Cure (When Will We Be Free?) - Bring Me The Horizon","Never Know - Unplugged - Bad Omens","wonderful life (feat. Dani Filth) - Bring Me The Horizon, Dani Filth","Kingslayer (feat. BABYMETAL) - Bring Me The Horizon, BABYMETAL","Ironic - Alanis Morissette","Teardrops - Bring Me The Horizon","Dear Diary, - Bring Me The Horizon","Cool - Alesso, Roy English","Sweet Escape - Alesso, Sirena","Human - KARAAL","Gatteka - Ghostemane","Jumpsuit - Twenty One Pilots","Gold Skies - Sander van Doorn, Martin Garrix, DVBBS, Aleesia","To Whom It May Concern - Ghostemane, Parv0","Axis - Ghostemane","D(R)Own - Ghostemane","1000 Rounds - Pouya, Ghostemane","Cyanide - Pouya, Ghostemane","Dawn - Axwell /\\\\ Ingrosso","Something New - Axwell /\\\\ Ingrosso, Axwell, Sebastian Ingrosso","Sun Is Shining - Axwell /\\\\ Ingrosso, Axwell, Sebastian Ingrosso","Máquina - Cuchillazo","Oasis (feat. Foxes) - Kygo, Foxes","Happy Birthday (feat. John Legend) - Kygo, John Legend","Intro - Kygo","Cut Your Teeth - Kygo Remix - Kyla La Grange, Kygo","Sexual Healing - Kygo Remix - Marvin Gaye, Kygo","Just Dance - Lady Gaga, Colby O'Donis","Clint Eastwood - Gorillaz","The Second Coming (Burn It Down) [Seth Rollins] - WWE, CFO$","Bitter Sweet Symphony - The Verve","I duckinf hatw you - Ghostemane, Parv0","Everybody Wants To Rule The World - Tears For Fears","Two Princes - Spin Doctors","Down Under - Men At Work","Polaris - Ghostemane","Mercury: Retrograde - Ghostemane","Forever - Martin Garrix, Matisse & Sadko","Cut My Lip - Twenty One Pilots","Morph - Twenty One Pilots","Levitate - Twenty One Pilots","Lloran las Rosas - Cristian Castro","Yo Quería - Cristian Castro","Azul - Cristian Castro","Con Ella - Cristian","Por Amarte Así - Cristian Castro","Something About You - ODESZA Remix - Hayden James, ODESZA","Cosas Del Amor - Enrique Iglesias","I Want You - ODESZA","Across The Room (feat. Leon Bridges) - ODESZA, Leon Bridges","Light (feat. Little Dragon) - ODESZA, Little Dragon","Koto - ODESZA","Falls - Kaskade Remix - ODESZA, Sasha Alex Sloan, Kaskade","Slow Grenade - Ellie Goulding, Lauv","Te Siento de Sólo Pensar - Pedro Suárez-Vértiz","Summit (feat. Ellie Goulding) - Skrillex, Ellie Goulding","Sin aliento - Danza Invisible","Un Vino, Una Cerveza - Pedro Suárez-Vértiz","Am I Wrong - Nico & Vinz","We Like to Party - Radio Edit - Showtek","Use Somebody - Kings of Leon","Inmortales - Cementerio Club","Fireflies - Owl City","Rain - Dragon","Big Girls Don't Cry (Personal) - Fergie","Rayando El Sol - Maná","Oye Mi Amor - Maná","We'll Be Coming Back (feat. Example) - Calvin Harris, Example","Tarzan Boy - Baltimora","Néctar (En Vivo) - Libido","Néctar - Libido","Feel - Robbie Williams","Bye Bye - Vilma Palma e Vampiros","Cuéntame - Pedro Suárez-Vértiz","All of Me - Tiësto's Birthday Treatment Remix - Radio Edit - John Legend, Jason Agel, Tiësto","Levels - Instrumental Radio Edit - Avicii","Levels - Radio Edit - Avicii","Under Control (feat. Hurts) - Calvin Harris, Alesso, Hurts","Lighters - Bad Meets Evil, Bruno Mars","Yee - Radio Edit - Deorro","Revolution - The Score","Flaca - Andrés Calamaro","Like a Stone - Audioslave","Lovebug - Jonas Brothers","Turn Down for What (feat. Juicy J, 2 Chainz & French Montana) - Official Remix - DJ Snake, Lil Jon, Juicy J, 2 Chainz, French Montana","You Make Me - Avicii","I Want to Know What Love Is - 2008 Remaster - Foreigner","Your Love - The Outfield","Good Feeling - Flo Rida","This Is What It Feels Like - Armin van Buuren, Trevor Guthrie","Decidiste Dejarme - Camila","Come As You Are - Nirvana","Sentimiento Original - Gondwana","Da Ya Think I'm Sexy? - Rod Stewart","Prófugos - Soda Stereo","Un día sin tí (Spending My Time) - Roxette","Pumped Up Kicks - Foster The People","Mi Gran Amor - Rapper School","Psicosis - Rapper School","DJ Got Us Fallin' In Love (feat. Pitbull) - Usher, Pitbull","De Música Ligera - Soda Stereo","Thinking Of You - Katy Perry","Careless Whisper - George Michael","Y Es Que Sucede Así - Arena Hash","Devuélveme a mi chica - Hombres G","Es por Amor - Pelo Madueño","Persiana Americana - Soda Stereo","Otherside - Red Hot Chili Peppers","Timber (feat. Ke$ha) - Pitbull, Kesha","Tren Al Sur - Los Prisioneros","International Love (feat. Chris Brown) - Pitbull, Chris Brown","Crush - David Archuleta","crushcrushcrush - Paramore","Angels - Radio Edit - Vicetone, Kat Nestel","Angels - Robbie Williams","Ten Feet Tall - Afrojack, Wrabel","Livin' On A Prayer - Bon Jovi","Said I Loved You...But I Lied - Michael Bolton","You Give Love A Bad Name - Bon Jovi","How Does It Feel - Dutch Edit - Michael Mind Project","Fuiste un Trozo de Hielo en la Escarcha - Chayanne","Estrechez De Corazón - Los Prisioneros","Me Elevé - Pedro Suárez-Vértiz","Zombie - The Cranberries","Wake Me up When September Ends - Green Day","Otra Como Tu - Eros Ramazzotti","Warriors - Nicky Romero, Volt & State","With You - Linkin Park","Dame tu aire - Alex Ubago","Despertar - Difonia","1x1 (feat. Nova Twins) - Bring Me The Horizon, Nova Twins","Ludens - Bring Me The Horizon","ouch - Bring Me The Horizon","i don't know what to say - Bring Me The Horizon","in the dark - Bring Me The Horizon","Goodness Gracious - Ellie Goulding","Let's Go (feat. Ne-Yo) - Calvin Harris, Ne-Yo","Thinking About You (feat. Ayah Marar) - Calvin Harris, Ayah Marar","Faith - Calvin Harris","Happy Song - Bring Me The Horizon","Follow You - Bring Me The Horizon","¿Sabes? - Alex Ubago","¿Qué pides tú? - Alex Ubago","Lose Somebody - Kygo, OneRepublic","Sunrise (feat. Jason Walker) - Kygo, Jason Walker","Beating Heart - Ellie Goulding","heavy metal (feat. Rahzel) - Bring Me The Horizon, Rahzel","Helicopter - Video Edit - Martin Garrix, Firebeatz","Truffle Butter - Nicki Minaj, Drake, Lil Wayne","Truffle Butter - The New Coldmans","Pusher - Sleepy Tom, Anna Lunoe","I Met You - Anna Lunoe, Flume","Kingston Town - UB40","Gangsta's Paradise - Coolio, L.V.","Summertime Sadness - Lana Del Rey","Summertime Sadness (Lana Del Rey Vs. Cedric Gervais) - Cedric Gervais Remix - Lana Del Rey, Cedric Gervais","Freak On a Leash - Korn","Falling Away from Me - Korn","Stranger In A Strange Land - Thirty Seconds To Mars","With You, Friends (Long Drive) - Skrillex","Mind (feat. Kai) - Jack Ü, Skrillex, Diplo, kai","Black and Yellow (feat. Juicy J, Snoop Dogg & T-Pain) - G-Mix [G-Mix] - Wiz Khalifa, Juicy J, Snoop Dogg, T-Pain","Alarm - Boys Noize","Waiting - RL Grime, What So Not, Skrillex","Set It All Free - Scarlett Johansson","Prisoner - Raphael Lake, Aaron Levy, Daniel Ryan Murphy","Earned It (Fifty Shades Of Grey) - The Weeknd","Creep - Radiohead","SICKO MODE - Travis Scott","High On Life (feat. Bonn) - Martin Garrix, Bonn","medicine - Bring Me The Horizon","MANTRA - Bring Me The Horizon","My Love (feat. Jess Glynne) - Route 94, Jess Glynne","Virus (How About Now) - Martin Garrix, MOTi","Sandcastles - Radio Edit - Volt & State","Forbidden Voices - Martin Garrix","The Devil in I - Slipknot","Would You Ever - Skrillex, Poo Bear","Harmony - Nicky Romero, Stadiumx","Let Me Feel - Radio Edit - Nicky Romero, Vicetone, When We Are Wild","Heavydirtysoul - Twenty One Pilots","Hometown - Twenty One Pilots","Polarize - Twenty One Pilots","i apologise if you feel something - Bring Me The Horizon","Bandito - Twenty One Pilots","Car Radio - Twenty One Pilots","Can't Stop - Red Hot Chili Peppers","Dani California - Red Hot Chili Peppers","Scar Tissue - Red Hot Chili Peppers","By the Way - Red Hot Chili Peppers","Strip My Mind - Red Hot Chili Peppers","Turn It Around - Radio Edit - DubVision","Losing It - FISHER","United We Dance - Radio Edit - Vicetone","God Put a Smile upon Your Face - Coldplay","In My Place - Coldplay","On My Way - Alan Walker, Sabrina Carpenter, Farruko","Children of the Wild (feat. Mako) - Steve Angello, Mako","Are You - Steve Angello, WDL","Try It Out - Skrillex","Remember (feat. The Presets) - Steve Angello, The Presets","Rejoice - Steve Angello, T.D. Jakes","Choker / Stressed Out / Migraine / Morph / Holding On To You - Livestream Version - Twenty One Pilots","I Don't Fuck With You (feat. E-40) - Big Sean, E-40","rockstar (feat. 21 Savage) - Post Malone, 21 Savage","Omen - Disclosure, Sam Smith","Blasphemy - Bring Me The Horizon","We Are Broken - Paramore","Going Dumb (with Stray Kids) - Alesso, CORSAK, Stray Kids","sugar honey ice & tea - Bring Me The Horizon","Hot N*gga - Bobby Shmurda","21 Guns - Green Day","Holiday / Boulevard of Broken Dreams - Green Day","Misery Business - Paramore","Imagíname Sin Ti - Luis Fonsi","Antologia - Shakira","Solo A Tu Lado Quiero Vivir - Jyve V","Tennis Court - Lorde","Mi Vida Sin Tu Amor - Cristian Castro","A gritos de esperanza - Alex Ubago","Aunque no te pueda ver - Alex Ubago","Rolling in the Deep - Adele","The One - Backstreet Boys","Larger Than Life - Backstreet Boys","I Want It That Way - Backstreet Boys","Que Me Quedes Tú - Shakira","Como Se Cura Una Herida - Pop - Jaci Velasquez","Up in Flames - Coldplay","Violet Hill - Coldplay","What If - Coldplay","Talk Show - Pedro Suárez-Vértiz","Speed of Sound - Coldplay","A Message - Coldplay","Paradise - Coldplay","Sálvame - RBD, Anahí, Dulce María, Maite Perroni, Christian Chávez, Christopher von Uckermann, Alfonso Herrera","Entre tú y mil mares - Laura Pausini","Something Just Like This - The Chainsmokers, Coldplay","Escucha atento - Laura Pausini","Mania - Madeon","Dream Dream Dream - Madeon","Somebody Else - The 1975","All My Friends - Madeon"]`;
let trakslist = JSON.parse(arrString)
trakslist = trakslist.reverse();
let counterTrack = 0;
const user = {
"ssh": "1d021289df50166c61630e02f002ec91182b518e56bcd681ac6b0640390c0245",
"token": "BQA0hleRSesRY_aOgsUqfg0rGiezd46iXVAwCUkXZ-_OAOKWbFylmxrGxvsUyZFgAg_akN-CQAauFOt_VHxThJ7PiLGmIU7B-S5NJZvKNmEPhrYk77lnRCQXqLs1q4ZebobihgN9TbdkAx3MdxTzwuKwWmik1M5g1poaFKSy9C759eJow0MTZENrrIAUjSuX_WQEuJ36qVWiwDw9cCojf3C3OCMzVMcd5u_k34JL1wCI-NBxOXmwxED-w-iGAgGR_xEpH9CeDFnqgp9r_UtXvIl8MZRHrHUyaupE1Qzh_QRYdlUbeM01sJ6ne_-oWYWOIuDhqXMrOoIAD4IVBsDraZKeLDwcXPsp"
}
getIdSong(user, cleanerTextSearch(trakslist[counterTrack]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment