podverse / podverse-rn

Podverse mobile app written in React Native for iOS, Android, and F-Droid
https://podverse.fm/about
GNU Affero General Public License v3.0
218 stars 36 forks source link

Download error recently on Android for some podcasts #2161

Open EricKerby opened 7 months ago

EricKerby commented 7 months ago

I'm recent weeks I started experiencing what seems like #1736 but on Android and for just some podcast feeds. I've tried logging out and back in on Podverse and unsubscribing and resubscribing to the affected podcasts with no success. Playing a stream works, but downloading an episode quickly fails and shows just "Error" in the My Library Downloads. Downloads of many other podcasts continue working fine.

Podcasts with issue for me are New Heights and The Bobby Bones Show.

Using Podverse 4.16.0 Build 5262 on Android 14 on a Pixel 7

Screenshot_20240418-205222

mitchdowney commented 7 months ago

@EricKerby thanks for creating this. Funny coincidence...I was just made aware of this in our Discord and have been investigating it for the past 10 minutes.

It seems the error is happening because after updating the react-native-background-downloader library in v4.16.0, some episodes are now returning a "too many redirects" error message. I imagine there must be a way for us to increase the number of redirects allowed by the downloader service.

For more context, one of the podcasts with the error is Pod Save America. Here is a link to the mp3 from their RSS feed:

https://pdst.fm/e/chrt.fm/track/479722/arttrk.com/p/CRMDA/claritaspod.com/measure/pscrb.fm/rss/p/stitcher.simplecastaudio.com/9aa1e238-cbed-4305-9808-c9228fc6dd4f/episodes/b0c9a72a-1cb7-4ac9-80a0-36996fc6470f/audio/128/default.mp3?aid=rss_feed&awCollectionId=9aa1e238-cbed-4305-9808-c9228fc6dd4f&awEpisodeId=b0c9a72a-1cb7-4ac9-80a0-36996fc6470f&feed=dxZsm5kX

And I just checked New Heights with Jason and Travis Kelce, and their mp3 looks like:

https://pdst.fm/e/pscrb.fm/rss/p/claritaspod.com/measure/chrt.fm/track/DA31CA/chrt.fm/track/F88GEG/arttrk.com/p/BLPSN/traffic.megaphone.fm/BSN1763591196.mp3?updated=1713367602

When I run curl on these it says 6 redirects.

Anyway, hoping to find a quick solution for increasing the number of redirects allowed.

mitchdowney commented 7 months ago

A fix for this should be in v4.16.1.

mitchdowney commented 7 months ago

My fix was incomplete. I only fixed it for urls prefixed with the pdst.fm domain, but it turns out there are many other redirect tracking troublemaker domains...

The fix I put in was to send pdst.fm mp3 urls to our "url resolving endpoint," then to send the final resolved url to the front-end.

Ideally a more proper fix for this would happen on the client-side, but I have barely any Android skills, which makes it difficult for me to fix. Maybe however the code can be done with just JavaScript and I am overthinking it.

I created https://github.com/kesha-antonov/react-native-background-downloader/issues/15 for @kesha-antonov's library we use for downloading mp3, and it'd be nice if the library handled "too many redirects" itself, but based on the fact no one else has created an issue for it sooner, maybe it's not a common problem people are running into.

Here are more examples of podcast urls that are failing due to "too many redirects":

<enclosure length="46055925" type="audio/mpeg" url="https://dts.podtrac.com/redirect.mp3/chrt.fm/track/8DB4DB/pdst.fm/e/pfx.vpixl.com/6qj4J/nyt.simplecastaudio.com/fa58abbf-ea07-4e56-95be-3c078f65b2f9/episodes/b137d9bd-385b-48c1-ab21-9586b873bd2c/audio/128/default.mp3?aid=rss_feed&awCollectionId=fa58abbf-ea07-4e56-95be-3c078f65b2f9&awEpisodeId=b137d9bd-385b-48c1-ab21-9586b873bd2c&feed=Kctn1RDB"/>

