Skip to content

Commit

Permalink
v0.1.2 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottDillman committed Jul 1, 2024
1 parent be9fc4e commit e809902
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions srt2docx_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import yaml
from loguru import logger
from pathlib import Path
from datetime import datetime
from datetime import datetime,timedelta
import srt
import pytz
from docx import Document
Expand All @@ -35,14 +35,18 @@
from docx.enum.style import WD_STYLE_TYPE


def round_to_secs(dt: datetime) -> datetime:
"""round to nearest second"""
return timedelta(seconds=int(dt.total_seconds()))

def readFiles(values) -> list:
"""read files from cwd"""
logger.info("Glob in effect is: [{}]".format(values.settings.filetypes.glob))
files = list(Path().glob(values.settings.filetypes.glob))
return files


def createDocument(values) -> docx.Document:
def createDocument(values) -> Document:
"""Create a new docx document"""
document = Document()

Expand Down Expand Up @@ -148,9 +152,13 @@ def buildTable(values, subs, title, document) -> None:

## TODO: fixme
## drop microseconds
row_cells[0].text = str(item.start).split(".")[0]
row_cells[1].text = str(item.end).split(".")[0]
row_cells[2].text = str((item.end - item.start)).split(".")[0]
start = round_to_secs(item.start)
end = round_to_secs(item.end)
row_cells[0].text = str(start)
row_cells[1].text = str(end)


row_cells[2].text = str(round_to_secs(end - start))
row_cells[3].text = "{}".format(item.content)


Expand Down

0 comments on commit e809902

Please sign in to comment.