def __init__(self, location, auth=None): if auth is None: self.client = RESTClient(location, None) else: self.client = RESTClient(location, auth) self.last_post = None self.location = location
class JodelPost(object): def __init__(self, location, auth=None): if auth is None: self.client = RESTClient(location, None) else: self.client = RESTClient(location, auth) self.last_post = None self.location = location def change_location(self, location): self.client.set_pos(location['longtitude'], location['latitude'], location['city']) self.location = location def post_image(self, image): self.client.post_image(image) self.set_last_post(self.client.get_posts()) def post_text(self, text): self.client.post(text) self.set_last_post(self.client.get_posts()) def set_last_post(self, posts): for post in posts: if post['post_own'] == 'own': self.last_post = post['post_id'] break def get_posts(self): return self.client.get_posts() def boost_post(self, votes): for i in tqdm(range(votes)): tmpClient = RESTClient(self.location, None) tmpClient.upvote(self.last_post) tmpClient.close()
def boost_post(self, votes): for i in tqdm(range(votes)): tmpClient = RESTClient(self.location, None) tmpClient.upvote(self.last_post) tmpClient.close()
help="read the Location from a file", required=True) parser.add_argument("-o", "--outputfile", help="the file the Jodel's should be written to") args = parser.parse_args() if args.from_file: if os.path.isfile(args.from_file): with open(args.from_file) as data_file: location = json.load(data_file) else: print 'File does not exist : %s' % args.from_file exit(0) try: rc = RESTClient(location, None) if args.outputfile: filename = args.outputfile if not str(filename).endswith('.json'): filename = "%s%s" % (filename, '.json') with open(filename, 'w') as outfile: outfile.write(rc.get_posts_raw()) else: print rc.get_posts_raw() except ConnectionError: pass
from jodelrest import RESTClient from tqdm import * import json __author__ = 'Jan' uni = {"latitude": 53.107, "longtitude": 8.853, "city": "Bremen"} rc = RESTClient(uni, None) posts = rc.get_posts() rc.close() for post in posts: if 'children' in post: print "[Comments : %s] [Votes : %s]" % (len( post['children']), post['vote_count']) #for comment in post['children']: # print "Kommentar : %s" % comment else: print "[Comments : 0] [Votes : %s]" % post['vote_count'] print '%s' % (post['message'].encode('UTF-8')) var = str(raw_input("[ up / down / comment / view / exit ] : ")) commands = {'up', 'down', 'comment', 'view', 'exit'} if var == 'exit': break id = post['post_id']
parser = argparse.ArgumentParser(description='Write Jodel\' to JSON') parser.add_argument("-f", "--from-file", help="read the Location from a file", required=True) parser.add_argument("-o", "--outputfile", help="the file the Jodel's should be written to") parser.add_argument("--tor", action='store_true', help="enable to add tor support") args = parser.parse_args() if args.from_file: if os.path.isfile(args.from_file): with open(args.from_file) as data_file: location = json.load(data_file) else: print 'File does not exist : %s' % args.from_file exit(0) try: rc = RESTClient(location, None, args.tor) if args.outputfile: filename = args.outputfile if not str(filename).endswith('.json'): filename = "%s%s" % (filename, '.json') with open(filename, 'w') as outfile: outfile.write(rc.get_posts_raw()) else: print rc.get_posts_raw() except ConnectionError: pass
from jodelrest import RESTClient from tqdm import * __author__ = 'Jan' uni = {"latitude": 53.107, "longtitude": 8.853, "city": "Bremen"} rc = RESTClient(uni, None) posts = rc.get_posts() rc.close() for post in posts: print '[ %s ] %s' % (post['vote_count'], post['message'].encode('UTF-8')) var = str(raw_input("[ up / down / exit ] : ")) commands = {'up', 'down', 'exit'} if var == 'exit': break id = post['post_id'] if var not in commands: continue elif var =='exit': break else: amount = int(raw_input('# Wie viel ? ')) for i in tqdm(range(amount)): rc = RESTClient(uni, None)
import os import json from requests.exceptions import ConnectionError __author__ = "Jan" parser = argparse.ArgumentParser(description="Write Jodel' to JSON") parser.add_argument("outputfile", help="the file the Jodel's should be written to") parser.add_argument("-f", "--from-file", help="read the Location from a file", required=True) args = parser.parse_args() if args.from_file: if os.path.isfile(args.from_file): with open(args.from_file) as data_file: location = json.load(data_file) else: print "File does not exist : %s" % args.from_file exit(0) try: rc = RESTClient(location, None) filename = args.outputfile if not str(filename).endswith(".json"): filename = "%s%s" % (filename, ".json") with open(filename, "w") as outfile: outfile.write(rc.get_posts_raw()) except ConnectionError: pass
from jodelrest import RESTClient from tqdm import * import json __author__ = 'Jan' uni = {"latitude": 53.107, "longtitude": 8.853, "city": "Bremen"} rc = RESTClient(uni, None) posts = rc.get_posts() rc.close() for post in posts: if 'children' in post: print "[Comments : %s] [Votes : %s]" % (len(post['children']), post['vote_count']) #for comment in post['children']: # print "Kommentar : %s" % comment else: print "[Comments : 0] [Votes : %s]" % post['vote_count'] print '%s' % (post['message'].encode('UTF-8')) var = str(raw_input("[ up / down / comment / view / exit ] : ")) commands = {'up', 'down', 'comment', 'view','exit'} if var == 'exit': break id = post['post_id']