copy_reddit

For people who use Reddit, the anonymous nature of the web site lends itself to people utilizing multiple accounts. The following script can be used to copy all subreddit subscriptions and friends from a source to a destination account.

Note that this script requires a specific revision of the praw API in order to copy over friends lists due to an outstanding issue. If you do not need to copy friends, simply comment out the code that does so below and use the current release of praw.

#!/usr/bin/env python3

#
# Sumit Khanna - 2013 - PenguinDreams.org
#
#  Requires praw 
#    * friends list requires specific revision: git reset --hard c8a0f10 
#    * later revisions have known issue: https://github.com/praw-dev/praw/issues/175
#

import praw
import getpass
import sys

def get_login(title):
  service = praw.Reddit(user_agent='copy_reddit.py v0.1 - Created By Sumit Khanna - penguindreams.org')
  while True:
    try:
      print("\n{0}".format(title))
      username = input('Username: ')
      password = getpass.getpass('Password: ')
      service.login(username,password)
      return service
    except praw.errors.InvalidUserPass:
      print('\nInvalid Reddit Username or Password',file=sys.stderr)
      continue;

print('\nCopy Reddit is a script for copying subreddit subscriptions and friends from')
print('Reddit account to another. -- Sumit Khanna -- PenguinDreams.org\n')

copy_from = get_login('Source Reddit Account')
copy_to   = get_login('Destination Reddit Account')


print('\nCopying Subreddits\n')
for x in copy_from.get_my_reddits(limit=None):
  print(x)
  copy_to.subscribe(str(x))


print('\nCopying Friends\n')
for i in copy_from.user.get_friends():
  print(i.name)
  praw.objects.Redditor(copy_to,i.name).friend()