Skip to content

Commit 8c363f0

Browse files
committed
init
1 parent baba22b commit 8c363f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+820
-21
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

.idea/.gitignore

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/compiler.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

-21
This file was deleted.

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 30
7+
buildToolsVersion "30.0.3"
8+
9+
defaultConfig {
10+
applicationId "com.example.epubdownloader"
11+
minSdkVersion 21
12+
targetSdkVersion 30
13+
versionCode 1
14+
versionName "1.0"
15+
16+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17+
}
18+
19+
buildTypes {
20+
release {
21+
minifyEnabled false
22+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23+
}
24+
}
25+
}
26+
27+
repositories {
28+
maven { url 'https://jitpack.io' }
29+
}
30+
31+
dependencies {
32+
implementation fileTree(dir: "libs", include: ["*.jar"])
33+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
34+
implementation 'androidx.core:core-ktx:1.3.2'
35+
implementation 'androidx.appcompat:appcompat:1.2.0'
36+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
37+
implementation "io.karn:khttp-android:0.1.2"
38+
implementation 'org.jsoup:jsoup:1.13.1'
39+
testImplementation 'junit:junit:4.12'
40+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
42+
43+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.example.epubdownloader
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.example.epubdownloader", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.example.epubdownloader">
4+
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
7+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
8+
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity android:name=".MainActivity">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN"/>
19+
20+
<category android:name="android.intent.category.LAUNCHER"/>
21+
</intent-filter>
22+
</activity>
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.example.epubdownloader
2+
3+
open class MainAPI {
4+
open val name = "NONE"
5+
open val mainUrl = "NONE"
6+
open fun search(query: String): ArrayList<SearchResponse>? {
7+
return null
8+
}
9+
10+
open fun load(url: String): LoadResponse? {
11+
return null
12+
}
13+
14+
open fun loadPage(url: String): String? {
15+
return null
16+
}
17+
}
18+
19+
data class SearchResponse(
20+
val name: String,
21+
val url: String,
22+
val posterUrl: String?,
23+
val rating: Int?,
24+
val latestChapter: String?,
25+
)
26+
27+
data class LoadResponse(
28+
val name: String,
29+
val data: ArrayList<ChapterData>,
30+
val author: String?,
31+
val posterUrl: String?,
32+
//RATING IS FROM 0-100
33+
val rating: Int?,
34+
val Synopsis: String?,
35+
val tags: ArrayList<String>?,
36+
)
37+
38+
data class ChapterData(
39+
val name: String,
40+
val url: String,
41+
val dateOfRelease: String?,
42+
val views: Int?,
43+
//val index : Int,
44+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.example.epubdownloader
2+
3+
import android.content.Context
4+
import androidx.appcompat.app.AppCompatActivity
5+
import android.os.Bundle
6+
import kotlin.concurrent.thread
7+
8+
class MainActivity : AppCompatActivity() {
9+
companion object {
10+
lateinit var activity: MainActivity;
11+
}
12+
13+
public lateinit var mainContext: Context;
14+
15+
val api: MainAPI = NovelPassionProvider()
16+
17+
override fun onCreate(savedInstanceState: Bundle?) {
18+
super.onCreate(savedInstanceState)
19+
setContentView(R.layout.activity_main)
20+
activity = this
21+
mainContext = this.applicationContext
22+
thread {
23+
api.load("https://www.novelpassion.com/novel/world-s-best-martial-artist")
24+
}
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.example.epubdownloader
2+
3+
import android.widget.Toast
4+
import khttp.head
5+
import org.jsoup.Jsoup
6+
7+
class NovelPassionProvider : MainAPI() {
8+
9+
override val name: String get() = "Novel Passion"
10+
override val mainUrl: String get() = "https://www.novelpassion.com"
11+
12+
override fun search(query: String): ArrayList<SearchResponse>? {
13+
val response = khttp.get("$mainUrl/search?keyword=$query")
14+
15+
val document = Jsoup.parse(response.text)
16+
val headers = document.select("div.lh1d5")
17+
if (headers.size <= 0) return null
18+
val returnValue: ArrayList<SearchResponse> = ArrayList()
19+
for (h in headers) {
20+
val head = h.selectFirst("a.c_000");
21+
val name = head.attr("title")
22+
val url = mainUrl + head.attr("href")
23+
24+
var posterUrl = head.selectFirst("i.oh > img").attr("src")
25+
if (posterUrl != null) posterUrl = mainUrl + posterUrl
26+
27+
val rating = (h.selectFirst("p.g_star_num > small").text()!!.toFloat() * 20).toInt()
28+
val latestChapter = h.selectFirst("div > div.dab > a").attr("title")
29+
returnValue.add(SearchResponse(name, url, posterUrl, rating, latestChapter))
30+
}
31+
return returnValue
32+
}
33+
34+
override fun load(url: String): LoadResponse? {
35+
val response = khttp.get(url)
36+
val document = Jsoup.parse(response.text)
37+
val name = document.select("h2.pt4").text()!!
38+
val author = document.selectFirst("a.stq").text()!!
39+
val posterUrl = mainUrl + document.select("i.g_thumb > img").attr("src")
40+
val tags: ArrayList<String> = ArrayList()
41+
42+
val rating = (document.select("strong.vam").text().toFloat() * 20).toInt()
43+
var synopsis = ""
44+
val synoParts = document.select("div.g_txt_over > div.c_000 > p")
45+
for (s in synoParts) {
46+
synopsis += s.text()!! + "\n"
47+
}
48+
49+
val infoheader =
50+
document.select("div.psn > address.lh20 > div.dns") // 0 = Author, 1 = Tags
51+
52+
val tagsHeader = infoheader[1].select("a.stq")
53+
for (t in tagsHeader) {
54+
tags.add(t.text())
55+
}
56+
57+
val data: ArrayList<ChapterData> = ArrayList()
58+
val chapterHeaders = document.select("ol.content-list > li > a")
59+
for (c in chapterHeaders) {
60+
val url = c.attr("href")
61+
val name = c.select("span.sp1").text()
62+
val added = c.select("i.sp2").text()
63+
val views = c.select("i.sp3").text().toInt()
64+
data.add(ChapterData(name, url, added, views))
65+
}
66+
67+
return LoadResponse(name, data, author, posterUrl, rating, synopsis, tags)
68+
Toast.makeText(MainActivity.activity.mainContext, "TEST", Toast.LENGTH_SHORT).show()
69+
return null
70+
}
71+
}

0 commit comments

Comments
 (0)