Refactor unnecessary else / elif when if block has a return statement
This commit is contained in:
committed by
GitHub
parent
86ae06de51
commit
bd2a63653b
@@ -153,7 +153,7 @@ class AbsChunkedInputStream(InputStream, HaltListener):
|
||||
length: int = None) -> int:
|
||||
if b is None and offset is None and length is None:
|
||||
return self.internal_read()
|
||||
elif not (b is not None and offset is not None and length is not None):
|
||||
if not (b is not None and offset is not None and length is not None):
|
||||
raise TypeError()
|
||||
|
||||
if self.closed:
|
||||
|
||||
@@ -45,11 +45,10 @@ class AudioKeyManager(PacketsReceiver):
|
||||
if key is None:
|
||||
if retry:
|
||||
return self.get_audio_key(gid, file_id, False)
|
||||
else:
|
||||
raise RuntimeError(
|
||||
"Failed fetching audio key! gid: {}, fileId: {}".format(
|
||||
Utils.Utils.bytes_to_hex(gid),
|
||||
Utils.Utils.bytes_to_hex(file_id)))
|
||||
raise RuntimeError(
|
||||
"Failed fetching audio key! gid: {}, fileId: {}".format(
|
||||
Utils.Utils.bytes_to_hex(gid),
|
||||
Utils.Utils.bytes_to_hex(file_id)))
|
||||
|
||||
return key
|
||||
|
||||
|
||||
@@ -87,9 +87,8 @@ class PlayableContentFeeder:
|
||||
if track is not None:
|
||||
return CdnFeedHelper.load_track(self.session, track, file,
|
||||
resp, preload, halt_lister)
|
||||
else:
|
||||
return CdnFeedHelper.load_episode(self.session, episode, file,
|
||||
resp, preload, halt_lister)
|
||||
return CdnFeedHelper.load_episode(self.session, episode, file,
|
||||
resp, preload, halt_lister)
|
||||
elif resp.result == StorageResolve.StorageResolveResponse.Result.STORAGE:
|
||||
if track is None:
|
||||
# return StorageFeedHelper
|
||||
|
||||
@@ -79,9 +79,8 @@ class CdnManager:
|
||||
self._LOGGER.debug("Fetched CDN url for {}: {}".format(
|
||||
Utils.bytes_to_hex(file_id), url))
|
||||
return url
|
||||
else:
|
||||
raise CdnManager.CdnException(
|
||||
"Could not retrieve CDN url! result: {}".format(proto.result))
|
||||
raise CdnManager.CdnException(
|
||||
"Could not retrieve CDN url! result: {}".format(proto.result))
|
||||
|
||||
class CdnException(Exception):
|
||||
def __init__(self, ex):
|
||||
@@ -228,8 +227,7 @@ class CdnManager:
|
||||
if self._streamId.is_episode():
|
||||
return "episode_gid: {}".format(
|
||||
self._streamId.get_episode_gid())
|
||||
else:
|
||||
return "file_id: {}".format(self._streamId.get_file_id())
|
||||
return "file_id: {}".format(self._streamId.get_file_id())
|
||||
|
||||
def decrypt_time_ms(self) -> int:
|
||||
return self._audioDecrypt.decrypt_time_ms()
|
||||
|
||||
@@ -10,18 +10,17 @@ class SuperAudioFormat(enum.Enum):
|
||||
@staticmethod
|
||||
def get(audio_format: Metadata.AudioFile.Format):
|
||||
if audio_format == Metadata.AudioFile.Format.OGG_VORBIS_96 or \
|
||||
audio_format == Metadata.AudioFile.Format.OGG_VORBIS_160 or \
|
||||
audio_format == Metadata.AudioFile.Format.OGG_VORBIS_320:
|
||||
audio_format == Metadata.AudioFile.Format.OGG_VORBIS_160 or \
|
||||
audio_format == Metadata.AudioFile.Format.OGG_VORBIS_320:
|
||||
return SuperAudioFormat.VORBIS
|
||||
elif audio_format == Metadata.AudioFile.Format.MP3_256 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_320 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_160 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_96 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_160_ENC:
|
||||
if audio_format == Metadata.AudioFile.Format.MP3_256 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_320 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_160 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_96 or \
|
||||
audio_format == Metadata.AudioFile.Format.MP3_160_ENC:
|
||||
return SuperAudioFormat.MP3
|
||||
elif audio_format == Metadata.AudioFile.Format.AAC_24 or \
|
||||
audio_format == Metadata.AudioFile.Format.AAC_48 or \
|
||||
audio_format == Metadata.AudioFile.Format.AAC_24_NORM:
|
||||
if audio_format == Metadata.AudioFile.Format.AAC_24 or \
|
||||
audio_format == Metadata.AudioFile.Format.AAC_48 or \
|
||||
audio_format == Metadata.AudioFile.Format.AAC_24_NORM:
|
||||
return SuperAudioFormat.AAC
|
||||
else:
|
||||
raise RuntimeError("Unknown audio format: {}".format(audio_format))
|
||||
raise RuntimeError("Unknown audio format: {}".format(audio_format))
|
||||
|
||||
Reference in New Issue
Block a user