Fixes according to SonerLint

This commit is contained in:
kokarare1212
2021-07-31 20:42:13 +09:00
parent 3f81de1610
commit bee0ad3ec1
14 changed files with 57 additions and 59 deletions

View File

@@ -3,8 +3,8 @@ from librespot.proto import Metadata_pb2 as Metadata
class StreamId:
file_id: bytes = None
episode_gid: bytes = None
file_id: bytes
episode_gid: bytes
def __init__(self,
file: Metadata.AudioFile = None,

View File

@@ -29,7 +29,7 @@ if typing.TYPE_CHECKING:
class CdnManager:
_LOGGER: logging = logging.getLogger(__name__)
_session: Session = None
_session: Session
def __init__(self, session: Session):
self._session = session
@@ -118,14 +118,14 @@ class CdnManager:
self._headers = headers
class CdnUrl:
_cdnManager = None
_fileId: bytes
__cdnManager = None
__fileId: bytes
_expiration: int
_url: str
def __init__(self, cdn_manager, file_id: bytes, url: str):
self._cdnManager: CdnManager = cdn_manager
self._fileId = file_id
self.__cdnManager: CdnManager = cdn_manager
self.__fileId = file_id
self.set_url(url)
def url(self):
@@ -133,14 +133,14 @@ class CdnManager:
return self._url
if self._expiration <= int(time.time() * 1000) + 5 * 60 * 1000:
self._url = self._cdnManager.get_audio_url(self._fileId)
self._url = self.__cdnManager.get_audio_url(self.__fileId)
return self.url
def set_url(self, url: str):
self._url = url
if self._fileId is not None:
if self.__fileId is not None:
token_url = urllib.parse.urlparse(url)
token_query = urllib.parse.parse_qs(token_url.query)
token_list = token_query.get("__token__")
@@ -163,7 +163,7 @@ class CdnManager:
if expire_at is None:
self._expiration = -1
self._cdnManager._LOGGER.warning(
self.__cdnManager._LOGGER.warning(
"Invalid __token__ in CDN url: {}".format(url))
return
@@ -173,8 +173,8 @@ class CdnManager:
i = token_url.query.index("_")
except ValueError:
self._expiration = -1
self._cdnManager._LOGGER.warning(
"Couldn't extract expiration, invalid parameter in CDN url: "
self.__cdnManager._LOGGER.warning(
"Couldn't extract expiration, invalid parameter in CDN url: {}"
.format(url))
return
@@ -187,19 +187,19 @@ class CdnManager:
GeneralAudioStream.GeneralAudioStream,
GeneralWritableStream.GeneralWritableStream,
):
_session: Session = None
_streamId: StreamId.StreamId = None
_session: Session
_streamId: StreamId.StreamId
_executorService = concurrent.futures.ThreadPoolExecutor()
_audioFormat: SuperAudioFormat = None
_audioDecrypt: AudioDecrypt = None
_audioFormat: SuperAudioFormat
_audioDecrypt: AudioDecrypt
_cdnUrl = None
_size: int
_buffer: typing.List[bytearray]
_available: typing.List[bool]
_requested: typing.List[bool]
_chunks: int
_internalStream: CdnManager.Streamer.InternalStream = None
_haltListener: HaltListener = None
_internalStream: CdnManager.Streamer.InternalStream
_haltListener: HaltListener
def __init__(
self,

View File

@@ -31,7 +31,7 @@ class AesAudioDecrypt(AudioDecrypt):
cipher = None
decrypt_count = 0
decrypt_total_time = 0
key: bytes = None
key: bytes
def __init__(self, key: bytes):
self.key = key
@@ -57,7 +57,7 @@ class AesAudioDecrypt(AudioDecrypt):
iv += self.iv_diff
self.decrypt_total_time += time.time_ns()
self.decrypt_total_time += time.time_ns() - start
self.decrypt_count += 1
return new_buffer