get paid to paste

#!/usr/bin/python

import plurkapi
import sys, pickle

plurk_user = 'SecondSecrets'
plurk_pass = 'PASSWORD'

idlog = 'idlog.dat'

ids = []

# We need to keep track of post IDs to avoid posting the same thing twice.
# I don't think there's a way to know who posted an ID once it has been deleted and I can't tell who posted what. :)

try:
    ids = pickle.load(open(idlog,'rb'))
except:
    print "ID log data file not present and will be created."

# Trim the list...
#ids = ids[-500:]

plurk_api = plurkapi.PlurkAPI()

try:
    returncode = plurk_api.login(plurk_user, plurk_pass)
except:
    print "Plurk login failed, plurk seems dead!"
    sys.exit(1)

if returncode == False:
    print "Plurk login failed, wrong password or username!"
    sys.exit(1)

# Get and accept all friend requests

alerts = plurk_api.getAlerts()
if len(alerts):
    plurk_api.befriend(alerts)

# Grab the timeline as presented
    
try:
    plurks = plurk_api.getPlurks()
except:
    print "Plurk is borked, can't get timeline."
    sys.exit(1)

# Chew through it and replurk singular private plurks keeping their IDs.

for plurk in reversed(plurks):
    if plurk['limited_to'] != None:
	plurkto = plurk['limited_to'].rstrip('|').lstrip('|').split('||')
	if len(plurkto) == 2 and plurk_api.uid in plurkto:
	    plurkid = str(plurk['plurk_id'])
	    if plurkid not in ids:
		ids.append(plurkid)
		text = plurk['content_raw']
		qualifier = plurk['qualifier']
		
		try:
		    #print qualifier, text
		    plurk_api.addPlurk(qualifier=qualifier, content=text)
		except:
		    print "Could not plurk, plurk might be borked..."

		# Only replurk one message per cycle.
		break

# Dump the ID log.
	    
pickle.dump(ids,open(idlog,'wb')) 

Pasted: Sep 29, 2009, 3:55:56 pm
Views: 127