Skip to content

Commit

Permalink
remove short playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
Guymer committed Jul 27, 2024
1 parent 6e92339 commit fc7bdc6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pyguymer3/media/return_dict_of_bluray_playlistsToStreams.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

# Define function ...
def return_dict_of_bluray_playlistsToStreams(dname, /):
def return_dict_of_bluray_playlistsToStreams(dname, /, *, time_threshold = 60.0):
"""
This function uses the list of MPLS files to obtain all of the possible
playlists in a Blu-ray, then it calls "parse_MPLS_file" on each file to
Expand Down Expand Up @@ -40,5 +40,21 @@ def return_dict_of_bluray_playlistsToStreams(dname, /):
)
)

# Loop over playlists ...
for iPlaylist in list(ans.keys()):
# Initialize total duration ...
totDuration = 0.0 # [s]

# Loop over streams ...
for (_, duration) in ans[iPlaylist]:
# Increment total duration ...
totDuration += duration # [s]

# Delete information if this playlist is not worthwhile (by default,
# "worthwhile" is defined as ≥1 minute) ...
if totDuration < time_threshold:
del ans[iPlaylist]
continue

# Return answer ...
return ans

0 comments on commit fc7bdc6

Please sign in to comment.