Skip to content

Instantly share code, notes, and snippets.

@kevcooper
Last active December 8, 2015 01:27
Show Gist options
  • Save kevcooper/92061d1d5dff99e14cb6 to your computer and use it in GitHub Desktop.
Save kevcooper/92061d1d5dff99e14cb6 to your computer and use it in GitHub Desktop.
A python script to transform a list of subreddits in the clipboard into a paste-able format to be used in an Alien Blue group. Copy the list from your multireddit, run the script in Pythonista, then create a new group in Alien Blue and paste. Thats it!
import console
import clipboard
import webbrowser
def main():
text = clipboard.get()
noNewlines = text.replace('\n',' ')
array = noNewlines.split(' ')
ABString = finalStringFromArray(array)
clipboard.set(ABString)
webbrowser.open('alienblue://')
def finalStringFromArray(array):
removeX = shouldRemoveX(array)
finalString = ''
i = 0
for i in range(0,len(array)):
if array[i] != None:
if array[i][:3] == 'add':
break
if array[i][:3] == '/r/':
if removeX:
finalString = finalString + array[i][3:-1]
else:
finalString = finalString + array[i][3:]
finalString = finalString + "+"
finalString = finalString[:-1]
return finalString
def shouldRemoveX(array):
numX = 0
numReddits = 0
for i in range(0,len(array)):
if array[i] != None:
if array[i][:3] == 'add':
break
if array[i][:3] == '/r/':
numReddits +=1
if array[i][-1:] == 'x':
numX += 1
return numReddits == numX
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment