Beispiel #1
0
    def __init__(self, username, password):
        cookie_jar = cookielib.MozillaCookieJar('cookie_file')
        self.api = quizduell.QuizduellApi(cookie_jar)

        if os.access(cookie_jar.filename, os.F_OK):
            cookie_jar.load()
        else:
            self.api.login_user(username, password)

        cookie_jar.save()
        result = self.api.top_list_rating()

        if 'access' in result:
            # Session invalid, re-login:
            self.api.login_user('name', 'password')
Beispiel #2
0
import quizduell

# Create a Quizduell user (alternatively login with api.login_user):
api = quizduell.QuizduellApi()
user = api.create_user('Max Mustermann', 'password')

if 'popup_mess' in user:
    print 'Error:', user['popup_mess']
    exit()

# Instantiation of the Quizduell TV API from authenticated Quizduell API:
# Raises "HTTP Error 404: Not Found" while show is inactive!
tv_api = quizduell.QuizduellTvApi.fromQuizduellApi(api)
tv_api.agree_agbs()
Beispiel #3
0
import quizduell
import cookielib
import json
import os

# Load authenticated session from file to prevent unnecessary logins:
cookie_jar = cookielib.MozillaCookieJar('cookie_file')
api = quizduell.QuizduellApi(cookie_jar)

if os.access(cookie_jar.filename, os.F_OK):
    cookie_jar.load()
else:
    api.login_user('name', 'password')

api = quizduell.QuizduellApi(cookie_jar)
result = api.top_list_rating()

if 'access' in result:
    # Session invalid, re-login:
    api.login_user('name', 'password')
    result = api.top_list_rating()

# Store authenticated session in file:
cookie_jar.save()

print json.dumps(result, sort_keys=True, indent=4)