Skip to content

Commit

Permalink
update youtube-dl library
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow578 committed Nov 11, 2024
1 parent 132f017 commit c114f20
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
9 changes: 4 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ android {

defaultConfig {
applicationId = "io.github.shadow578.yodel"
minSdk = 23
minSdk = 24
targetSdk = 33
compileSdk = 33
versionCode = 5
Expand Down Expand Up @@ -111,10 +111,9 @@ dependencies {
kapt("androidx.room:room-compiler:2.5.0")

// youtube-dl
//TODO: currently uses the latest version available. This makes the build unstable!
implementation("com.github.yausername.youtubedl-android:library:master-SNAPSHOT")
implementation("com.github.yausername.youtubedl-android:ffmpeg:master-SNAPSHOT")
implementation("com.github.yausername.youtubedl-android:aria2c:master-SNAPSHOT")
implementation("io.github.junkfood02.youtubedl-android:library:0.17.1")
implementation("io.github.junkfood02.youtubedl-android:ffmpeg:0.17.1")
implementation("io.github.junkfood02.youtubedl-android:aria2c:0.17.1")

// id3v2 tagging
implementation("com.mpatric:mp3agic:0.9.1")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.github.shadow578.yodel.downloader

import android.Manifest
import android.app.Notification
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.os.Build
import androidx.annotation.StringRes
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.documentfile.provider.DocumentFile
Expand Down Expand Up @@ -616,6 +619,10 @@ class DownloaderService : LifecycleService() {
private fun updateNotification(newNotification: Notification) {
if (isInForeground) {
// already in foreground, update the notification
if (ActivityCompat.checkSelfPermission(this,Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
// TODO: handle this gracefully
return
}
notificationManager.notify(PROGRESS_NOTIFICATION_ID, newNotification)
} else {
// create foreground notification
Expand Down Expand Up @@ -745,7 +752,10 @@ class DownloaderService : LifecycleService() {

// send the notification with a randomized id
// this way, we can have multiple notifications (for multiple errors)
notificationManager.notify(notificationId, notification.build())
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED) {
// TODO: handle this gracefully
notificationManager.notify(notificationId, notification.build())
}
}

//endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ class YoutubeDLWrapper(
* @throws InterruptedException by [YoutubeDL.execute] call
*/
@Throws(YoutubeDLException::class, InterruptedException::class)
fun download(progressCallback: DownloadProgressCallback?): YoutubeDLResponse {
fun download(progressCallback: ((Float, Long, String) -> Unit)?): YoutubeDLResponse {
check(initialized) { "youtube-dl was not initialized! call YoutubeDLWrapper.init() first!" }
Timber.i("downloading $videoUrl")

val response = YoutubeDL.getInstance().execute(request, progressCallback)
val response = YoutubeDL.getInstance().execute(request, callback=progressCallback)
if (printOutput) {
Timber.i(response.toPrettyString())
print(response)
Expand Down

0 comments on commit c114f20

Please sign in to comment.