Skip to content

Commit

Permalink
Fix empy lists issue
Browse files Browse the repository at this point in the history
That was a mistake
  • Loading branch information
Ichunjo committed Jun 8, 2021
1 parent dae37fd commit 00eb029
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 35 deletions.
6 changes: 3 additions & 3 deletions pyparsebluray/mpls/extension_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ExtensionData(MplsObject):
length: int
data_block_start_address: Optional[int]
nb_ext_data_entries: Optional[int]
ext_data_entries: Optional[List[ExtensionDataEntry]] = []
ext_data_entries: Optional[List[ExtensionDataEntry]]

def load(self):
pos = self._get_pos()
Expand All @@ -40,10 +40,10 @@ def load(self):
ext_data_start_address, = self._unpack_byte(4) # 4 bytes - 32 bits
ext_data_length, = self._unpack_byte(4) # 4 bytes - 32 bits

self.ext_data_entries += [
self.ext_data_entries.append(
ExtensionDataEntry(ext_data_type, ext_data_version,
ext_data_start_address, ext_data_length)
]
)

self.mpls.seek(pos + self.length + 4)

Expand Down
48 changes: 27 additions & 21 deletions pyparsebluray/mpls/play_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@ class STNTable(MplsObject):
nb_seco_video_stream_entries: Optional[int]
nb_seco_pgs_stream_entries: Optional[int]
nb_dv_stream_entries: Optional[int]
prim_video_stream_entries: EntryStreams = []
prim_audio_stream_entries: EntryStreams = []
prim_pgs_stream_entries: EntryStreams = []
seco_pgs_stream_entries: EntryStreams = []
prim_igs_stream_entries: EntryStreams = []
seco_audio_stream_entries: EntryStreams = []
seco_video_stream_entries: EntryStreams = []
dv_stream_entries: EntryStreams = []
prim_video_stream_entries: Optional[EntryStreams]
prim_audio_stream_entries: Optional[EntryStreams]
prim_pgs_stream_entries: Optional[EntryStreams]
seco_pgs_stream_entries: Optional[EntryStreams]
prim_igs_stream_entries: Optional[EntryStreams]
seco_audio_stream_entries: Optional[EntryStreams]
seco_video_stream_entries: Optional[EntryStreams]
dv_stream_entries: Optional[EntryStreams]

stream_entries: Tuple

def load(self):
pos = self._get_pos()
Expand All @@ -157,24 +159,28 @@ def load(self):
self.mpls.read(4) # 4 bytes - 32 bits - Reserved


nbs = [
nbs = (
self.nb_prim_video_stream_entries, self.nb_prim_audio_stream_entries,
self.nb_prim_pgs_stream_entries, self.nb_seco_pgs_stream_entries,
self.nb_prim_igs_stream_entries, self.nb_seco_audio_stream_entries,
self.nb_seco_video_stream_entries, self.nb_dv_stream_entries
]
entries = [
self.prim_video_stream_entries, self.prim_audio_stream_entries,
self.prim_pgs_stream_entries, self.seco_pgs_stream_entries,
self.prim_igs_stream_entries, self.seco_audio_stream_entries,
self.seco_video_stream_entries, self.dv_stream_entries
]

for nb, entry in zip(nbs, entries):
)

__stream_entries: List[EntryStreams] = []

for nb in nbs:
entry_streams: EntryStreams = []
for _ in range(nb):
stream_entry = StreamEntry(self.mpls).load()
stream_attributes = StreamAttributes(self.mpls).load()
entry += [(stream_entry, stream_attributes)]
entry_streams.append((stream_entry, stream_attributes))
__stream_entries.append(entry_streams)

self.prim_video_stream_entries, self.prim_audio_stream_entries, \
self.prim_pgs_stream_entries, self.seco_pgs_stream_entries, \
self.prim_igs_stream_entries, self.seco_audio_stream_entries, \
self.seco_video_stream_entries, self.dv_stream_entries = __stream_entries


self.mpls.seek(pos + self.length + 2)

Expand Down Expand Up @@ -204,7 +210,7 @@ class PlayItem(MplsObject):
still_time: Optional[int]
nb_angles: Optional[int]
misc_flags_3: Optional[int]
angles: Optional[List[Angle]] = []
angles: Optional[List[Angle]]
stn_table: Optional[STNTable]

