fix: handle None quality in video/audio stream comparison - #2
Open
xiaoyuyu6420 wants to merge 1 commit into
Open
xiaoyuyu6420 wants to merge 1 commit into
xiaoyuyu6420 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
VideoDownloadURLDataDetecter.detect_best_streams()crashes withAttributeError: 'NoneType' object has no attribute 'value'when a stream in the DASH response hasvideo_quality/audio_qualityset toNone.Both comparator functions (
video_stream_cmp/audio_stream_cmp) call.valuedirectly on the quality enums:video_stream_cmp:if s1.video_quality.value != s2.video_quality.value→s1.video_quality.value - s2.video_quality.valueaudio_stream_cmp:return s1.audio_quality.value - s2.audio_quality.valueReproduced on PyPI
bilibili-api-python==17.4.2(detect_best_streamson line 2636), breaking video download/resolution detection for some videos.Fix
Guard both comparators: if either stream's quality is
None, return0before the Dolby/HDR/Hi-Res priority checks.Verification
A/B tested against the released 17.4.2 source with
detect()mocked to return streams carryingNonequality:AttributeError: 'NoneType' object has no attribute 'value'(video.py:2636)detect_best_streams()returns the stream list normallyNo behavior change for streams with valid quality values.