Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jackellenberger/eddcf1111732df97f84734fbf929fcfd to your computer and use it in GitHub Desktop.
Save jackellenberger/eddcf1111732df97f84734fbf929fcfd to your computer and use it in GitHub Desktop.
Migrating YouTube subscriptions from one account to another

Migrating YouTube subscriptions from one account to another

It's a pain in the butt! there's no google-provided way to do it and the extensions that were written to do it are all terrible or non-functional. Luckily, youtube runs on "computers" and "computers" can be "hackarino'd" with just a bit of encouragement. Prereqs are a) ability to follow instructions b) maybe some familiarity with bash. I'm writing this from my mac, it'll be the sameish on linux and WSL.

This is for non-"brand" accounts, cause i'm not a brand. I'm a small business man, not a small business, man. I'm not a man either but whatever.

1. Download your subscriptions with Takeout

This at least is easy.

  1. open youtube.com > profile icon > your data in youtube, should take you to myaccount.
  2. note the number of subscriptions, that'll be useful later
  3. click "Download YouTube data" (takes you to google takeout - you could start at this step but why not teach a dog to fish)
  4. click "All YouTube data included", because we want to change that > Deselect all but subscriptions
  5. "Export Once" ".zip" file type, 2gb export. Create export.
  6. Download and unzip the file, somewhere in there you should have subscriptions.csv that contains ,,
  7. Set aside.

2. Capture a subscription request

  1. On your new/target youtube account open youtube and find some channel you're not subscribed to. In chrome. this works elsewhere but i'm doing it in chrome.
  2. right click > inspect, or open the developer tools however you normally do. Open the Network tab and clear it out (little crossed circle icon)
  3. Click the subscribe button
  4. look in the network tab for a request like subscribe?key=somegarbage. Right click > copy as curl. you can do this with any of the options, fetch is good for example, but we're gonna do other bash stuff so why not curl.
  5. Paste that request somewhere, anywhere, to save it. a text doc, or just pop it in your bash buffer if you're an fc god.
  6. pop on Nation Of Language's cover of Androgynous, it's really quite nice.

3. Hijack that subscription request

As far as I can tell, this request has all the credentialling we need and doesn't expire in any short time, so it's prime for replaying. YouTube engineers, don't change this.

  1. Take a look at that request. In it's --data-raw blob, you'll find something like "channelIDs":["UC3CBOpT2-NRvoc2ecFMDCsA"] That's great, but it's only one channel ID. Let's put a bunch in there.
  2. There are two ways you can go about this now, either serially adding channels one per request, or doing them all in bulk. The latter is potentially faster, but it does seem like the error responses you get are unhelpful so you get stuck in a "half synced" state, which is a pain.

3a. serial replays

  • notice the for loop, and your need to insert a valid path
  • tail is necessary to remove csv header
  • reproduce the quotes around channelId exactly - the copied curl uses single quotes, which won't allow for variable expansion.
for channelId in $(cat ~/path/to/subscriptions.csv | sort | tail -n+1 | cut -f 1 -d,); do
  #your saved curl command
  curl 'https://www.youtube.com/youtubei/v1/subscription/subscribe?key=my-secret-key&prettyPrint=false' \
  [...]
  --data-raw '{...
    ..."channelIds": ["'${channelId}'"]...
  }';
done

3b. single bulk replay

idk why even write this? just cause it's an option i guess. When an error is returned it's not scoped to a channel id, so it's useless. but i wrote that awk string and i'm gonna publish it

#your saved curl command
curl 'https://www.youtube.com/youtubei/v1/subscription/subscribe?key=my-secret-key&prettyPrint=false' \
[...]
--data-raw '{...
  ..."channelIds": ['$(cat ~/path/to/subscriptions.csv | sort | tail -n+1 | cut -f 1 -d,) | awk 'BEGIN { ORS="" } { print p"\042"$0"\042"; p="," } END { print "\n" })'']...
}'

but like don't do it this way.

4. Double check your subscription count

  1. The myaccount page for your new/target account will have the number of subscriptions you have set up. Hopefully, after all this, it'll be the same number as you see on your old account!
@kastnerp
Copy link

This saved me a lot of time, thanks!

@bongraster
Copy link

Thanks for that!

@magicants
Copy link

Hey! Do you know of a modified method for this that is compatible with windows? Really sorry to bother you ;;

@jackellenberger
Copy link
Author

This will work for the Windows Subsystem for Linux (WSL) for sure, but I'm not near a powershell and won't be for a couple of months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment