Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Organized the library module for future changes #280

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.yausername.aria2c.Aria2c;
import com.yausername.ffmpeg.FFmpeg;
import com.yausername.youtubedl_android.YoutubeDL;
import com.yausername.youtubedl_android.YoutubeDLException;
import com.yausername.youtubedl_android.domain.YoutubeDLException;

import io.reactivex.Completable;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import androidx.core.app.ActivityCompat;

import com.yausername.youtubedl_android.YoutubeDL;
import com.yausername.youtubedl_android.YoutubeDLRequest;
import com.yausername.youtubedl_android.data.local.YoutubeDLRequest;

import java.util.Collections;
import java.util.regex.Matcher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import androidx.core.app.ActivityCompat;

import com.yausername.youtubedl_android.YoutubeDL;
import com.yausername.youtubedl_android.YoutubeDLRequest;
import com.yausername.youtubedl_android.data.local.YoutubeDLRequest;

import java.io.File;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import androidx.appcompat.app.AppCompatActivity;

import com.yausername.youtubedl_android.YoutubeDL;
import com.yausername.youtubedl_android.domain.UpdateChannel;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {

private Button btnStreamingExample;
Expand Down Expand Up @@ -87,11 +87,11 @@ public void onClick(View v) {
.setItems(new String[]{"Stable Releases", "Nightly Releases", "Master Releases"},
(dialogInterface, which) -> {
if (which == 0)
updateYoutubeDL(YoutubeDL.UpdateChannel._STABLE);
updateYoutubeDL(UpdateChannel._STABLE);
else if (which == 1)
updateYoutubeDL(YoutubeDL.UpdateChannel._NIGHTLY);
updateYoutubeDL(UpdateChannel._NIGHTLY);
else
updateYoutubeDL(YoutubeDL.UpdateChannel._MASTER);
updateYoutubeDL(UpdateChannel._MASTER);
})
.create();
dialog.show();
Expand All @@ -100,7 +100,7 @@ else if (which == 1)
}
}

