Exemplo n.º 1
0
def getSylabus(className, username, password):
	plugin.log.info("getSylabus for %s." % className)
	
	cookies, didLogin = getClassCookieOrLogin(username, password, className, indicateDidLogin=True)
	url = get_syllabus_url(className=className)
	plugin.log.debug("syllabus_url=%s" % url)
	opener = getOpenerFromRawCookies(cookies_raw=cookies)

	sylabus_txt = get_page(url, opener)
#	print "sylabus_txt = %s" % sylabus_txt
	not_logged_in = 'with a Coursera account' in sylabus_txt
	
	if not_logged_in:
		if didLogin:
			raise Exception("Unable to login to class")
		else:
			plugin.log.info("Cookies for %s are old. Logging in to class" % className)
			cookies = getClassCookies(className, username, password)
			opener = getOpenerFromRawCookies(cookies_raw=cookies)
		
			sylabus_txt = get_page(url, opener)
	#		print "sylabus_txt = %s" % sylabus_txt
			not_logged_in = 'with a Coursera account' in sylabus_txt
			if not_logged_in:
				raise Exception("Unable to login to class")
			else:
				cookies_class = loadSavedClassCookies(username)
				cookies_class[className] = cookies
	
	parsed = parse_syllabus(sylabus_txt, opener)
	
	return parsed
Exemplo n.º 2
0
def getSylabus(className, username, password):
    plugin.log.info("getSylabus for %s." % className)

    raw_cookies = getMyDamnCookies(username, password)
    opener = getOpenerFromRawCookies(cookies_raw=raw_cookies)
    url = get_syllabus_url(className=className)
    plugin.log.debug("syllabus_url=%s" % url)

    sylabus_txt = get_page(url, opener)

    parsed = parse_syllabus(sylabus_txt, opener)

    return parsed
Exemplo n.º 3
0
def getSylabus(className, username, password):
    plugin.log.info("getSylabus for %s." % className)

    cookies, didLogin = getClassCookieOrLogin(username,
                                              password,
                                              className,
                                              indicateDidLogin=True)
    url = get_syllabus_url(className=className)
    plugin.log.debug("syllabus_url=%s" % url)
    opener = getOpenerFromRawCookies(cookies_raw=cookies)

    sylabus_txt = get_page(url, opener)
    #	print "sylabus_txt = %s" % sylabus_txt
    not_logged_in = 'with a Coursera account' in sylabus_txt or "// First check the URL and line number of the error" in sylabus_txt

    if not_logged_in:
        if didLogin:
            raise Exception("Unable to login to class")
        else:
            plugin.log.info("Cookies for %s are old. Logging in to class" %
                            className)
            cookies = getClassCookies(className, username, password)
            opener = getOpenerFromRawCookies(cookies_raw=cookies)

            sylabus_txt = get_page(url, opener)
            #		print "sylabus_txt = %s" % sylabus_txt
            not_logged_in = 'with a Coursera account' in sylabus_txt or "// First check the URL and line number of the error" in sylabus_txt
            if not_logged_in:
                raise Exception("Unable to login to class")
            else:
                cookies_class = loadSavedClassCookies(username)
                cookies_class[className] = cookies

    parsed = parse_syllabus(sylabus_txt, opener)

    return parsed