@@ -331,7 +331,7 @@ def load_track(
331331 session : Session , track : Metadata .Track , file : Metadata .AudioFile ,
332332 resp_or_url : typing .Union [StorageResolve .StorageResolveResponse ,
333333 str ], preload : bool ,
334- halt_listener : HaltListener ) -> PlayableContentFeeder . LoadedStream :
334+ halt_listener : HaltListener ) -> LoadedStream :
335335 if type (resp_or_url ) is str :
336336 url = resp_or_url
337337 else :
@@ -345,18 +345,17 @@ def load_track(
345345 normalization_data = NormalizationData .read (input_stream )
346346 if input_stream .skip (0xA7 ) != 0xA7 :
347347 raise IOError ("Couldn't skip 0xa7 bytes!" )
348- return PlayableContentFeeder . LoadedStream (
348+ return LoadedStream (
349349 track ,
350350 streamer ,
351351 normalization_data ,
352- PlayableContentFeeder .Metrics (file .file_id , preload ,
353- - 1 if preload else audio_key_time ),
352+ file .file_id , preload , audio_key_time
354353 )
355354
356355 @staticmethod
357356 def load_episode_external (
358357 session : Session , episode : Metadata .Episode ,
359- halt_listener : HaltListener ) -> PlayableContentFeeder . LoadedStream :
358+ halt_listener : HaltListener ) -> LoadedStream :
360359 resp = session .client ().head (episode .external_url )
361360
362361 if resp .status_code != 200 :
@@ -368,11 +367,11 @@ def load_episode_external(
368367
369368 streamer = session .cdn ().stream_external_episode (
370369 episode , url , halt_listener )
371- return PlayableContentFeeder . LoadedStream (
370+ return LoadedStream (
372371 episode ,
373372 streamer ,
374373 None ,
375- PlayableContentFeeder . Metrics ( None , False , - 1 ),
374+ None , False , - 1
376375 )
377376
378377 @staticmethod
@@ -383,7 +382,7 @@ def load_episode(
383382 resp_or_url : typing .Union [StorageResolve .StorageResolveResponse , str ],
384383 preload : bool ,
385384 halt_listener : HaltListener ,
386- ) -> PlayableContentFeeder . LoadedStream :
385+ ) -> LoadedStream :
387386 if type (resp_or_url ) is str :
388387 url = resp_or_url
389388 else :
@@ -397,12 +396,11 @@ def load_episode(
397396 normalization_data = NormalizationData .read (input_stream )
398397 if input_stream .skip (0xA7 ) != 0xA7 :
399398 raise IOError ("Couldn't skip 0xa7 bytes!" )
400- return PlayableContentFeeder . LoadedStream (
399+ return LoadedStream (
401400 episode ,
402401 streamer ,
403402 normalization_data ,
404- PlayableContentFeeder .Metrics (file .file_id , preload ,
405- - 1 if preload else audio_key_time ),
403+ file .file_id , preload , audio_key_time
406404 )
407405
408406
@@ -850,43 +848,41 @@ def resolve_storage_interactive(
850848 storage_resolve_response .ParseFromString (body )
851849 return storage_resolve_response
852850
853- class LoadedStream :
854- episode : Metadata .Episode
855- track : Metadata .Track
856- input_stream : GeneralAudioStream
857- normalization_data : NormalizationData
858- metrics : PlayableContentFeeder .Metrics
859-
860- def __init__ (self , track_or_episode : typing .Union [Metadata .Track ,
861- Metadata .Episode ],
862- input_stream : GeneralAudioStream ,
863- normalization_data : typing .Union [NormalizationData , None ],
864- metrics : PlayableContentFeeder .Metrics ):
865- if type (track_or_episode ) is Metadata .Track :
866- self .track = track_or_episode
867- self .episode = None
868- elif type (track_or_episode ) is Metadata .Episode :
869- self .track = None
870- self .episode = track_or_episode
871- else :
872- raise TypeError ()
873- self .input_stream = input_stream
874- self .normalization_data = normalization_data
875- self .metrics = metrics
851+
852+ class LoadedStream :
853+ episode : Metadata .Episode
854+ track : Metadata .Track
855+ input_stream : GeneralAudioStream
856+ normalization_data : NormalizationData
857+ metrics : Metrics
876858
877859 class Metrics :
878860 file_id : str
879861 preloaded_audio_key : bool
880862 audio_key_time : int
881863
882864 def __init__ (self , file_id : typing .Union [bytes , None ],
883- preloaded_audio_key : bool , audio_key_time : int ):
865+ preloaded_audio_key : bool , audio_key_time : int ):
884866 self .file_id = None if file_id is None else util .bytes_to_hex (
885867 file_id )
886868 self .preloaded_audio_key = preloaded_audio_key
887- self .audio_key_time = audio_key_time
888- if preloaded_audio_key and audio_key_time != - 1 :
889- raise RuntimeError ()
869+ self .audio_key_time = - 1 if preloaded_audio_key else audio_key_time
870+
871+ def __init__ (self , track_or_episode : typing .Union [Metadata .Track , Metadata .Episode ],
872+ input_stream : GeneralAudioStream ,
873+ normalization_data : typing .Union [NormalizationData , None ],
874+ file_id : str , preloaded_audio_key : bool , audio_key_time : int ):
875+ if type (track_or_episode ) is Metadata .Track :
876+ self .track = track_or_episode
877+ self .episode = None
878+ elif type (track_or_episode ) is Metadata .Episode :
879+ self .track = None
880+ self .episode = track_or_episode
881+ else :
882+ raise TypeError ()
883+ self .input_stream = input_stream
884+ self .normalization_data = normalization_data
885+ self .metrics = self .Metrics (file_id , preloaded_audio_key , audio_key_time )
890886
891887
892888class StreamId :
0 commit comments