private void updateYoutubeDL(YoutubeDL.UpdateChannel updateChannel) {
private void updateYoutubeDL(UpdateChannel updateChannel) {
if (updating) {
Toast.makeText(MainActivity.this, "Update is already in progress!", Toast.LENGTH_LONG).show();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import com.devbrackets.android.exomedia.listener.OnPreparedListener;
import com.devbrackets.android.exomedia.ui.widget.VideoView;
import com.yausername.youtubedl_android.YoutubeDL;
import com.yausername.youtubedl_android.YoutubeDLRequest;
import com.yausername.youtubedl_android.data.local.YoutubeDLRequest;

import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down
2 changes: 1 addition & 1 deletion aria2c/src/main/java/com/yausername/aria2c/Aria2c.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yausername.aria2c

import android.content.Context
import com.yausername.youtubedl_android.YoutubeDLException
import com.yausername.youtubedl_android.domain.YoutubeDLException
import com.yausername.youtubedl_common.SharedPrefsHelper
import com.yausername.youtubedl_common.utils.ZipUtils
import org.apache.commons.io.FileUtils
Expand Down
2 changes: 1 addition & 1 deletion ffmpeg/src/main/java/com/yausername/ffmpeg/FFmpeg.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.yausername.ffmpeg

import android.content.Context
import com.yausername.youtubedl_android.YoutubeDLException
import com.yausername.youtubedl_android.domain.YoutubeDLException
import com.yausername.youtubedl_common.SharedPrefsHelper
import com.yausername.youtubedl_common.SharedPrefsHelper.update
import com.yausername.youtubedl_common.utils.ZipUtils.unzip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ package com.yausername.youtubedl_android
import android.content.Context
import android.os.Build
import com.fasterxml.jackson.databind.ObjectMapper
import com.yausername.youtubedl_android.YoutubeDLException
import com.yausername.youtubedl_android.mapper.VideoInfo
import com.yausername.youtubedl_android.data.local.YoutubeDLRequest
import com.yausername.youtubedl_android.data.local.streams.StreamGobbler
import com.yausername.youtubedl_android.data.local.streams.StreamProcessExtractor
import com.yausername.youtubedl_android.data.remote.YoutubeDLUpdater
import com.yausername.youtubedl_android.domain.UpdateChannel
import com.yausername.youtubedl_android.domain.UpdateStatus
import com.yausername.youtubedl_android.domain.YoutubeDLException
import com.yausername.youtubedl_android.domain.model.YoutubeDLResponse
import com.yausername.youtubedl_android.domain.model.videos.VideoInfo
import com.yausername.youtubedl_common.SharedPrefsHelper
import com.yausername.youtubedl_common.SharedPrefsHelper.update
import com.yausername.youtubedl_common.utils.ZipUtils.unzip
Expand Down Expand Up @@ -243,30 +250,6 @@ object YoutubeDL {
return YoutubeDLUpdater.versionName(appContext)
}

enum class UpdateStatus {
DONE, ALREADY_UP_TO_DATE
}

open class UpdateChannel(val apiUrl: String) {
object STABLE : UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest")
object NIGHTLY :
UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest")

object MASTER :
UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp-master-builds/releases/latest")

companion object {
@JvmField
val _STABLE: STABLE = STABLE

@JvmField
val _NIGHTLY: NIGHTLY = NIGHTLY

@JvmField
val _MASTER: MASTER = MASTER
}
}


const val baseName = "youtubedl-android"
private const val packagesRoot = "packages"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.local

import kotlin.collections.ArrayList
import kotlin.collections.LinkedHashMap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.local

class YoutubeDLRequest {
private val urls: List<String>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.local.streams

interface DownloadProgressCallback {
fun onProgressUpdate(progress: Float, etaInSeconds: Long, line: String?)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.yausername.youtubedl_android.data.local.streams

class DownloadProgressCallbackImpl : DownloadProgressCallback {
override fun onProgressUpdate(progress: Float, etaInSeconds: Long, line: String?) {
TODO("Not yet implemented")
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.local.streams

import android.util.Log
import com.yausername.youtubedl_android.BuildConfig
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.local.streams

import android.util.Log
import com.yausername.youtubedl_android.BuildConfig
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.data.remote

import android.content.Context
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ArrayNode
import com.yausername.youtubedl_android.YoutubeDL.UpdateChannel
import com.yausername.youtubedl_android.YoutubeDL.UpdateStatus
import com.yausername.youtubedl_android.YoutubeDL.getInstance
import com.yausername.youtubedl_android.YoutubeDL
import com.yausername.youtubedl_android.domain.UpdateChannel
import com.yausername.youtubedl_android.domain.UpdateStatus
import com.yausername.youtubedl_android.domain.YoutubeDLException
import com.yausername.youtubedl_common.SharedPrefsHelper
import com.yausername.youtubedl_common.SharedPrefsHelper.update
import org.apache.commons.io.FileUtils
Expand Down Expand Up @@ -45,7 +46,7 @@ internal object YoutubeDLUpdater {
} catch (e: Exception) {
/* if something went wrong restore default version */
FileUtils.deleteQuietly(ytdlpDir)
getInstance().init_ytdlp(appContext, ytdlpDir)
YoutubeDL.init_ytdlp(appContext, ytdlpDir)
throw YoutubeDLException(e)
} finally {
file.delete()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.yausername.youtubedl_android.domain

open class UpdateChannel(val apiUrl: String) {
object STABLE :
UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest")

object NIGHTLY :
UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest")

object MASTER :
UpdateChannel("https://api.github.com/repos/yt-dlp/yt-dlp-master-builds/releases/latest")

companion object {
@JvmField
val _STABLE: STABLE = STABLE

@JvmField
val _NIGHTLY: NIGHTLY = NIGHTLY

@JvmField
val _MASTER: MASTER = MASTER
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.yausername.youtubedl_android.domain

enum class UpdateStatus {
DONE, ALREADY_UP_TO_DATE
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.domain

class YoutubeDLException : Exception {
constructor(message: String?) : super(message) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android
package com.yausername.youtubedl_android.domain.model

class YoutubeDLResponse(
val command: List<String?>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android.mapper
package com.yausername.youtubedl_android.domain.model.videos

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android.mapper
package com.yausername.youtubedl_android.domain.model.videos

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android.mapper
package com.yausername.youtubedl_android.domain.model.videos

import com.fasterxml.jackson.annotation.JsonIgnoreProperties

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.yausername.youtubedl_android.mapper
package com.yausername.youtubedl_android.domain.model.videos

import com.fasterxml.jackson.annotation.JsonIgnoreProperties

Expand Down