question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't make the compose() works

See original GitHub issue

To me is impossible to make the composer method work. So I wrote this basic example anda everything works mostly fine for my needs, but the compose don’t. Is There anything wrong with the way I’m using it?

from datetime import timedelta
import srt

td = timedelta(seconds=1)

a = srt.Subtitle(index=1, start=td, end=td, content='Word 1')
b = srt.Subtitle(index=2, start=td, end=td, content='Word 2')

c = [a, b]

print(srt.compose(c))

c = a.to_srt() + b.to_srt()

print("========")
print(c)

print("====")
d = list(srt.parse(c))
print(d)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
stuartjcameroncommented, Jul 21, 2020

The creators of this module may want to adjust the docs as the same example is given there. https://srt.readthedocs.io/en/latest/api.html#srt.compose

>>> from datetime import timedelta
>>> td = timedelta(seconds=1)
>>> subs = [
...     Subtitle(index=1, start=td, end=td, content='x'),
...     Subtitle(index=2, start=td, end=td, content='y'),
... ]
>>> compose(subs)  
'1\n00:00:01,000 --> 00:00:01,000\nx\n\n2\n00:00:01,000 --> ...'

The output shown in the docs will not in fact be produced unless reindex=False is passed.

1reaction
cdowncommented, Jul 20, 2020

It’s filtered because it’s never displayed (end <= start). If you want to just verbatim print the Subtitle objects, you need to pass reindex=False to srt.compose.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why won't my modifiers work in jetpack compose
I'd imported some java.lang thing. Make sure you've got import androidx.compose.ui.Modifier . Hope your solution is something as simple as that ...
Read more >
Can't get compose to work with remote hosts #6059 - GitHub
Description of the issue When following the instructions from Running Compose on a single server I am unable to connect to a remote...
Read more >
Compose link not working. No problem opening messages in ...
Went into Task Mgr to stop CHrome and went back in fresh, Cleared history and temp files, Closed computer and restarted, I have...
Read more >
Thinking in Compose | Jetpack Compose - Android Developers
A simple composable function. Using Compose, you can build your user interface by defining a set of composable functions that take in data...
Read more >
Troubleshooting - Composer
Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found