use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.
the class IndiwareStundenplan24Parser method getSubstitutionSchedule.
@Override
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
String baseurl;
if (data.has("schoolNumber")) {
baseurl = "https://www.stundenplan24.de/" + data.getString("schoolNumber") + "/vplan/";
if (credential == null || !(credential instanceof UserPasswordCredential)) {
throw new IOException("no login");
}
String login = ((UserPasswordCredential) credential).getUsername();
String password = ((UserPasswordCredential) credential).getPassword();
executor.auth(login, password);
} else {
baseurl = data.getString("baseurl") + "/";
new LoginHandler(scheduleData, credential, cookieProvider).handleLogin(executor, cookieStore);
}
List<Document> docs = new ArrayList<>();
for (int i = 0; i < MAX_DAYS; i++) {
LocalDate date = LocalDate.now().plusDays(i);
String dateStr = DateTimeFormat.forPattern("yyyyMMdd").print(date);
String url = baseurl + "vdaten/VplanKl" + dateStr + ".xml?_=" + System.currentTimeMillis();
try {
String xml = httpGet(url, ENCODING);
Document doc = Jsoup.parse(xml, url, Parser.xmlParser());
if (doc.select("kopf datei").text().equals("VplanKl" + dateStr + ".xml")) {
docs.add(doc);
}
} catch (HttpResponseException e) {
if (e.getStatusCode() != 404 && e.getStatusCode() != 300)
throw e;
}
}
SubstitutionSchedule v = SubstitutionSchedule.fromData(scheduleData);
for (Document doc : docs) {
v.addDay(parseIndiwareDay(doc, false));
}
v.setWebsite(baseurl);
v.setClasses(getAllClasses());
v.setTeachers(getAllTeachers());
return v;
}
use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.
the class LegionBoardParser method getSubstitutionSchedule.
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
final SubstitutionSchedule substitutionSchedule = SubstitutionSchedule.fromData(scheduleData);
substitutionSchedule.setClasses(getAllClasses());
substitutionSchedule.setTeachers(getAllTeachers());
substitutionSchedule.setWebsite(website);
final JSONArray changes = getChanges();
final JSONArray courses = getCourses();
final JSONArray teachers = getTeachers();
parseLegionBoard(substitutionSchedule, changes, courses, teachers);
return substitutionSchedule;
}
use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.
the class NotCompatibleParser method getSubstitutionSchedule.
@Override
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
SubstitutionSchedule v = SubstitutionSchedule.fromData(scheduleData);
v.setLastChange(new LocalDateTime(2017, 10, 18, 12, 4));
SubstitutionScheduleDay today = new SubstitutionScheduleDay();
today.setDate(new LocalDate(2018, 1, 1));
Substitution subst = new Substitution();
subst.setLesson("0");
subst.setClasses(new HashSet<>(getAllClasses()));
subst.setType("siehe Nachrichten");
subst.setDesc("Der Vertretungsplan kann von dieser Schule nicht mehr abgerufen werden. Genauere Informationen" + " findest du unter \"Nachrichten\".");
subst.setColor("#F44336");
today.addSubstitution(subst);
today.addMessage("Aus technischen Gründen kann der Vertretungsplan dieser Schule mit dieser App nicht mehr " + "abgerufen werden. " + (scheduleData.getApi().equals("dsbmobile") ? "Als Alternative kannst du vorerst die offizielle " + "App \"DSBmobile\" nutzen. " : "") + "Falls Sie eine Lehrkraft oder Schulleiter/-in an der Schule sind, melden Sie sich " + "bitte unter info@vertretungsplan.me bei uns, um herauszufinden, wie der Plan wieder in die App " + "aufgenommen werden kann. Falls Sie die Pro-Version der App gekauft haben, können wir " + "Ihnen das Geld zurückerstatten, wenn Sie sich per E-Mail an info@vertretungsplan.me bei uns melden.");
v.addDay(today);
v.setClasses(getAllClasses());
v.setTeachers(new ArrayList<String>());
return v;
}
use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.
the class TurboVertretungParser method getSubstitutionSchedule.
@Override
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
//
new LoginHandler(scheduleData, credential, cookieProvider).handleLogin(executor, cookieStore);
JSONArray urls = data.getJSONArray(PARAM_URLS);
String encoding = data.optString(PARAM_ENCODING, null);
List<Document> docs = new ArrayList<>();
SubstitutionSchedule v = SubstitutionSchedule.fromData(scheduleData);
for (int i = 0; i < urls.length(); i++) {
String url;
if (urls.get(i) instanceof JSONObject) {
// backwards compatibility
url = urls.getJSONObject(i).getString("url");
} else {
url = urls.getString(i);
}
loadUrl(url, encoding, docs);
}
for (Document doc : docs) {
String html = doc.body().html();
String[] parts = html.split("<p class=\"Titel\">");
for (int i = 1; i < parts.length; i++) {
Document partDoc = Jsoup.parse("<p class=\"Titel\">" + parts[i]);
parseTurboVertretungDay(v, partDoc);
}
}
v.setClasses(getAllClasses());
v.setTeachers(getAllTeachers());
return v;
}
use of me.vertretungsplan.objects.SubstitutionSchedule in project substitution-schedule-parser by vertretungsplanme.
the class UntisSubstitutionParser method getSubstitutionSchedule.
@Override
public SubstitutionSchedule getSubstitutionSchedule() throws IOException, JSONException, CredentialInvalidException {
new LoginHandler(scheduleData, credential, cookieProvider).handleLogin(executor, cookieStore);
String encoding = data.optString(PARAM_ENCODING, null);
SubstitutionSchedule v = SubstitutionSchedule.fromData(scheduleData);
int successfulSchedules = 0;
HttpResponseException lastExceptionSchedule = null;
for (String baseUrl : ParserUtils.handleUrlsWithDateFormat(urls)) {
try {
Document doc = Jsoup.parse(this.httpGet(baseUrl, encoding));
Elements classes = doc.select("td a");
String lastChange = doc.select("td[align=right]:not(:has(b))").text();
int successfulClasses = 0;
HttpResponseException lastExceptionClass = null;
for (Element klasse : classes) {
try {
Document classDoc = Jsoup.parse(httpGet(baseUrl.substring(0, baseUrl.lastIndexOf("/")) + "/" + klasse.attr("href"), encoding));
parseSubstitutionTable(v, lastChange, classDoc, klasse.text());
successfulClasses++;
} catch (HttpResponseException e) {
lastExceptionClass = e;
}
}
if (successfulClasses == 0 && lastExceptionClass != null) {
throw lastExceptionClass;
}
successfulSchedules++;
} catch (HttpResponseException e) {
lastExceptionSchedule = e;
}
}
if (successfulSchedules == 0 && lastExceptionSchedule != null) {
throw lastExceptionSchedule;
}
if (data.has(PARAM_WEBSITE)) {
v.setWebsite(data.getString(PARAM_WEBSITE));
} else {
v.setWebsite(urls.get(0));
}
v.setClasses(getAllClasses());
v.setTeachers(getAllTeachers());
return v;
}
Aggregations