Open meder411 opened 7 years ago
Indeed. Your problem is that SubRipItem.start
is a SubRipTime instance which is mutable.
That is why casting as string solves it, because it end up doing a copy of the instance.
To be honest I kinda regret making those mutable, but it's quite of a breaking change so I'm not sure if I should fix it.
I am trying to split subtiltes where there are two speakers that show up in the same frame. In my case this is indicated by newlines and hyphens ('\n-'). I this code snippet to split the subtitles into multiple:
The basic gist is that to format the time I am using a dummy object so that I can take advantage of shifting. For example, a 3-phrase frame over 3 seconds is split 3 ways would be 1 second long for each new frame.
When I create the dummy as above using
start=sub.start
andend=sub.end
and then shift the dummy, it also shifts the original subtitle. I suspect this was not the intended behavior.I found that casting
sub.start
andsub.end
to strings in the assignment (e.g.start=str(sub.start)
) solved the issue. It appears that without the cast, however, I am actually assigning a reference or pointer of some kind rather than the value of the string.