diff --git a/events.json b/events.json new file mode 100644 index 0000000..ed16547 --- /dev/null +++ b/events.json @@ -0,0 +1 @@ +[{"name": "Transmission Electron Microscopy", "vert_name": "Vertiefungsgebiet: \"Struktur kondensierter Materie\" / \"structure of condensed matter\" ", "week": "both", "time": 6, "day": 3, "type": "lect"}, {"name": "Festk\u00f6rpermagnetismus I", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 3, "day": 0, "type": "lect"}, {"name": "Festk\u00f6rpermagnetismus I", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "date": {"day": 2, "week": "both", "time": 1}, "week": "both", "time": 1, "day": 2, "type": "tut"}, {"name": "Solid State Spectroscopy ", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 2, "day": 0, "type": "lect"}, {"name": "Solid State Spectroscopy ", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 4, "day": 2, "type": "lect"}, {"name": "Solid State Spectroscopy ", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "date": {"day": 3, "week": "gw", "time": 4}, "week": "gw", "time": 4, "day": 3, "type": "tut"}, {"name": "Physik unter extremen Bedingungen", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 2, "day": 2, "type": "lect"}, {"name": "Magnetism on the nanoscale", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 6, "day": 0, "type": "lect"}, {"name": "Supraleitung II", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 3, "day": 0, "type": "lect"}, {"name": "Optical Spectroscopy of Quantum Matter", "vert_name": "Vertiefungsgebiet: \"Elektronische Eigenschaften von Festk\u00f6rpern\" / \"electronic properties of solids\" ", "week": "both", "time": 6, "day": 2, "type": "lect"}, {"name": "Nanooptics - MC Nanobiophysics", "vert_name": "Vertiefungsgebiet: \"Angewandte Festk\u00f6rperphysik und Photonik\" / \"applied solid state physics and photonics\" ", "week": "both", "time": 4, "day": 0, "type": "lect"}, {"name": "Semiconductor Quantum Structures", "vert_name": "Vertiefungsgebiet: \"Angewandte Festk\u00f6rperphysik und Photonik\" / \"applied solid state physics and photonics\" ", "week": "both", "time": 5, "day": 1, "type": "lect"}, {"name": "Moderne Optik 2", "vert_name": "Vertiefungsgebiet: \"Angewandte Festk\u00f6rperphysik und Photonik\" / \"applied solid state physics and photonics\" ", "week": "both", "time": 2, "day": 1, "type": "lect"}, {"name": "Introduction to Semiconductor Physics", "vert_name": "Vertiefungsgebiet: \"Angewandte Festk\u00f6rperphysik und Photonik\" / \"applied solid state physics and photonics\" ", "week": "both", "time": 5, "day": 0, "type": "lect"}, {"name": "Mat. Sci.Ions", "vert_name": "Vertiefungsgebiet: \"Angewandte Festk\u00f6rperphysik und Photonik\" / \"applied solid state physics and photonics\" ", "week": "both", "time": 3, "day": 4, "type": "lect"}, {"name": "Nuclear Physics: Fundamentals and Applications", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 5, "day": 0, "type": "lect"}, {"name": "Nuclear Physics: Fundamentals and Applications", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 0, "week": "ugw", "time": 6}, "week": "ugw", "time": 6, "day": 0, "type": "tut"}, {"name": "Statistical Methods in Data Analysis", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 4, "day": 3, "type": "lect"}, {"name": "Statistical Methods in Data Analysis", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 2, "week": "ugw", "time": 5}, "week": "ugw", "time": 5, "day": 2, "type": "tut"}, {"name": "Higgs and Beyond Standard Model Physics ", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 2, "day": 1, "type": "lect"}, {"name": "Higgs and Beyond Standard Model Physics ", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 0, "week": "gw", "time": 4}, "week": "gw", "time": 4, "day": 0, "type": "tut"}, {"name": "Neutrinophysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 3, "day": 0, "type": "lect"}, {"name": "Neutrinophysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 1, "week": "gw", "time": 3}, "week": "gw", "time": 3, "day": 1, "type": "tut"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 4, "day": 2, "type": "lect"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "gw", "time": 2, "day": 3, "type": "lect"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 3, "week": "both", "time": 2}, "week": "both", "time": 2, "day": 3, "type": "tut"}, {"name": "Strahlungsphysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "week": "both", "time": 4, "day": 1, "type": "lect"}, {"name": "Strahlungsphysik", "vert_name": "Vertiefungsgebiet: \"Teilchen- und Kernphysik\" / \"particle and nuclear physics\" ", "date": {"day": 2, "week": "gw", "time": 4}, "week": "gw", "time": 4, "day": 2, "type": "tut"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 2, "day": 0, "type": "lect"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "ugw", "time": 5, "day": 3, "type": "lect"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "date": {"day": 3, "week": "gw", "time": 5}, "week": "gw", "time": 5, "day": 3, "type": "tut"}, {"name": "Biophysik/Biophysikalische Methoden", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 3, "day": 1, "type": "lect"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 4, "day": 2, "type": "lect"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "ugw", "time": 2, "day": 3, "type": "lect"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "date": {"day": 3, "week": "gw", "time": 2}, "week": "gw", "time": 2, "day": 3, "type": "tut"}, {"name": "Introduction to Biophysics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 5, "day": 1, "type": "lect"}, {"name": "Biophysical Chemistry", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 5, "day": 0, "type": "lect"}, {"name": "Biophysical Chemistry", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "date": {"day": 0, "week": "both", "time": 6}, "week": "both", "time": 6, "day": 0, "type": "tut"}, {"name": "Collective processes in non-equilibrium systems", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 6, "day": 1, "type": "lect"}, {"name": "Nanooptics - MC Nanobiophysics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 4, "day": 0, "type": "lect"}, {"name": "Cellular Machines II: Molecular Motors", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 3, "day": 1, "type": "lect"}, {"name": "Biological Hydrodynamics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 3, "day": 2, "type": "lect"}, {"name": "Biological Hydrodynamics", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "date": {"day": 3, "week": "both", "time": 5}, "week": "both", "time": 5, "day": 3, "type": "tut"}, {"name": "Modern Topics in Physical Chemistry of Polymeric Materials", "vert_name": "Vertiefungsgebiet: \"Weiche kondensierte Materie und biologische Physik\" / \"soft condensed matter and biological physics\" ", "week": "both", "time": 5, "day": 3, "type": "lect"}, {"name": "Quantenfelder unter dem Einflu\u00df externer Bedingungen", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 4, "day": 0, "type": "lect"}, {"name": "Quantenfelder unter dem Einflu\u00df externer Bedingungen", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 3, "day": 1, "type": "lect"}, {"name": "Quantenfelder unter dem Einflu\u00df externer Bedingungen", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 1, "week": "gw", "time": 3}, "week": "gw", "time": 3, "day": 1, "type": "tut"}, {"name": "Quantum Information", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 4, "day": 3, "type": "lect"}, {"name": "Quantum Information", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 5, "day": 1, "type": "lect"}, {"name": "Quantum Information", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 1, "week": "both", "time": 5}, "week": "both", "time": 5, "day": 1, "type": "tut"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 4, "day": 2, "type": "lect"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 2, "day": 3, "type": "lect"}, {"name": "Theoretical Polymer Physics", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 3, "week": "gw", "time": 2}, "week": "gw", "time": 2, "day": 3, "type": "tut"}, {"name": "Relativistische Quantenfeldtheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 5, "day": 3, "type": "lect"}, {"name": "Relativistische Quantenfeldtheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 2, "day": 1, "type": "lect"}, {"name": "Relativistische Quantenfeldtheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 4, "week": "both", "time": 3}, "week": "both", "time": 3, "day": 4, "type": "tut"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 4, "day": 2, "type": "lect"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "gw", "time": 2, "day": 3, "type": "lect"}, {"name": "Theoretische Teilchenphysik", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 3, "week": "both", "time": 2}, "week": "both", "time": 2, "day": 3, "type": "tut"}, {"name": "Vielteilchentheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 4, "day": 1, "type": "lect"}, {"name": "Vielteilchentheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 5, "day": 3, "type": "lect"}, {"name": "Vielteilchentheorie", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 3, "week": "gw", "time": 5}, "week": "gw", "time": 5, "day": 3, "type": "tut"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 2, "day": 0, "type": "lect"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "ugw", "time": 5, "day": 3, "type": "lect"}, {"name": "Spezielle Kapitel der Thermodynamik und Statistk", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "date": {"day": 3, "week": "gw", "time": 5}, "week": "gw", "time": 5, "day": 3, "type": "tut"}, {"name": "Methods for Quantum Many-Body Dynamics", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 6, "day": 2, "type": "lect"}, {"name": "Collective processes in non-equilibrium systems", "vert_name": "Vertiefungsgebiet: \"Theoretische Physik\" / \"theoretical physics\" ", "week": "both", "time": 6, "day": 1, "type": "lect"}] diff --git a/index.html b/index.html new file mode 100644 index 0000000..a3187c5 --- /dev/null +++ b/index.html @@ -0,0 +1,56 @@ + + + Physik Vertiefungsbrowser + + + + + + + + + +
+ +
+
+
+
+ + + + +
+
+
+
+ Einfach Links auswaehlen :). +
+
+ + + + diff --git a/main.js b/main.js new file mode 100644 index 0000000..439f236 --- /dev/null +++ b/main.js @@ -0,0 +1,108 @@ +function getEvents() { + return new Promise((resolve, reject) => { + $.getJSON("events.json", function(data) { + resolve(data); + }); + }); +} + +db = new PouchDB("main"); +subjects = {}; + +function setUpForm() { + for(let vert in subjects) { + $('#verts').append(` +

${vert}

+ `); + for(let sub of subjects[vert].keys()) { + + $('#verts').append(` + + +
+ `); + } + $('#verts').append(`
`); + } + + $('#settings').on('click', '*', e => { + renderTable(); + }); +} + +async function renderTable() { + tbl = $('#table'); + checked_subj = new Set(); + for(let subj of $('.subj')) + if($(subj).prop('checked')) + checked_subj.add(subj.value); + + types = $('#type').val(); + week = $('#week').val(); + + allsub = []; + + + for(let time of Array.from({length: 7}, (x, i) => i + 1)) { + allsub.push(db.find({ + sort: ["day"], + selector: + {name: {$in:Array.from(checked_subj)},day: {$exists: true}, time: time, week: {$in:[week, 'both']}, type: {$in: types}}})); + + } + + subs = await Promise.all(allsub); + + let content = ``; + for(let day of ["Mo", "Di", "Mi", "Do", "Fr"]) + content += ``; + content += ``; + + for(let time in subs) { + content += ``; + } + content += ``; + } + + tbl.html(content); +} + +$(document).ready(() => { + getEvents().then(events => { + allput=[]; + for(let event of events) { + if(!subjects[event.vert_name]) + subjects[event.vert_name] = new Set(); + subjects[event.vert_name].add(event.name); + allput.push(db.put({_id: event.name + event.time.toString() + event.day.toString() + event.week, + ...event}).catch(() => true)); + } + + return Promise.all(allput); + + }).then(() => { + return db.createIndex({ + index: {fields: ['day']} + }); + }).then(() =>{ + setUpForm(); + }); +}); diff --git a/main.py b/main.py new file mode 100644 index 0000000..02b93c8 --- /dev/null +++ b/main.py @@ -0,0 +1,127 @@ +from bs4 import BeautifulSoup +import requests +from uritools import urijoin +import re +from enum import Enum +import json + +base = "https://tu-dresden.de/" +time_regex = re.compile( + r"(MO|DI|MI|DO|FR)\(([0-9])\)\s*(ugW|gw)*", re.MULTILINE | re.IGNORECASE +) +days = ["MO", "DI", "MI", "DO", "FR"] + + +class Week(str, Enum): + GW = "gw" + UGW = "ugw" + BOTH = "both" + + +def parse_dates(text): + parsed = [] + for day, time, week in time_regex.findall(text): + day = days.index(day) + week = ( + (Week.GW if re.match("gw", week, re.IGNORECASE) else Week.UGW) + if week + else Week.BOTH + ) + + parsed.append(dict(day=day, week=week, time=int(time))) + + return parsed + + +def parse_lecture(lect_link, name): + lect_html = requests.get(urijoin(base, lect_link.get("href"))).text + lect = BeautifulSoup(lect_html, features="html.parser") + lect_times = ( + lect.find("div", class_="tudbox") + .find(lambda tag: tag.name == "td" and "Zeit/Ort:" in tag.text) + .find_next_sibling("td") + .text.strip() + ) + + dates = [ + dict( + name=lect_link.text, + vert_name=name, + week=date["week"], + time=date["time"], + day=date["day"], + type="lect", + ) + for date in parse_dates(lect_times) + ] + + tuts = None + tuts_row = lect.find("div", class_="tudbox").find( + lambda tag: tag.name == "td" and "Übungen:" in tag.text + ) + + if tuts_row: + dates += [ + dict( + name=lect_link.text, + vert_name=name, + date=date, + week=date["week"], + time=date["time"], + day=date["day"], + type="tut", + ) + for date in parse_dates( + list(tuts_row.find_next_sibling("td").findAll("td"))[-1].text + ) + ] + + return dates + + +def get_lectures(vert_table, vert_name): + return [ + event + for lect in vert_table.findAll("a") + for event in parse_lecture(lect, vert_name) + ] + + +def get_vert_tables(): + vert_html = requests.get( + "https://tu-dresden.de/mn/physik/studium/lehrveranstaltungen/vertiefungsgebiete-bachelor-und-master/katalog_wintersemester" + ).text + soup = BeautifulSoup(vert_html, features="html.parser") + + vert_tables = soup.findAll("table", class_="BodyTable") + + verts = [ + lecture + for vert in vert_tables + for lecture in get_lectures(vert, vert.previous_sibling.text) + ] + return verts + + +def get_lectures_for_time(verts, time, tut=False, week=None): + lects = [[] for _ in days] + lnames = [[] for _ in days] + for _, vert in verts.items(): + for lect in vert["lectures"]: + times = lect["tutorial_times"] if tut else lect["lecture_times"] + if times: + for l_time in times: + if l_time["time"] == time: + if lect["name"] not in lnames[l_time["day"]]: + if week is not None and l_time["week"].value != week.value: + continue + + lects[l_time["day"]].append(lect) + lnames[l_time["day"]].append(lect["name"]) + + return lects + + +if __name__ == "__main__": + all = get_vert_tables() + print(json.dumps(all))
DS${day}
${parseInt(time) + 1}`; + last_day = 0; + weekday_subs = Array.from({length: 5}, (x, i) => []); + for(let sub of subs[time].docs) { + console.log( sub, sub.day ); + + weekday_subs[sub.day].push(sub); + } + console.log(weekday_subs); + + for (let day of weekday_subs) { + content += ``; + for(let sub of day) { + content += sub.name; + if(sub.type === "tut") + content += "(U)"; + content += ",
"; + } + content += `