Commit 83072f7d authored by Kiste's avatar Kiste
Browse files

Move stuff

parent a271d8a6
# -*- coding: utf-8 -*-
from .main import main
from .studfeed import main
# -*- coding: utf-8 -*-
This program is free software. It comes without any warranty, to the extent
permitted by applicable law. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2, as
published by Sam Hocevar. See for more details.
import argparse
import requests
from feedgen.feed import FeedGenerator
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-u', '--user', help='Stud.IP Benutzername', required=True)
parser.add_argument('-p', '--password', help='Stud.IP Passwort', required=True)
parser.add_argument('-o', '--output', help='Datei, in die der ATOM-Feed geschrieben wird', required=True)
args = parser.parse_args()
generate_feed(args.user, args.password).atom_file(args.output)
def generate_feed(user, password):
session = requests.Session()
session.auth = (user, password)
fg = FeedGenerator()'')
fg.title('Stud.IP LUH')'', rel='alternate')
json_semester = session.get(BASEURL + '/courses/semester').json()
latest = None
for semester in json_semester['semesters']:
if not latest:
latest = semester
if semester['begin'] > latest['begin']:
latest = semester
json_courses = session.get(BASEURL + '/courses/semester/' + latest['semester_id']).json()
for course in json_courses['courses']:
json_news = session.get(BASEURL + '/news/range/' + course['course_id']).json()
for news in json_news['news']:
json_user = session.get(BASEURL + '/user/' + news['user_id']).json()
author = json_user['user']
fe = fg.add_entry()' ', filter(None, (author['title_pre'], author['forename'], author['lastname']))),
fe.content(news['body'], type='html')['news_id'])
fe.title(str.join('', ('[', course['title'], '] ', news['topic'])))
return fg
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment