Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
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']
Ejemplo n.º 4
0
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)