-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Fix downloads of streams with missing MediaFormat #10165
Conversation
8e2daa4
to
d0c1919
Compare
app/src/main/java/org/schabi/newpipe/util/StreamItemAdapter.java
Outdated
Show resolved
Hide resolved
fb23e75
to
2fd8b50
Compare
2fd8b50
to
ba84e7e
Compare
|
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I will push a small commit to improve upon the last comment, and then merge
} | ||
|
||
// extract the file extension / suffix | ||
final String[] p = fileName.split("\\."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say "split this without using a regex" but then stumbled upon this: https://stackoverflow.com/a/60048140
// try to get the format by content type | ||
// some mime types are not unique for every format, those are omitted | ||
final List<MediaFormat> formats = MediaFormat.getAllFromMimeType( | ||
response.getHeader("Content-Type")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
response.getHeader("Content-Type")
will return null if there are no such headers. Fortunately that's not a problem since getAllFromMimeType
works normally with null strings, but it should be changed anyway. The loop below can also be optimized to exit-early as soon as a conflicting media format is found, and also to prevent creating a new list.
Also check for nullity
Kudos, SonarCloud Quality Gate passed! |
What is it?
Description of the changes in your PR
Rertrieve
MediaFormat
s for streams in case the extractor was not able to get them. Sometimes the MediaFormat can be retrieved from the HTTP response header that is fetched when getting the stream size.The dialog now also displays "Unknown Quality" if the quality is unknown. Previously, the media format name was displayed as title and as quality info.
Some code improvements simplifying castings by directly casting in if-conditions using
instanceof
Before/After Screenshots/Screen Record
Fixes the following issue(s)
Relies on the following changes
TeamNewPipe/NewPipeExtractor#1074
APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
Due diligence