<enclosure length="53529417" type="audio/mpeg" url="https://chrt.fm/track/D1246F/dts.podtrac.com/redirect.mp3/pdst.fm/e/pscrb.fm/rss/p/mgln.ai/e/275/afp-27275-injected.calisto.simplecastaudio.com/aa5424c1-b7ed-4668-a39c-473d31465df6/episodes/8bd8dfdf-8f50-423b-b357-945b24f3ee27/audio/128/default.mp3?aid=rss_feed&awCollectionId=aa5424c1-b7ed-4668-a39c-473d31465df6&awEpisodeId=8bd8dfdf-8f50-423b-b357-945b24f3ee27&feed=bOogzwqU"/>

<enclosure url="https://chtbl.com/track/5899E/podtrac.com/pts/redirect.mp3/pscrb.fm/rss/p/traffic.omny.fm/d/clips/e73c998e-6e60-432f-8610-ae210140c5b1/78d30acb-8463-4c40-a5ae-ae2d0145c9ff/5ba782ff-4a29-4b7c-91d2-b157001878f4/audio.mp3?utm_source=Podcast&in_playlist=d64f756d-6d5e-4fae-b24f-ae280140ad36" length="207216801" type="audio/mpeg"/>

<enclosure url="https://chtbl.com/track/9EE2G/dts.podtrac.com/redirect.mp3/pdst.fm/e/rss.art19.com/episodes/ea42f5e0-9437-425d-b06e-eda7fce5cb10.mp3?rss_browser=BAhJIgtDaHJvbWUGOgZFVA%3D%3D--d05363d83ce333c74f32188013892b2863ad051c" type="audio/mpeg" length="21433782"/>

image

image

lovegaoshi commented 7 months ago

not like podverse will migrate to the RN-fetch-blob family of downloaders, but these ones do work with redirect; also @mitchdowney for a hack try this: fetch with method HEAD and return Response.url (await fetch(url, {method": HEAD"})).url I use them in separate https://github.com/lovegaoshi/azusa-player-mobile/blob/dev/src/utils/mediafetch/headRequest.ts#L8 https://github.com/lovegaoshi/azusa-player-mobile/blob/master/src/utils/mediafetch/b23tv.ts dunno if this overhead would be worth it, since not all have this redirect problem. but the urls you quoted works with this hack

mitchdowney commented 6 months ago

@lovegaoshi thanks for your help. I didn't realize it was so easy to follow redirects with a HEAD request and axios (which we're using in PV). I started by trying to use a follow-redirects library but found it was Node.js only.

Anyway, I think I have a fix implemented for Podverse Android in v4.16.2.

mitchdowney commented 6 months ago

This should be fixed for good in v4.16.2 🤞

mitchdowney commented 6 months ago

More download errors, this time for BBC podcasts 😩

When I check Logcat, it looks like they have an insecure URL somewhere in their redirects, and it results in a "cleartext not allowed" error.

We have an API service that is supposed to get the HTTPS version of URLs, but it apparently isn't working for this case.

mitchdowney commented 6 months ago

New fix attempted in v4.16.3.

archtur commented 5 months ago

I

  1. reinstalled Podverse 4.16.3 from F-Droid right now,
  2. disabled auto downoads for new podcasts
  3. added a Podcast (https://podverse.fm/podcast/3JERV6OYpu)
  4. clicked on download of the first Episode

The download is simply stucking. Screenshot_20240530-100018_Trebuchet

The direct playback is working.

lovegaoshi commented 5 months ago

i cant reproduce with the same podcast.

is this reproducible and could u post adb logs and/or willing to use android studio or a debug build to pin down the issue?

archtur commented 5 months ago

In General yes.

Connecting via adb is no issue I think. Is it enough to connect via USB and run adb logcat ...? If yes it would be great if you could provide me the exact command with filters.

For the debugging approach: it depends how much time I need for installing Android Studio (manjaro linux - I expect it is fast) and for debugging (I never did this).

Regarding debug builds: I will not use binary packages from everyone. If they are build by the official maintainer ( @mitchdowney ) it would be ok.