Skip to content

Commit

Permalink
Merge pull request #80 from snehilrx/feature_playlist_download
Browse files Browse the repository at this point in the history
major - Added feature for downloading all episodes of anime
  • Loading branch information
snehilrx authored Oct 24, 2023
2 parents 5653a3d + e21b444 commit 9f887d0
Show file tree
Hide file tree
Showing 146 changed files with 3,451 additions and 2,791 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
echo "version=${new_version}" >> "$GITHUB_OUTPUT"
echo ${commit}
echo ${new_version}
- name: apk
env:
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
Expand All @@ -100,13 +100,13 @@ jobs:
echo -e "${property_content}" > version.properties
./gradlew :app:assembleRelease --scan
rm -f ${KEY_PATH}
# attaches the build apks in workflow run page
- uses: actions/upload-artifact@v3
with:
name: builds
path: ${{ github.workspace }}/app/build/outputs/apk/release/*.apk

# attaches the build report in workflow run page
- uses: actions/upload-artifact@v3
with:
Expand Down
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ android {

dependencies {
implementation project(path: ":base")
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.4.2'
implementation 'com.google.firebase:firebase-analytics-ktx:21.3.0'
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.5.0'
implementation 'com.google.firebase:firebase-analytics-ktx:21.4.0'
implementation "androidx.core:core-ktx:$versions.core_ktx"
implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "com.google.android.material:material:$versions.material"
Expand All @@ -78,7 +78,7 @@ dependencies {
implementation "androidx.hilt:hilt-work:$versions.work_hilt"
implementation "androidx.work:work-runtime-ktx:$versions.work"
implementation project(path: ':kickassanime')
implementation 'com.google.firebase:firebase-perf:20.4.1'
implementation 'com.google.firebase:firebase-perf:20.5.0'
androidTestImplementation "io.github.rascaler:assertj:$versions.assertJ"
testImplementation "junit:junit:$versions.junit"
androidTestImplementation "androidx.test.ext:junit:$versions.androidx_junit"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import android.content.Context
import androidx.test.runner.AndroidJUnitRunner
import dagger.hilt.android.testing.HiltTestApplication


@Suppress("unused")
class FetchTestRunner : AndroidJUnitRunner() {
@Throws(ClassNotFoundException::class, IllegalAccessException::class, InstantiationException::class)
@Throws(
ClassNotFoundException::class,
IllegalAccessException::class,
InstantiationException::class
)
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MainActivityTest {
fun setup() = hiltRule.inject()

@Test
fun testActivityStates(){
fun testActivityStates() {
ActivityScenario.launch(MainActivity::class.java).use {
it.onActivity { activity ->
Toast.makeText(activity, "Launched Anything", Toast.LENGTH_SHORT).show()
Expand Down
15 changes: 9 additions & 6 deletions app/src/androidTest/java/com/otaku/fetch/work/FeedFetcherTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal class FeedFetcherTest {
@Inject
@ApplicationContext
lateinit var context: Context

@Inject
lateinit var workerFactory: HiltWorkerFactory

Expand All @@ -42,19 +43,21 @@ internal class FeedFetcherTest {
val request = PeriodicWorkRequest.Builder(FeedFetcher::class.java, 15, TimeUnit.MINUTES)
.build()
val synchronousExecutor = SynchronousExecutor()
WorkManagerTestInitHelper.initializeTestWorkManager(context, Configuration.Builder()
.setMinimumLoggingLevel(Log.DEBUG)
.setExecutor(synchronousExecutor)
.setWorkerFactory(workerFactory)
.build())
WorkManagerTestInitHelper.initializeTestWorkManager(
context, Configuration.Builder()
.setMinimumLoggingLevel(Log.DEBUG)
.setExecutor(synchronousExecutor)
.setWorkerFactory(workerFactory)
.build()
)
// Enqueue periodic request
val instance = WorkManager.getInstance(context)
instance
.enqueueUniquePeriodicWork(TAG, ExistingPeriodicWorkPolicy.UPDATE, request)

// Initialize testDriver
val testDriver: TestDriver? = WorkManagerTestInitHelper.getTestDriver(context)
if(testDriver == null) {
if (testDriver == null) {
assert(false) {
"Test Driver was null"
}
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove">
</provider>

<meta-data android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="androidx.media3.cast.DefaultCastOptionsProvider"/>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove" />

</application>
<meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="androidx.media3.cast.DefaultCastOptionsProvider" />

</application>

</manifest>
1 change: 0 additions & 1 deletion app/src/main/java/com/otaku/fetch/FetchApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.hilt.work.HiltWorkerFactory
import androidx.multidex.MultiDexApplication
import androidx.work.Configuration
import androidx.work.WorkManager
import com.AppModuleProvider
import com.otaku.fetch.base.settings.Settings
import com.otaku.fetch.base.settings.dataStore
import com.otaku.fetch.base.ui.BindingActivity.Companion.REPO_LINK
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/otaku/fetch/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MainActivity : AppCompatActivity() {
) {
Row(horizontalArrangement = Arrangement.Center) {
Text(
text = "Fetch!",
text = getString(com.otaku.fetch.R.string.fetch),
fontFamily = sohen,
fontWeight = FontWeight.Bold,
fontSize = 42.sp
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/java/com/otaku/fetch/ModuleActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ class ModuleActivity :
pref[Settings.SKIP_ENABLED] = true
pref[Settings.NOTIFICATION_ENABLED] = askNotificationPermission()
pref[Settings.AUTO_RESUME] = true
pref[Settings.STREAM_VIDEO_QUALITY] =
resources.getStringArray(com.otaku.fetch.base.R.array.video_qualities)[0]
pref[Settings.DOWNLOADS_VIDEO_QUALITY] =
resources.getStringArray(com.otaku.fetch.base.R.array.video_qualities)[0]
pref[Settings.STREAM_VIDEO_QUALITY] = "0"
pref[Settings.DOWNLOADS_VIDEO_QUALITY] = "0"
}
}
}
Expand Down Expand Up @@ -93,6 +91,9 @@ class ModuleActivity :
}
val navHostFragment = binding.fragmentContainerView.getFragment<NavHostFragment>()
navHostFragment.navController.setGraph(appModule.getNavigationGraph())
navHostFragment.allowEnterTransitionOverlap = true
navHostFragment.allowReturnTransitionOverlap = true
navHostFragment.navController
deepLink?.let { navHostFragment.navController.navigate(it) }
binding.bottomNavigation?.inflateMenu(appModule.getBottomNavigationMenu())
binding.bottomNavigation?.setupWithNavController(navHostFragment.navController)
Expand Down Expand Up @@ -204,6 +205,7 @@ class ModuleActivity :
override fun setQueryListener(listener: MaterialSearchView.OnQueryTextListener?) {
binding.searchView.setOnQueryTextListener(listener)
}

companion object {
const val ARG_MODULE_DEEPLINK = "data"
const val ARG_MODULE_NAME = "name"
Expand Down
17 changes: 6 additions & 11 deletions app/src/main/java/com/otaku/fetch/work/AnimeNotifier.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
package com.otaku.fetch.work

import androidx.work.BackoffPolicy
import androidx.work.Constraints
import androidx.work.ExistingPeriodicWorkPolicy
import androidx.work.NetworkType
import androidx.work.PeriodicWorkRequest
import androidx.work.WorkManager
import androidx.work.WorkRequest
import java.util.concurrent.TimeUnit

class AnimeNotifier {

fun schedulePeriodicWork(workManager: WorkManager) {
workManager.enqueueUniquePeriodicWork(
"fetch_anime_updates",
ExistingPeriodicWorkPolicy.KEEP,
PeriodicWorkRequest.Builder(FeedFetcher::class.java, 1, TimeUnit.HOURS)
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE,
PeriodicWorkRequest.Builder(FeedFetcher::class.java, 2, TimeUnit.HOURS)
.setInitialDelay(25, TimeUnit.MINUTES)
.setConstraints(
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
).setBackoffCriteria(
BackoffPolicy.LINEAR,
WorkRequest.MIN_BACKOFF_MILLIS,
TimeUnit.MILLISECONDS
)
.build()
Constraints.Builder()
.setRequiresDeviceIdle(true)
.setRequiredNetworkType(NetworkType.CONNECTED).build()
).build()
)
}

Expand Down
33 changes: 15 additions & 18 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

<layout xmlns:android="http://schemas.android.com/apk/res/android">

<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragmentContainerView"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_kickassanime" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragmentContainerView"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_kickassanime" />

<com.lapism.search.widget.MaterialSearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
<com.lapism.search.widget.MaterialSearchView
android:id="@+id/searchView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>

</layout>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<background android:drawable="@drawable/ic_launcher_background" />
<monochrome android:drawable="@drawable/ic_launcher_background" />
</adaptive-icon>
2 changes: 1 addition & 1 deletion app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background"/>
<background android:drawable="@drawable/ic_launcher_background" />
<monochrome android:drawable="@drawable/ic_launcher_background" />
</adaptive-icon>
2 changes: 0 additions & 2 deletions app/src/main/res/values-land/dimens.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values-w1240dp/dimens.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values-w600dp/dimens.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/dimens.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<resources>
<string name="app_name">Fetch</string>
<string name="fetch">Fetch!</string>
</resources>
8 changes: 5 additions & 3 deletions base/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "com.android.library"
id 'org.jetbrains.kotlin.android'
id 'com.google.devtools.ksp'
id 'dagger.hilt.android.plugin'
id 'kotlin-kapt'
id "androidx.navigation.safeargs.kotlin"
Expand Down Expand Up @@ -66,6 +67,7 @@ dependencies {
implementation("com.squareup.okhttp3:okhttp:$versions.okhttp")
implementation("com.squareup.okhttp3:logging-interceptor:$versions.okhttp")
implementation project(path: ':shinebar')
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'

debugImplementation "com.squareup.leakcanary:leakcanary-android:$versions.leak_canary"

Expand Down Expand Up @@ -93,7 +95,7 @@ dependencies {
androidTestImplementation "com.google.dagger:hilt-android-testing:$versions.hilt"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$versions.hilt"

kapt "com.github.bumptech.glide:compiler:$versions.glide"
ksp("com.github.bumptech.glide:ksp:$versions.glide")
implementation "com.github.bumptech.glide:glide:$versions.glide"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:$versions.swipe_refresh_layout"

Expand Down Expand Up @@ -127,7 +129,7 @@ dependencies {
implementation "androidx.room:room-ktx:$versions.room"
implementation "androidx.room:room-common:$versions.room"
implementation "androidx.room:room-paging:$versions.room"
kapt "androidx.room:room-compiler:$versions.room"
ksp "androidx.room:room-compiler:$versions.room"


// Optional - Integration with activities
Expand All @@ -143,7 +145,7 @@ dependencies {
implementation "androidx.media3:media3-datasource-cronet:$versions.media3"
// For loading data using the OkHttp network stack
implementation "androidx.media3:media3-datasource-okhttp:$versions.media3"
implementation "androidx.hilt:hilt-navigation-compose:1.1.0-alpha01"
implementation 'androidx.hilt:hilt-navigation-compose:1.1.0-rc01'
implementation "androidx.media3:media3-exoplayer:$versions.media3"
implementation "androidx.media3:media3-datasource-okhttp:$versions.media3"
implementation "androidx.media3:media3-ui:$versions.media3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@ package com.fetch.cloudflarebypass
import com.fetch.cloudflarebypass.exceptions.UnsupportedChallengeException
import com.fetch.cloudflarebypass.uam.UAMPageAtributes
import com.fetch.cloudflarebypass.uam.UAMSettings
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import okhttp3.FormBody
import okhttp3.Headers
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

class CloudflareInterceptor(private val log: Log, private val uamSettings: UAMSettings) : Interceptor {
class CloudflareInterceptor(
private val log: Log,
private val uamSettings: UAMSettings
) :
Interceptor {

override fun intercept(chain: Interceptor.Chain): Response {
val oldRequest: Request = chain.request()
Expand All @@ -33,19 +35,19 @@ class CloudflareInterceptor(private val log: Log, private val uamSettings: UAMSe
return when {
isIUAMChallenge(response, page) -> runBlocking {
log.i(TAG, "intercept: got IUAMChallenge")
withContext(Dispatchers.IO) {
chain.proceed(
solveCFChallenge(
response,
page
)
chain.proceed(
solveCFChallenge(
response,
page
)
}
)
}

isCaptchaChallenge(response, page) -> {
log.e(TAG, "Unsupported challenge $page")
throw UnsupportedChallengeException()
}

else -> {
log.i(TAG, "intercept: got normal request")
response
Expand Down
Loading

0 comments on commit 9f887d0

Please sign in to comment.