added ability to upgrade to nightly builds of yt-dlp
This commit is contained in:
parent
2bfb998e4a
commit
5ea0c4654f
7 changed files with 33 additions and 5 deletions
|
|
@ -320,7 +320,7 @@
|
|||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/drag_handle/baseline_drag_handle_24.xml" />
|
||||
<entry key="url" value="file:/$USER_HOME$/AppData/Local/Android/Sdk/icons/material/materialicons/nights_stay/baseline_nights_stay_24.xml" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
|
|
@ -330,7 +330,7 @@
|
|||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="outputName" value="ic_handle" />
|
||||
<entry key="outputName" value="ic_nightly" />
|
||||
<entry key="sourceFile" value="C:\Users\denis\Desktop\adaptiveproduct_youtube_foreground_color_108 (1).svg" />
|
||||
</map>
|
||||
</option>
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
private var audioQuality: SeekBarPreference? = null
|
||||
private var videoQuality: ListPreference? = null
|
||||
private var updateYTDL: Preference? = null
|
||||
private var updateNightlyYTDL: SwitchPreferenceCompat? = null
|
||||
private var updateApp: SwitchPreferenceCompat? = null
|
||||
private var version: Preference? = null
|
||||
private var updateUtil: UpdateUtil? = null
|
||||
|
|
@ -69,6 +70,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
audioQuality = findPreference("audio_quality")
|
||||
videoQuality = findPreference("video_quality")
|
||||
updateYTDL = findPreference("update_ytdl")
|
||||
updateNightlyYTDL = findPreference("nightly_ytdl")
|
||||
updateApp = findPreference("update_app")
|
||||
version = findPreference("version")
|
||||
version!!.summary = BuildConfig.VERSION_NAME
|
||||
|
|
@ -97,6 +99,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
editor.putString("video_format", videoFormat!!.value)
|
||||
editor.putInt("audio_quality", audioQuality!!.value)
|
||||
editor.putString("video_quality", videoQuality!!.value)
|
||||
editor.putBoolean("nightly_ytdl", updateNightlyYTDL!!.isChecked)
|
||||
editor.putBoolean("update_app", updateApp!!.isChecked)
|
||||
editor.apply()
|
||||
}
|
||||
|
|
@ -252,6 +255,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
updateUtil!!.updateYoutubeDL()
|
||||
true
|
||||
}
|
||||
updateNightlyYTDL!!.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
||||
val enable = newValue as Boolean
|
||||
editor.putBoolean("nightly_ytdl", enable)
|
||||
editor.apply()
|
||||
true
|
||||
}
|
||||
updateApp!!.onPreferenceChangeListener =
|
||||
Preference.OnPreferenceChangeListener { _: Preference?, newValue: Any ->
|
||||
val enable = newValue as Boolean
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.deniscerri.ytdlnis.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.DownloadManager
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
|
|
@ -29,6 +30,7 @@ class UpdateUtil(var context: Context) {
|
|||
private val tag = "UpdateUtil"
|
||||
private val downloadManager: DownloadManager = context.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
private val ytdlpNightly = "https://api.github.com/repos/ytdl-patched/yt-dlp/releases/latest"
|
||||
|
||||
fun updateApp(): Boolean {
|
||||
if (updatingApp) {
|
||||
|
|
@ -140,6 +142,8 @@ class UpdateUtil(var context: Context) {
|
|||
}
|
||||
|
||||
fun updateYoutubeDL() {
|
||||
val sharedPreferences =
|
||||
context.getSharedPreferences("root_preferences", Activity.MODE_PRIVATE)
|
||||
if (updatingYTDL) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
|
|
@ -156,7 +160,7 @@ class UpdateUtil(var context: Context) {
|
|||
updatingYTDL = true
|
||||
val disposable = Observable.fromCallable {
|
||||
YoutubeDL.getInstance().updateYoutubeDL(
|
||||
context
|
||||
context, if (sharedPreferences.getBoolean("nightly_ytdl", false) ) ytdlpNightly else null
|
||||
)
|
||||
}
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
|
|
|
|||
6
app/src/main/res/drawable/ic_nightly.xml
Normal file
6
app/src/main/res/drawable/ic_nightly.xml
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<vector android:height="24dp"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="?android:colorAccent" android:pathData="M11.1,12.08C8.77,7.57 10.6,3.6 11.63,2.01C6.27,2.2 1.98,6.59 1.98,12c0,0.14 0.02,0.28 0.02,0.42C2.62,12.15 3.29,12 4,12c1.66,0 3.18,0.83 4.1,2.15C9.77,14.63 11,16.17 11,18c0,1.52 -0.87,2.83 -2.12,3.51c0.98,0.32 2.03,0.5 3.11,0.5c3.5,0 6.58,-1.8 8.37,-4.52C18,17.72 13.38,16.52 11.1,12.08z"/>
|
||||
<path android:fillColor="?android:colorAccent" android:pathData="M7,16l-0.18,0C6.4,14.84 5.3,14 4,14c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.62,0 2.49,0 3,0c1.1,0 2,-0.9 2,-2C9,16.9 8.1,16 7,16z"/>
|
||||
</vector>
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
<string name="video_directory">Video Folder</string>
|
||||
<string name="updating">Updating</string>
|
||||
<string name="ytdl_update_hint">Useful if you have problems downloading</string>
|
||||
<string name="update_ytdl">Install new version of youtube-dl</string>
|
||||
<string name="update_ytdl">Install new version of yt-dlp</string>
|
||||
<string name="about">About</string>
|
||||
<string name="source_code">Source Code</string>
|
||||
<string name="search_hint">Search from YouTube</string>
|
||||
|
|
@ -166,4 +166,5 @@
|
|||
<string name="logs">Logs</string>
|
||||
<string name="commands">Commands</string>
|
||||
<string name="date_added">Date added</string>
|
||||
<string name="update_ytdl_nightly">Download Nightly Version of yt-dlp</string>
|
||||
</resources>
|
||||
|
|
@ -171,6 +171,13 @@
|
|||
app:summary="@string/ytdl_update_hint"
|
||||
app:title="@string/update_ytdl" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
app:icon="@drawable/ic_nightly"
|
||||
app:key="nightly_ytdl"
|
||||
android:title="@string/update_ytdl_nightly"
|
||||
/>
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="true"
|
||||
android:icon="@drawable/ic_update_app"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ buildscript {
|
|||
commonsIoVer = '2.5'
|
||||
// supports java 1.6
|
||||
commonsCompressVer = '1.12'
|
||||
youtubedlAndroidVer = "a3b971724d"
|
||||
youtubedlAndroidVer = "970b819246"
|
||||
workVer = "2.8.0"
|
||||
composeVer = "1.4.0-alpha02"
|
||||
kotlinVer = "1.7.21"
|
||||
|
|
|
|||
Loading…
Reference in a new issue