Quick reddit account migration script
Hey everyone, I haven't touched python in a while so I wanted to program a little script to migrate to a new account and wipe the old one (I'm a little paranoid about anonymity). Figured I would post it in hopes of some tips or critique, and maybe someone will find it useful. I also apologize if this isn't the right sub for this, didn't know where to post
import praw
#Account Migration Script
#By:/u/letmelive123
#Date:6/24/2017
#Warning! Using this script will entirely wipe the parent Account.
#To use input accounts and body to replace comments with
#parentAcc is the account being wiped
#secAcc is the account you are moving to
#body is the text that will replace all comments on parentAcc
#This function will transfer new multireddits to the target account.
#Note:We convert 'multi' to str and partition it to extract the multireddit name
#This is because parentAcc.user.multireddits() returns a list of paths to multireddits
def transferMultis():
for multi in parentAcc.user.multireddits():
s = str(multi)
parentAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).update(visibility='public')
secAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).copy(display_name=None)
parentAcc.multireddit(name=s.partition("/m/")[2],redditor=parentAcc.user.me()).delete()
#This function will transfer new multireddits to the target account.
def transferSubs():
for sub in parentAcc.user.subreddits():
s = str(sub)
secAcc.subreddit(s).subscribe()
parentAcc.subreddit(s).unsubscribe()
#This function will clean the comments of parentAcc.
def wipeComments(body):
for comment in parentAcc.redditor(name=str(parentAcc.user.me())).comments.top(time_filter='all'):
comment.edit(body)
###WARNING###
#This Account will be wiped
###WARNING###
#Parent Account
parentAcc = praw.Reddit(client_id='',
client_secret='',
password='k',
user_agent='AccMigrate by /u/letmelive123',
username='')
#Secondary Account
secAcc = praw.Reddit(client_id='',
client_secret='',
password='',
user_agent='AccMigrate by /u/letmelive123',
username='')
#Body for replacing comments
body="Test"
print("Hello welcome to AccMigrate.")
print("Please note wiping comments does take some time.")
transferMultis()
transferSubs()
wipeComments(body) print("done")
/r/Python
https://redd.it/6j6rpp
Hey everyone, I haven't touched python in a while so I wanted to program a little script to migrate to a new account and wipe the old one (I'm a little paranoid about anonymity). Figured I would post it in hopes of some tips or critique, and maybe someone will find it useful. I also apologize if this isn't the right sub for this, didn't know where to post
import praw
#Account Migration Script
#By:/u/letmelive123
#Date:6/24/2017
#Warning! Using this script will entirely wipe the parent Account.
#To use input accounts and body to replace comments with
#parentAcc is the account being wiped
#secAcc is the account you are moving to
#body is the text that will replace all comments on parentAcc
#This function will transfer new multireddits to the target account.
#Note:We convert 'multi' to str and partition it to extract the multireddit name
#This is because parentAcc.user.multireddits() returns a list of paths to multireddits
def transferMultis():
for multi in parentAcc.user.multireddits():
s = str(multi)
parentAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).update(visibility='public')
secAcc.multireddit(name=s.partition("/m/")[2], redditor=parentAcc.user.me()).copy(display_name=None)
parentAcc.multireddit(name=s.partition("/m/")[2],redditor=parentAcc.user.me()).delete()
#This function will transfer new multireddits to the target account.
def transferSubs():
for sub in parentAcc.user.subreddits():
s = str(sub)
secAcc.subreddit(s).subscribe()
parentAcc.subreddit(s).unsubscribe()
#This function will clean the comments of parentAcc.
def wipeComments(body):
for comment in parentAcc.redditor(name=str(parentAcc.user.me())).comments.top(time_filter='all'):
comment.edit(body)
###WARNING###
#This Account will be wiped
###WARNING###
#Parent Account
parentAcc = praw.Reddit(client_id='',
client_secret='',
password='k',
user_agent='AccMigrate by /u/letmelive123',
username='')
#Secondary Account
secAcc = praw.Reddit(client_id='',
client_secret='',
password='',
user_agent='AccMigrate by /u/letmelive123',
username='')
#Body for replacing comments
body="Test"
print("Hello welcome to AccMigrate.")
print("Please note wiping comments does take some time.")
transferMultis()
transferSubs()
wipeComments(body) print("done")
/r/Python
https://redd.it/6j6rpp
reddit
Quick reddit account migration script • r/Python
Hey everyone, I haven't touched python in a while so I wanted to program a little script to migrate to a new account and wipe the old one (I'm a...
json post issue
Ok, so here's the problem. I have a Notes form. It posts the information properly but lets say I'd like to post another post right after I hit submit note. It won't post it and it will fill the url eg: " [http://app.com/ticket/1?body=](http://app.com/ticket/1?body=)blahblah&?method=add ". If I want to post again I have to refresh the page, What am I doing wrong?
Here's my JS.
$('#noteform').submit(function(e) {
e.preventDefault();
var csrf_token = "{{ csrf_token() }}";
var ticketid = "{{ ticket.id }}";
var twoSecMin = $.Deferred();
$.ajax({
url: '/repair/addNote',
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify( {
"method": 'add',
"body": $('#body').val(),
"ticketid": ticketid,
"private_note": $('#private_note').prop('checked')
}),
processData: true,
success: function( data, textStatus, jQxhr ){
$('#notes').load(' #notes');
$('#notecount').load(' #notecount');
$('input[type=text], textarea').val('');
$('input[type=checkbox]').prop("checked", false);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
alert('Error Posting Note!');
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
}
});
});
and this is my controller logic.
@ticket.route('/addNote', methods=["POST"])
def addNote():
json = request.get_json()
method = json['method']
if method == 'add':
body = json['body']
private = json['private_note']
tid = json['ticketid']
# Create note!
newnote = Notes(
created_by = 0,
is_private = private,
ticket_id = tid,
body = body,
)
db.session.add(newnote)
db.session.commit()
elif method == 'delete':
noteid = json['noteid']
# Delete note.
notetodelete = Notes.query.filter_by(id=noteid).first_or_404()
db.session.delete(notetodelete)
db.session.commit()
elif method == 'update':
return None
return jsonify(result='done')
/r/flask
https://redd.it/8is6qf
Ok, so here's the problem. I have a Notes form. It posts the information properly but lets say I'd like to post another post right after I hit submit note. It won't post it and it will fill the url eg: " [http://app.com/ticket/1?body=](http://app.com/ticket/1?body=)blahblah&?method=add ". If I want to post again I have to refresh the page, What am I doing wrong?
Here's my JS.
$('#noteform').submit(function(e) {
e.preventDefault();
var csrf_token = "{{ csrf_token() }}";
var ticketid = "{{ ticket.id }}";
var twoSecMin = $.Deferred();
$.ajax({
url: '/repair/addNote',
dataType: 'json',
type: 'post',
contentType: 'application/json',
data: JSON.stringify( {
"method": 'add',
"body": $('#body').val(),
"ticketid": ticketid,
"private_note": $('#private_note').prop('checked')
}),
processData: true,
success: function( data, textStatus, jQxhr ){
$('#notes').load(' #notes');
$('#notecount').load(' #notecount');
$('input[type=text], textarea').val('');
$('input[type=checkbox]').prop("checked", false);
},
error: function( jqXhr, textStatus, errorThrown ){
console.log( errorThrown );
alert('Error Posting Note!');
}
});
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!/^(GET|HEAD|OPTIONS|TRACE)$/i.test(settings.type) && !this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", csrf_token);
}
}
});
});
and this is my controller logic.
@ticket.route('/addNote', methods=["POST"])
def addNote():
json = request.get_json()
method = json['method']
if method == 'add':
body = json['body']
private = json['private_note']
tid = json['ticketid']
# Create note!
newnote = Notes(
created_by = 0,
is_private = private,
ticket_id = tid,
body = body,
)
db.session.add(newnote)
db.session.commit()
elif method == 'delete':
noteid = json['noteid']
# Delete note.
notetodelete = Notes.query.filter_by(id=noteid).first_or_404()
db.session.delete(notetodelete)
db.session.commit()
elif method == 'update':
return None
return jsonify(result='done')
/r/flask
https://redd.it/8is6qf