Compare commits

...

10 commits

Author SHA1 Message Date
Mikołaj Pich
3e8cdb8a27
Version 0.13.0 2019-12-07 22:44:54 +01:00
Mikołaj Pich
25791ba25d
Update tests 2019-12-07 22:44:29 +01:00
Mikołaj Pich
c53e4ead91
Fix gradle script 2019-12-07 22:36:46 +01:00
Mikołaj Pich
5d41ea5ef5
Improve timetable parsing if warn button is present
fb90b4baea
2019-12-07 22:31:11 +01:00
Mikołaj Pich
d35e92f6a7 Put comment in grade entry (<5 chars) if entry is empty
1b80087288
2019-12-07 22:29:17 +01:00
Mikołaj Pich
6df2820e96 Move sources to api module 2019-12-07 22:29:16 +01:00
doteq
60b9add09a Fix timetable (#46) 2019-12-06 15:39:07 +01:00
Mikołaj Pich
5de412b6c0 Add debug stmt in symbol list 2019-11-06 22:56:04 +01:00
Mikołaj Pich
c2377ce5ce Update chrome version 2019-11-06 22:56:04 +01:00
Mikołaj Pich
4c4cfb5eed Update gradle wrapper to 5.6.4 2019-11-06 22:56:04 +01:00
219 changed files with 311 additions and 217 deletions

4
.gitignore vendored
View file

@ -25,8 +25,8 @@ hs_err_pid*
.idea/
!.idea/codeStyles/
.gradle
/build/
/out/
build/
out/
# Ignore Gradle GUI config
gradle-app.setting

View file

@ -21,7 +21,7 @@
- timetable
- messages
... and more. Check it out [full public api](https://github.com/wulkanowy/api/blob/0.12.0/src/main/kotlin/io/github/wulkanowy/api/Api.kt).
... and more. Check it out [full public api](https://github.com/wulkanowy/api/blob/0.13.0/src/main/kotlin/io/github/wulkanowy/api/Api.kt).
## Download
@ -35,7 +35,7 @@ allprojects {
}
dependencies {
implementation 'io.github.wulkanowy:api:0.12.0'
implementation 'io.github.wulkanowy:api:0.13.0'
}
```

145
api/build.gradle Normal file
View file

@ -0,0 +1,145 @@
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm'
id 'jacoco'
id 'com.jfrog.bintray' version '1.8.4'
id 'com.github.dcendents.android-maven' version '2.1'
}
ext {
PUBLISH_VERSION = '0.13.0'
SITE_URL = 'https://github.com/wulkanowy/api'
GIT_URL = 'https://github.com/wulkanowy/api.git'
}
group 'io.github.wulkanowy'
version PUBLISH_VERSION
sourceCompatibility = 1.6
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
jcenter()
}
configurations {
ktlint
}
ext {
jspoon = "1.3.2"
okhttp3 = "3.12.6"
retrofit = "2.6.2"
threetenbp = "1.4.0"
slf4j = "1.7.29"
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "pl.droidsonroids:jspoon:$jspoon"
implementation "pl.droidsonroids.retrofit2:converter-jspoon:$jspoon"
implementation "com.squareup.retrofit2:converter-gson:$retrofit"
implementation "com.squareup.retrofit2:retrofit:$retrofit"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit"
implementation "com.squareup.retrofit2:converter-scalars:$retrofit"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3"
implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttp3"
implementation "com.github.jonyas:RxJava2Reauth:master"
implementation "org.slf4j:slf4j-api:$slf4j"
testImplementation "org.slf4j:slf4j-simple:$slf4j"
compileOnly "org.threeten:threetenbp:$threetenbp:no-tzdb"
testImplementation "org.threeten:threetenbp:$threetenbp"
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp3"
testImplementation "junit:junit:4.12"
ktlint "com.pinterest:ktlint:0.35.0"
}
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "-F", "src/**/*.kt"
}
compileKotlin {
kotlinOptions.jvmTarget = "1.6"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.6"
}
jacocoTestReport {
reports {
xml.enabled true
}
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
configurations = ['archives']
pkg {
repo = 'wulkanowy'
name = 'api'
userOrg = 'wulkanowy'
licenses = ['Apache-2.0']
vcsUrl = GIT_URL
labels = ['aar', 'wulkanowy', 'api']
publicDownloadNumbers = true
publish = true
version {
name = PUBLISH_VERSION
vcsTag = PUBLISH_VERSION
released = new Date()
}
}
}
install {
repositories.mavenInstaller {
pom {
project {
packaging 'aar'
name 'Scraping API for VULCAN UONET+'
url SITE_URL
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'mklkj'
name 'Mikołaj Pich'
email 'm.pich@outlook.com'
}
}
scm {
connection GIT_URL
developerConnection GIT_URL
url SITE_URL
}
}
}
}
}

View file

@ -10,6 +10,7 @@ fun GradesResponse.mapGradesList(): List<Grade> {
val values = getGradeValueWithModifier(grade.entry)
grade.apply {
subject = gradesSubject.name
entry = entry.removeSurrounding("(", ")")
comment = entry.substringBefore(" (").run {
if (length > 4) entry
else entry.substringBeforeLast(")").substringAfter(" (")

View file

@ -11,7 +11,7 @@ class UserAgentInterceptor(
private val androidVersion: String,
private val buildTag: String,
private val webKitRev: String = "537.36",
private val chromeRev: String = "71.0.3578.98"
private val chromeRev: String = "78.0.3904.62"
) : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {

View file

@ -19,6 +19,7 @@ import io.reactivex.Observable
import io.reactivex.Single
import org.jsoup.Jsoup
import org.jsoup.parser.Parser
import org.slf4j.LoggerFactory
import java.net.URL
class RegisterRepository(
@ -33,6 +34,10 @@ class RegisterRepository(
private val url: ServiceManager.UrlGenerator
) {
companion object {
@JvmStatic private val logger = LoggerFactory.getLogger(this::class.java)
}
fun getStudents(): Single<List<Student>> {
return getSymbols().flatMapObservable { Observable.fromIterable(it) }.flatMap { (symbol, certificate) ->
loginHelper.sendCertificate(certificate, email, certificate.action.replace(startSymbol.getNormalizedSymbol(), symbol))
@ -76,6 +81,7 @@ class RegisterRepository(
Single.just(Jsoup.parse(cert.wresult.replace(":", ""), "", Parser.xmlParser())
.select("[AttributeName$=\"Instance\"] samlAttributeValue")
.map { it.text().trim() }
.apply { logger.debug("$this") }
.filter { it.matches("[a-zA-Z0-9]*".toRegex()) } // early filter invalid symbols
.ifEmpty { listOf("opole", "gdansk", "tarnow", "rzeszow") } // fallback
.map { Pair(it, cert) }

Some files were not shown because too many files have changed in this diff Show more