Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions arib/ass.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@
file.

"""
from pathlib import Path
from enum import Enum
import copy
import re
import unicodedata
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from typing import List
import unicodedata

import arib.code_set as code_set
import arib.control_characters as control_characters
import re
from arib.arib_exceptions import FileOpenError
from arib.drcs_decoder import drcs_unpack_to_bitmap
from arib.drcs_cache import DrcsGlyph
from arib.drcs_decoder import drcs_unpack_to_bitmap


# DRCS drawing support
Expand Down
21 changes: 9 additions & 12 deletions arib/autosub.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,19 @@
embedded in MPEG Transport Stream data.

"""
from arib.bing import translate
import arib.code_set as code_set
import arib.control_characters as control_characters
import argparse
import codecs
import copy
import os
import re

import os
import argparse
import copy
from arib.closed_caption import next_data_unit
from arib.closed_caption import StatementBody
from arib.mpeg.ts import next_ts_packet
from arib.mpeg.ts import PESPacket
import arib.code_set as code_set
import arib.control_characters as control_characters
from arib.bing import translate
from arib.closed_caption import StatementBody, next_data_unit
from arib.data_group import DataGroup
from arib.secret_key import SECRET_KEY
from arib.secret_key import CLIENT_ID
from arib.mpeg.ts import PESPacket, next_ts_packet
from arib.secret_key import CLIENT_ID, SECRET_KEY


class Pos(object):
Expand Down
3 changes: 2 additions & 1 deletion arib/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"""
import argparse
import json
import requests
import urllib

import requests


def translate(text, from_language="ja", to_language="en", client_id="", secret_key=""):
if not secret_key:
Expand Down
14 changes: 8 additions & 6 deletions arib/closed_caption.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

from arib import read
from arib.decoder import Decoder
from arib.drcs_cache import DRCS_CACHE
from arib.drcs_cache import DrcsGlyph
from arib.drcs_cache import drcs_set_from_font_id_byte
from arib.drcs_cache import normalize_94
from arib.drcs_cache import is_94_byte
from arib.drcs_cache import drcs0_pack
from arib.drcs_cache import (
DRCS_CACHE,
DrcsGlyph,
drcs0_pack,
drcs_set_from_font_id_byte,
is_94_byte,
normalize_94,
)

DEBUG = False
DRCS_DEBUG = False
Expand Down
6 changes: 2 additions & 4 deletions arib/code_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@

"""

from arib.arib_exceptions import UnimplimentedError
from arib import read
from arib.drcs_cache import DRCS_CACHE
from arib.drcs_cache import normalize_94
from arib.drcs_cache import drcs0_pack
from arib.arib_exceptions import UnimplimentedError
from arib.drcs_cache import DRCS_CACHE, drcs0_pack, normalize_94

DEBUG = False

Expand Down
3 changes: 1 addition & 2 deletions arib/control_characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
"""

from arib import read
from arib.code_set import code_set_handler_from_final_byte
from arib.code_set import in_code_set_table
from arib.arib_exceptions import DecodingError
from arib.code_set import code_set_handler_from_final_byte, in_code_set_table

DEBUG = False

Expand Down
7 changes: 3 additions & 4 deletions arib/data_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@

"""
import sys
from arib import read
from arib.read import EOFError
import traceback

from arib.closed_caption import CaptionStatementData
from arib.closed_caption import CaptionManagementData
from arib import read
from arib.closed_caption import CaptionManagementData, CaptionStatementData
from arib.read import EOFError

DEBUG = False

Expand Down
6 changes: 2 additions & 4 deletions arib/decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@

"""

from arib import read
from arib.control_characters import is_control_character
from arib.control_characters import handle_control_character
import arib.control_characters as control_char
from arib import code_set
from arib import code_set, read
from arib.arib_exceptions import DecodingError
from arib.control_characters import handle_control_character, is_control_character

DEBUG = False

Expand Down
7 changes: 4 additions & 3 deletions arib/drcs_cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from dataclasses import dataclass
from typing import Tuple, Optional
from collections import OrderedDict
import threading
from collections import OrderedDict
from dataclasses import dataclass
from typing import Optional, Tuple

from arib import read


Expand Down
10 changes: 3 additions & 7 deletions arib/es_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,17 @@
DATE: Saturday January 14th 2017

"""
import sys
import argparse
import sys
import traceback

