Skip to content

Commit

Permalink
6.5.3 commit
Browse files Browse the repository at this point in the history
  • Loading branch information
XilinJia committed Sep 3, 2024
1 parent c29eb0b commit b7f17b9
Show file tree
Hide file tree
Showing 14 changed files with 966 additions and 1,004 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ While podcast subscriptions' OPML files (from AntennaPod or any other sources) c
* default video player mode setting in preferences
* when video mode is set to audio only, click on image on audio player on a video episode brings up the normal player detailed view
* "Prefer streaming over download" is now on setting of individual feed
* added setting in individual feed to play audio only for video feeds,
* an added benefit for setting it enables Youtube media to only stream audio content, saving bandwidth.
* this differs from switching to "Audio only" on each episode, in which case, video is also streamed
* Multiple queues can be used: 5 queues are provided by default, user can rename or add up to 10 queues
* on app startup, the most recently updated queue is set to curQueue
* any episodes can be easily added/moved to the active or any designated queues
Expand Down Expand Up @@ -100,10 +103,11 @@ While podcast subscriptions' OPML files (from AntennaPod or any other sources) c
* on action bar of FeedEpisodes view there is a direct access to Queue
* Long-press filter button in FeedEpisodes view enables/disables filters without changing filter settings
* History view shows time of last play, and allows filters and sorts

### Podcast/Episode

* New share notes menu option on various episode views
* Every feed can be associated with a queue allowing downloaded media to be added to the queue
* Every feed (podcast) can be associated with a queue allowing downloaded media to be added to the queue
* FeedInfo view offers a link for direct search of feeds related to author
* FeedInfo view has button showing number of episodes to open the FeedEpisodes view
* FeedInfo view has feed setting in the header
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ android {
testApplicationId "ac.mdiq.podcini.tests"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

versionCode 3020236
versionName "6.5.2"
versionCode 3020237
versionName "6.5.3"

applicationId "ac.mdiq.podcini.R"
def commit = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
package ac.mdiq.podcini.net.download

import ac.mdiq.podcini.net.download.service.PodciniHttpClient.UserAgentInterceptor
import ac.mdiq.podcini.storage.algorithms.InfoCache
import ac.mdiq.podcini.util.Logd
import ac.mdiq.podcini.util.config.ClientConfig
import ac.mdiq.vista.extractor.downloader.Downloader
import ac.mdiq.vista.extractor.downloader.Request
import ac.mdiq.vista.extractor.downloader.Response
import ac.mdiq.vista.extractor.exceptions.ReCaptchaException
import android.content.Context
import android.net.TrafficStats
import androidx.preference.PreferenceManager
import okhttp3.Cache
import okhttp3.Interceptor
import okhttp3.Interceptor.Chain
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request.Builder
import okhttp3.RequestBody
import java.io.File
import java.io.IOException
import java.util.*
import java.util.concurrent.TimeUnit
import java.util.stream.Collectors
import java.util.stream.Stream

class VistaDownloaderImpl private constructor(builder: OkHttpClient.Builder) : Downloader() {
class VistaDownloaderImpl private constructor(val builder: OkHttpClient.Builder) : Downloader() {
private val mCookies: MutableMap<String, String> = HashMap()
private val client: OkHttpClient = builder
.readTimeout(30, TimeUnit.SECONDS)
// .cache(Cache(File(context.getExternalCacheDir(), "okhttp"), 16 * 1024 * 1024))
.build()
private val client: OkHttpClient
get() {
builder.readTimeout(30, TimeUnit.SECONDS)
builder.networkInterceptors().add(object : Interceptor {
override fun intercept(chain: Chain): okhttp3.Response {
TrafficStats.setThreadStatsTag(Thread.currentThread().id.toInt())
return chain.proceed(chain.request())
}
} )
return builder.build()
}

private fun getCookies(url: String): String {
val youtubeCookie = if (url.contains(YOUTUBE_DOMAIN)) getCookie(YOUTUBE_RESTRICTED_MODE_COOKIE_KEY) else null

// Recaptcha cookie is always added TODO: not sure if this is necessary
return Stream.of(youtubeCookie, getCookie("recaptcha_cookies"))
.filter { obj: String? -> Objects.nonNull(obj) }
Expand Down Expand Up @@ -73,11 +81,8 @@ class VistaDownloaderImpl private constructor(builder: OkHttpClient.Builder) : D
try {
val response = head(url)
return response.getHeader("Content-Length")!!.toLong()
} catch (e: NumberFormatException) {
throw IOException("Invalid content length", e)
} catch (e: ReCaptchaException) {
throw IOException(e)
}
} catch (e: NumberFormatException) { throw IOException("Invalid content length", e)
} catch (e: ReCaptchaException) { throw IOException(e) }
}

@Throws(IOException::class, ReCaptchaException::class)
Expand Down Expand Up @@ -115,10 +120,8 @@ class VistaDownloaderImpl private constructor(builder: OkHttpClient.Builder) : D
response.close()
throw ReCaptchaException("reCaptcha Challenge requested", url)
}

val body = response.body
val responseBodyToReturn: String? = body?.string()

val latestUrl = response.request.url.toString()
return Response(response.code, response.message, response.headers.toMultimap(), responseBodyToReturn, latestUrl)
} catch (e: Throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,15 @@ object PodciniHttpClient {
init {
try {
var sslContext: SSLContext

try {
sslContext = SSLContext.getInstance("TLSv1.3")
try { sslContext = SSLContext.getInstance("TLSv1.3")
} catch (e: NoSuchAlgorithmException) {
e.printStackTrace()
// In the play flavor (security provider can vary), some devices only support TLSv1.2.
sslContext = SSLContext.getInstance("TLSv1.2")
}

sslContext.init(null, arrayOf(trustManager), null)
factory = sslContext.socketFactory
} catch (e: GeneralSecurityException) {
e.printStackTrace()
}
} catch (e: GeneralSecurityException) { e.printStackTrace() }
}

override fun getDefaultCipherSuites(): Array<String> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,8 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP
if (streamurl != null) {
val media = curMedia
if (media is EpisodeMedia) {
val deferred = CoroutineScope(Dispatchers.IO).async { setDataSource(metadata, media) }
runBlocking { deferred.await() }
val deferred = CoroutineScope(Dispatchers.IO).async { setDataSource(metadata, media) }
if (startWhenPrepared) runBlocking { deferred.await() }
// val preferences = media.episodeOrFetch()?.feed?.preferences
// setDataSource(metadata, streamurl, preferences?.username, preferences?.password)
} else setDataSource(metadata, streamurl, null, null)
Expand Down Expand Up @@ -805,14 +805,16 @@ class LocalMediaPlayer(context: Context, callback: MediaPlayerCallback) : MediaP
}

private fun initLoudnessEnhancer(audioStreamId: Int) {
val newEnhancer = LoudnessEnhancer(audioStreamId)
val oldEnhancer = loudnessEnhancer
if (oldEnhancer != null) {
newEnhancer.setEnabled(oldEnhancer.enabled)
if (oldEnhancer.enabled) newEnhancer.setTargetGain(oldEnhancer.targetGain.toInt())
oldEnhancer.release()
runOnIOScope {
val newEnhancer = LoudnessEnhancer(audioStreamId)
val oldEnhancer = loudnessEnhancer
if (oldEnhancer != null) {
newEnhancer.setEnabled(oldEnhancer.enabled)
if (oldEnhancer.enabled) newEnhancer.setTargetGain(oldEnhancer.targetGain.toInt())
oldEnhancer.release()
}
loudnessEnhancer = newEnhancer
}
loudnessEnhancer = newEnhancer
}

fun cleanup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import android.os.Build.VERSION_CODES
import android.service.quicksettings.TileService
import android.util.Log
import android.view.KeyEvent
import android.view.KeyEvent.KEYCODE_MEDIA_STOP
import android.view.ViewConfiguration
import android.webkit.URLUtil
import android.widget.Toast
Expand Down Expand Up @@ -579,7 +580,7 @@ class PlaybackService : MediaLibraryService() {
override fun onMediaButtonEvent(mediaSession: MediaSession, controller: MediaSession.ControllerInfo, intent: Intent): Boolean {
val keyEvent = if (Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) intent.extras!!.getParcelable(EXTRA_KEY_EVENT, KeyEvent::class.java)
else intent.extras!!.getParcelable(EXTRA_KEY_EVENT) as? KeyEvent
Log.d(TAG, "onMediaButtonEvent ${keyEvent?.keyCode}")
Logd(TAG, "onMediaButtonEvent ${keyEvent?.keyCode}")

if (keyEvent != null && keyEvent.action == KeyEvent.ACTION_DOWN && keyEvent.repeatCount == 0) {
val keyCode = keyEvent.keyCode
Expand Down Expand Up @@ -681,6 +682,7 @@ class PlaybackService : MediaLibraryService() {
}

fun recreateMediaPlayer() {
Logd(TAG, "recreateMediaPlayer")
val media = curMedia
var wasPlaying = false
if (mPlayer != null) {
Expand All @@ -691,6 +693,7 @@ class PlaybackService : MediaLibraryService() {
mPlayer = CastPsmp.getInstanceIfConnected(this, mediaPlayerCallback)
if (mPlayer == null) mPlayer = LocalMediaPlayer(applicationContext, mediaPlayerCallback) // Cast not supported or not connected

Logd(TAG, "recreateMediaPlayer wasPlaying: $wasPlaying")
if (media != null) mPlayer!!.playMediaObject(media, !media.localFileAvailable(), wasPlaying, true)
isCasting = mPlayer!!.isCasting()
}
Expand Down Expand Up @@ -788,7 +791,7 @@ class PlaybackService : MediaLibraryService() {
handleKeycode(keycode, !hardwareButton)
return super.onStartCommand(intent, flags, startId)
}
keyEvent != null && keyEvent.keyCode != -1 -> {
keyEvent?.keyCode == KEYCODE_MEDIA_STOP -> {
Logd(TAG, "onStartCommand Received button event: ${keyEvent.keyCode}")
handleKeycode(keyEvent.keyCode, !hardwareButton)
return super.onStartCommand(intent, flags, startId)
Expand Down
Loading

0 comments on commit b7f17b9

Please sign in to comment.