Closed codenotworking closed 4 years ago
Never mind. I figured it out. I managed to create a simple for
loop, using regex to find the timestamp dictionary keys to return the timestamp dictionary values, while also formatting the timestamp dictionary keys to look like real timestamps:
for key, value in track.to_data().items():
if re.search(r"\d+_\d+_\d+", key):
keyFormatted = key.replace("_", ":")
keyFormatted = f"{keyFormatted[0:-3]}.{keyFormatted[-3:]}"
print(f"{keyFormatted}\t{value}")
This produced:
00:00:00.000 en:00:00:00.000
00:10:41.683 en:00:10:41.683
00:21:07.308 en:00:21:07.308
00:29:12.876 en:00:29:12.876
00:40:12.744 en:00:40:12.744
00:50:50.464 en:00:50:50.464
01:01:02.033 en:01:01:02.033
01:10:15.420 en:01:10:15.420
01:19:59.086 en:01:19:59.086
01:29:40.709 en:01:29:40.709
01:40:10.338 en:01:40:10.338
01:48:35.801 en:01:48:35.801
01:50:49.977 en:01:50:49.977
This is a solution that can be used either way.
it renumbers the chapters in the correct format 01, 02, etc. However, it could be adjusted for use anyway.
https://gist.github.com/jlw4049/88b049951479eb4abd6822d6f2167a6f
I'm trying to figure out how to display the timestamps in the Menu section of a video file. Here's my working basic code:
This produces the following:
I'm looking to extract only the timestamps from the produced dictionary, similar to how MediaInfo itself formats it:
I found a post on Sourceforge where someone asks the developer of MediaInfo for extracting the timestamps. The developer suggested some psuedocode, but I wouldn't even know where to begin:
Any help on how to extract the Menu section's timestamps using python?