Commit 4bff8063 authored by Kiste's avatar Kiste
Browse files

Initial commit

parents
*.kdev4
*.pyc
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
# Stud.FEED
---
Copyright © 2017 Christian Buschau <christian.buschau@stud.uni-hannover.de>
This work is free. 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 the COPYING file for more details.
#!/usr/bin/env python3
from studfeed.main import main
main()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from setuptools import setup
setup(
name='studfeed',
version='1.0',
description='Stud.IP feed generator',
url='https://git.finf.uni-hannover.de/kiste/studfeed',
author='Christian Buschau',
author_email='christian.buschau@stud.uni-hannover.de',
packages=['studfeed'],
install_requires=[
'feedgen',
'requests'
],
entry_points={
'console_scripts': [
'studfeed = studfeed.main:main'
]
}
)
# -*- coding: utf-8 -*-
from .main import main
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 http://www.wtfpl.net/ for more details.
"""
import argparse
import json
import os
from feedgen.feed import FeedGenerator
import requests
BASEURL = 'https://studip.uni-hannover.de/plugins.php/restipplugin/api'
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()
session = requests.Session()
session.auth = (args.user, args.password)
fg = FeedGenerator()
fg.id('https://studip.uni-hannover.de/')
fg.title('Stud.IP LUH')
fg.link(href='https://studip.uni-hannover.de/', rel='alternate')
fg.logo('https://studip.uni-hannover.de/assets/images/favicon.png')
fg.language('de')
jsemester = session.get(BASEURL + '/courses/semester')
aktuell = None
for semester in jsemester.json()['semesters']:
if not aktuell:
aktuell = semester
else:
if semester['begin'] > aktuell['begin']:
aktuell = semester
jcourses = session.get(BASEURL + '/courses/semester/' + aktuell['semester_id'])
for course in jcourses.json()['courses']:
jnews = session.get(BASEURL + '/news/range/' + course['course_id'])
for news in jnews.json()['news']:
juser = session.get(BASEURL + '/user/' + news['user_id'])
author = juser.json()['user']
fe = fg.add_entry()
fe.author(name=str.join(' ', filter(None, (author['title_pre'], author['forename'], author['lastname']))), email=author['email'])
fe.content(news['body'], type='html')
fe.id(news['news_id'])
fe.published(news['iso_mkdate'])
fe.title(str.join('', ('[', course['title'], '] ', news['topic'])))
fe.updated(news['iso_chdate'])
fg.atom_file(args.output)
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