from pathlib import Path


from arib.closed_caption import next_data_unit
from arib.closed_caption import StatementBody
import arib.code_set as code_set
import arib.control_characters as control_characters
from arib.data_group import next_data_group

# print out some additional info for DRCS values
from arib.closed_caption import set_DRCS_debug
from arib.closed_caption import StatementBody, next_data_unit, set_DRCS_debug
from arib.data_group import next_data_group

set_DRCS_debug(True)

Expand Down
6 changes: 3 additions & 3 deletions arib/mpeg/ts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
DATE: Thursday, October 20th 2016

"""
import os
import sys
import argparse
import struct

# memorymap file on 64 bit systems
import mmap
import os
import struct
import sys


class ES:
Expand Down
8 changes: 4 additions & 4 deletions arib/srt.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path
from enum import Enum
import sys
import math
from typing import Optional, Union, Callable, Dict, Any
import re
import sys
from enum import Enum
from pathlib import Path
from typing import Any, Callable, Dict, Optional, Union

import arib.code_set as code_set
import arib.control_characters as control_characters
Expand Down
15 changes: 5 additions & 10 deletions arib/ts2ass.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,19 @@

from __future__ import annotations

import sys
import argparse
import sys
import traceback
from dataclasses import dataclass
from pathlib import Path
from typing import Optional

from arib.read import EOFError

from arib.closed_caption import next_data_unit
from arib.closed_caption import StatementBody
from arib.data_group import DataGroup
from arib.arib_exceptions import FileOpenError

from arib.mpeg.ts import TS
from arib.mpeg.ts import ES

from arib.ass import ASSFormatter
from arib.closed_caption import StatementBody, next_data_unit
from arib.data_group import DataGroup
from arib.mpeg.ts import ES, TS
from arib.read import EOFError


@dataclass(frozen=True)
Expand Down
17 changes: 6 additions & 11 deletions arib/ts2srt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@

from __future__ import annotations

import sys
import argparse
import sys
import traceback
from dataclasses import dataclass
from pathlib import Path
from typing import Optional

from arib.read import EOFError

from arib.closed_caption import next_data_unit
from arib.closed_caption import StatementBody
from arib.data_group import DataGroup
from arib.arib_exceptions import FileOpenError

from arib.mpeg.ts import TS
from arib.mpeg.ts import ES

from arib.closed_caption import StatementBody, next_data_unit
from arib.data_group import DataGroup
from arib.mpeg.ts import ES, TS
from arib.read import EOFError
from arib.srt import SRTFormatter


Expand Down Expand Up @@ -128,7 +123,7 @@ def on_es_packet(self, current_pid, packet, header_size):
"Exception thrown while handling DataGroup in ES."
"This may be due to many factors "
"such as file corruption or the .ts file using"
"as yet unsupported features."
" as yet unsupported features."
)
traceback.print_exc(file=sys.stdout)

Expand Down
14 changes: 5 additions & 9 deletions arib/ts_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@
DATE: Thursday, October 20th 2016

"""
import argparse
import os
import sys
import argparse
import traceback
from arib.read import EOFError

from arib.mpeg.ts import TS
from arib.mpeg.ts import ES

from arib.closed_caption import next_data_unit
from arib.closed_caption import StatementBody
import arib.code_set as code_set
import arib.control_characters as control_characters
from arib.data_group import DataGroup

# print out some additional info for DRCS values
from arib.closed_caption import set_DRCS_debug
from arib.closed_caption import StatementBody, next_data_unit, set_DRCS_debug
from arib.data_group import DataGroup
from arib.mpeg.ts import ES, TS
from arib.read import EOFError

set_DRCS_debug(True)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ line-length = 100
target-version = "py310"

[tool.ruff.lint]
select = ["E", "F", "W"] # pycodestyle/pyflakes/warnings
select = ["E", "F", "W", "I"] # pycodestyle/pyflakes/warnings
ignore = []
2 changes: 2 additions & 0 deletions tests/test_cli_es_extract.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import sys

import pytest

import arib.es_extract as cli

# List of input .es files to run the CLI against
Expand Down
1 change: 1 addition & 0 deletions tests/test_read.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import io

import arib.read as read


Expand Down