def main(configFile=None): ''' Deletes all subscriptions from the Instagram server. Typically called on a new dotcloud push just to make sure its all clear.''' print "----------->", configFile # Get the config information into a single object p = getConfigParameters(configFile) # Get the client and secret keys api = InstagramAPI(client_id=p.client, client_secret=p.secret) # Get all current subs subs = api.list_subscriptions() # For each active sub, delete it if subs['meta']['code'] == 200: for sub in subs['data']: if sub['type'] == 'subscription': deleted = api.delete_subscriptions(id=int(sub['id'])) # Final check - make sure they're definitely all gone subs = api.list_subscriptions() if len(subs['data']) == 0: success = True else: success = False else: success = False
def ageOffSubscriptions(p, collHandle, ageOff, protectedSubs): ''' Deletes subscriptions from the Instagram server based on the age and protection level in the subs collection. If protect=True, then it must be manually deleted''' out = [] # Get the client and secret keys api = InstagramAPI(client_id=p.client, client_secret=p.secret) # Get the expired non-protected subscriptions subs, ids = getExpiredSubs(collHandle, ageOff, protectedSubs) # Delete the subscriptions from the instagram server for sub in subs: print sub deleted = api.delete_subscriptions(id=int(sub)) print deleted out.append(deleted) if deleted['meta']['code'] != 200: print 'Failed to delete subscription %s' %(sub) # Delete the nextUrl object files (kept in the config directory) for objId in ids: f = os.path.join(os.path.dirname(p.configFile), objId) try: os.remove(f) except: print 'Failed to delete the subscription next URL file: \n %s\n' %(f) return out
def ageOffSubscriptions(p, collHandle, ageOff, protectedSubs): ''' Deletes subscriptions from the Instagram server based on the age and protection level in the subs collection. If protect=True, then it must be manually deleted''' out = [] # Get the client and secret keys api = InstagramAPI(client_id=p.client, client_secret=p.secret) # Get the expired non-protected subscriptions subs, ids = getExpiredSubs(collHandle, ageOff, protectedSubs) # Delete the subscriptions from the instagram server for sub in subs: print sub deleted = api.delete_subscriptions(id=int(sub)) print deleted out.append(deleted) if deleted['meta']['code'] != 200: print 'Failed to delete subscription %s' % (sub) # Delete the nextUrl object files (kept in the config directory) for objId in ids: f = os.path.join(os.path.dirname(p.configFile), objId) try: os.remove(f) except: print 'Failed to delete the subscription next URL file: \n %s\n' % ( f) return out