def load(self):
Expand Down Expand Up @@ -239,7 +245,7 @@ def load(self):
clip_info = self.mpls.read(5).decode('utf-8') # 5 bytes - 40 bits
clip_codec = self.mpls.read(4).decode('utf-8') # 4 bytes - 32 bits
ref, = self._unpack_byte(1) # 1 byte - 8 bits
self.angles += [Angle(clip_info, clip_codec, ref)]
self.angles.append(Angle(clip_info, clip_codec, ref))

self.stn_table = STNTable(self.mpls).load()

Expand Down
8 changes: 4 additions & 4 deletions pyparsebluray/mpls/playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Playlist(MplsObject):
length: int
nb_play_items: Optional[int]
nb_sub_paths: Optional[int]
play_items: Optional[List[PlayItem]] = []
sub_paths: Optional[List[SubPath]] = []
play_items: Optional[List[PlayItem]]
sub_paths: Optional[List[SubPath]]

def load(self):
pos = self._get_pos()
Expand All @@ -28,8 +28,8 @@ def load(self):
self.nb_play_items, = self._unpack_byte(2) # 2 bytes - 16 bits
self.nb_sub_paths, = self._unpack_byte(2) # 2 bytes - 16 bits

self.play_items += [PlayItem(self.mpls).load() for _ in range(self.nb_play_items)]
self.sub_paths += [SubPath(self.mpls).load() for _ in range(self.nb_sub_paths)]
self.play_items = [PlayItem(self.mpls).load() for _ in range(self.nb_play_items)]
self.sub_paths = [SubPath(self.mpls).load() for _ in range(self.nb_sub_paths)]

self.mpls.seek(pos + self.length + 4)

Expand Down
6 changes: 3 additions & 3 deletions pyparsebluray/mpls/playlist_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PlaylistMarks(MplsObject):
"""https://github.com/lw/BluRay/wiki/PlayListMark"""
length: int
nb_playlist_marks: Optional[int]
playlist_marks: Optional[List[PlaylistMark]] = []
playlist_marks: Optional[List[PlaylistMark]]

def load(self):
pos = self._get_pos()
Expand All @@ -36,10 +36,10 @@ def load(self):
entry_espid, = self._unpack_byte(2) # 2 bytes - 16 bits
duration, = self._unpack_byte(4) # 4 bytes - 32 bits

self.playlist_marks += [
self.playlist_marks.append(
PlaylistMark(mark_type, ref_to_play_item_id,
mark_timestamp, entry_espid, duration)
]
)

self.mpls.seek(pos + self.length + 4)

Expand Down
8 changes: 4 additions & 4 deletions pyparsebluray/mpls/sub_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SubPlayItem(MplsObject):
sync_play_item_id: Optional[int]
sync_start_pts: Optional[int]
nb_multi_clip_entries: Optional[int]
multi_clip_entries: Optional[List[MultiClipEntry]] = []
multi_clip_entries: Optional[List[MultiClipEntry]]

def load(self):
pos = self._get_pos()
Expand All @@ -54,7 +54,7 @@ def load(self):
clip_info = self.mpls.read(5).decode('utf-8') # 5 bytes - 40 bits
clip_codec = self.mpls.read(4).decode('utf-8') # 4 bytes - 32 bits
ref, = self._unpack_byte(1) # 1 byte - 8 bits
self.multi_clip_entries += [MultiClipEntry(clip_info, clip_codec, ref)]
self.multi_clip_entries.append(MultiClipEntry(clip_info, clip_codec, ref))

self.mpls.seek(pos + self.length + 2)

Expand All @@ -67,7 +67,7 @@ class SubPath(MplsObject):
sub_path_type: Optional[int]
misc_flags_1: Optional[int]
nb_sub_play_items: Optional[int]
sub_play_items: Optional[List[SubPlayItem]] = []
sub_play_items: Optional[List[SubPlayItem]]

def load(self):
pos = self._get_pos()
Expand All @@ -81,7 +81,7 @@ def load(self):
self.mpls.read(1)
self.nb_sub_play_items, = self._unpack_byte(1) # 1 byte - 8 bits

self.sub_play_items += [SubPlayItem(self.mpls).load() for _ in range(self.nb_sub_play_items)]
self.sub_play_items = [SubPlayItem(self.mpls).load() for _ in range(self.nb_sub_play_items)]

self.mpls.seek(pos + self.length + 4)

Expand Down

0 comments on commit 00eb029

Please sign in to comment.