Esempio n. 1
0
    def user_data(self, access_token, *args, **kwargs):
        """Loads user data from service. Implement in subclass"""

        if access_token.startswith('connectData:'):
            try:
                access_token = self.get_access_token_from_connectData(access_token.replace("connectData:", ""))
            except (UnicodeDecodeError, binascii.Error) as e:

                msg = 'Token has invalid format, {}'.format(str(e))
                response = Response()
                response.status_code = 400
                response._content = json.dumps({"error": {"message": msg}}).encode('utf-8')
                raise HTTPError(msg, response=response)

        api = wykop.WykopAPI(*self.get_key_and_secret())
        try:
            return api.user_login(login='', accountkey=access_token)
        except InvalidCredentialsError as exception:

            msg = ";".join([err.decode('utf-8') for err in exception.args])

            response = Response()
            response.status_code = 401
            response._content = json.dumps({"error": {"message": msg}}).encode('utf-8')

            raise HTTPError(msg, response=response)
Esempio n. 2
0
def crawl(test):

    api = wykop.WykopAPI(appkey=os.environ['BARYLKA_WYKOP_API_KEY'],
                         secretkey=os.environ['BARYLKA_WYKOP_SECRET_KEY'],
                         login=os.environ['BARYLKA_WYKOP_LOGIN'],
                         accountkey=os.environ['BARYLKA_WYKOP_ACCOUNT_KEY'])

    entries = api.tag("barylkakrwi")

    for entry in reversed(entries['items']):

        if not DonationEntry.objects.filter(
                micro_id=entry.id
        ) and entry.type == 'entry' and '#ignoruj' not in entry.body:
            try:
                donations = []

                read_entry(entry.body, donations)

                for donation in donations:
                    print str(donation)

                for comment in entry.comments:
                    if '#korekta' in comment.body:
                        try:
                            user = User.objects.get(name=comment.author)
                            if user.corrector:
                                read_entry(comment.body, donations)
                                if donations:
                                    api.vote_entry_comment(
                                        entry.id, comment.id)
                        except User.DoesNotExist:
                            print 'User is not corrector'

                if donations:
                    user, created = User.objects.get_or_create(
                        name=entry.author)
                    de = DonationEntry.objects.create(micro_id=entry.id,
                                                      date=entry.date,
                                                      author=user,
                                                      msg=entry.body)
                    api.vote_entry(entry.id)

                for donation in donations:
                    Donation.objects.create(
                        donor=user,
                        date=donation.get('date', de.date),
                        type=donation.get('type', 'Blood'),
                        value=donation['value'],
                        entry=de,
                        barylka_edition=settings.CURRENT_BARYLKA_EDITION)

            except:
                import sys, traceback
                traceback.print_exc()

    from django.http import HttpResponse
    return HttpResponse("ok")
Esempio n. 3
0
def wykop_complete_login(app, connectData):
    import wykop
    client = wykop.WykopAPI(app.client_id, app.secret)
    extra_data = client.get_profile(connectData['login'])
    user = get_adapter() \
        .populate_new_user(email=extra_data.get('email').split(":")[0] + '@wykop.pl',
                           username=extra_data.get('login'),
                           name=extra_data.get('name'))
    account = SocialAccount(uid=extra_data['login'],
                            provider=WykopProvider.id,
                            extra_data=extra_data,
                            user=user)

    return SocialLogin(account)
Esempio n. 4
0
 def next_api(self):
     keys = self.key_iter.next()
     self.app_key = keys[0]
     self.api = wykop.WykopAPI(*keys)
Esempio n. 5
0
import time
import wykop
import auth 
import sys
from random import randint
init_done = False 
while not init_done:
    try:
        api=wykop.WykopAPI(auth.appkey,auth.secretkey)
        api.authenticate(auth.login, auth.connection_key)
        init_done=True
    except:
        print "no auth???"
        print sys.exc_info()[0]
        time.sleep(120)
    
anserws={}
id_of_last_post=None;
while True:
    try:
        if id_of_last_post is not None:
            print id_of_last_post
            voters= api.get_entry(id_of_last_post)["voters"]
            respond="rozliczenie tury:"
            x=len(voters)-1;
            x=randint(0,x)
            i=0
            for vote in voters:
                print "@"+vote["author"]
                respond+="\n"
                respond+="@"+vote["author"]
Esempio n. 6
0
import wykop
import yaml
import pickle
import os

dir_path = os.path.dirname(os.path.realpath(__file__))
checked_path = os.path.join(dir_path, "checked.pickle")
ignored_domains_path = os.path.join(dir_path, "ignored_domains.yaml")
config = yaml.safe_load(open("config.yaml"))
api = wykop.WykopAPI(config["app_key"], config["secret_key"])


def get_checked():
    if os.path.exists(checked_path):
        with open(checked_path, "rb") as file:
            return pickle.load(file)
    else:
        return []


def update_checked(old_checked, new_checked):
    checked = old_checked + new_checked
    with open(checked_path, "wb") as file:
        pickle.dump(checked, file)


def authenticate_api():
    api.authenticate(config["account_login"], config["account_key"])


def filter_url(url):
Esempio n. 7
0
 def get_user_details(self, response):
     user = wykop.WykopAPI(*self.get_key_and_secret()).get_profile(response.get('login'))
     return dict(username=user['login'], **user)
Esempio n. 8
0
import os
import wykop
import requests
from database import User, Stream

################################################
# TODO:
# v bigger thumbnails (1024_576)
# v simple database (SQLite?)
# - custom tags per author, transmission, project to subscribe or ignore
# - proper authorization
# - stats
################################################
api = wykop.WykopAPI(
    appkey=os.environ['WYKOP_API_KEY'],
    secretkey=os.environ['WYKOP_SECRET_KEY'],
    login=os.environ['WYKOP_LOGIN'],
    password=os.environ['WYKOP_PASS']
)
################################################
cookies = {'sessionid': os.environ['LIVECODING_SESSION_ID']}
programming_languages = [
    'javascript', 'java', 'python', 'ruby', 'css', 'php',
    'c++', 'c', 'shell', 'csharp', 'objectivec', 'r',
    'viml', 'go', 'perl', 'coffeescript', 'tex',
    'scala', 'haskell', 'emacs', 'lisp'
]
################################################


def is_user_from_country(stream_data, code):
    user = User.get_user(stream_data['user__slug'].lower())
Esempio n. 9
0
 def __init__(self, config_path):
     self._config = appconfig.Config(config_path)
     self._api = wykop.WykopAPI(self._config.get_app_key(),
                                self._config.get_app_secret())
Esempio n. 10
0
 def __init__(self):
     key = "DckQrvYifo"
     secret = "eh1KVgsGxJ"  # super secreit!!111one
     self.api = wykop.WykopAPI(key, secret)