Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when shifting files #19

Closed
tjavier82 opened this issue Oct 20, 2012 · 7 comments
Closed

Error when shifting files #19

tjavier82 opened this issue Oct 20, 2012 · 7 comments

Comments

@tjavier82
Copy link

I have this subs:

1
00:00:00,058 --> 00:00:02,942
Previously on AMC's
Breaking Bad...

2
00:00:02,984 --> 00:00:04,513
Sooner or later
someone is gonna flip.

If I shift this subs -1 seconds, the resulting file has all this subs at 00:00:00,000

1
00:00:00,000 --> 00:00:00,000
Previously on AMC's
Breaking Bad...

2
00:00:00,000 --> 00:00:00,000
Sooner or later
someone is gonna flip.

3
00:00:00,000 --> 00:00:00,000
I've got nine guys.
They were part of the

I think it should be 00:00:00,000 at first and then -1 second.

@byroot
Copy link
Owner

byroot commented Oct 20, 2012

Using the srt command or the library ?

@tjavier82
Copy link
Author

library

@byroot
Copy link
Owner

byroot commented Oct 20, 2012

I'm sorry but I'm not able to reproduce. Can you show me a code sample that behave like that please ?

@tjavier82
Copy link
Author

$ pip freeze
pysrt==0.4.3
[...]
$ python
Python 2.7.2 (default, Jul 11 2012, 22:02:57)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from pysrt import SubRipFile
subs = SubRipFile.open ('Breaking_Bad_-5x08-_TBA.HDTV.asap.en.srt')
subs.shift(-1)
subs.save('out.srt',encoding='utf-8')
exit()

$ head out.srt
1
00:00:00,000 --> 00:00:00,000
Previously on AMC's
Breaking Bad...

2
00:00:00,000 --> 00:00:00,000
Sooner or later
someone is gonna flip.

@byroot
Copy link
Owner

byroot commented Oct 20, 2012

Ok it's a bit difficult to see but the shift method signature is:

 shift(hours=0, minutes=0, seconds=0, milliseconds=0)

So you ask to shift 1 hour back.
Try this

subs.shift(seconds=-1)

@byroot byroot closed this as completed Oct 20, 2012
@tjavier82
Copy link
Author

You're rigth!

Thanks!

@byroot
Copy link
Owner

byroot commented Oct 20, 2012

You're welcome. It's my bad, I've never took the time to write a proper documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants