This repository has been archived by the owner on Mar 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1559ee1
Showing
10 changed files
with
692 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
version: "{branch}.{build}" | ||
image: | ||
- "Visual Studio 2015" | ||
environment: | ||
PATH: "C:\\msys64\\usr\\bin;%PATH%" | ||
matrix: | ||
- APPVEYOR_BITS: 32 | ||
- APPVEYOR_BITS: 64 | ||
cache: | ||
- '%LOCALAPPDATA%\pip\Cache' | ||
init: | ||
- git config --global core.autocrlf true | ||
install: | ||
- bash -e install.sh | ||
build: | ||
verbosity: detailed | ||
build_script: | ||
- bash -e build.sh | ||
test: off | ||
matrix: | ||
fast_finish: true | ||
artifacts: | ||
- path: build\dist\smi2ass.* | ||
name: Releases | ||
deploy: | ||
provider: GitHub | ||
auth_token: | ||
secure: "NFYPLE7fXMSzXHZGA9EEXaGwvgct/x4tnWYIPsvKOK0FmNvYeUT6wxf/pwy/NMc5" | ||
artifact: /smi2ass\..*/ | ||
draft: false | ||
prerelease: false | ||
on: | ||
appveyor_repo_tag: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.bat text eol=crlf | ||
/gradlew text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Build output | ||
/build | ||
/test_smis/*.ass | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: generic | ||
sudo: required | ||
dist: trusty | ||
os: | ||
- linux | ||
- osx | ||
cache: | ||
directories: | ||
- "$HOME/.cache/pip" | ||
- "$HOME/Library/Caches/pip" | ||
- "$HOME/Library/Caches/Homebrew" | ||
install: | ||
- ./install.sh | ||
script: | ||
- ./build.sh | ||
notifications: | ||
email: false | ||
deploy: | ||
provider: releases | ||
api_key: | ||
- secure: "yFKbvIDfZYNiK3ea5Kdm8mAMBKdrnDgNAQHQGprhqpziJ7lJOadCqgHh53Dn/eIoIJTqm29GIEj+YvTP623i3duiIHEOFrYxu6TOkaTT0clRNDe55NckGXlq4NUx1/AFu3THkLVbCxK8dHTqDoiBNSG3CLAbzCw9SV+59ND3NLZQ/U4lKzaKJP0E2yACFweT1vsiW1fJiuvYZi2gkhOwTi+WVM7Dgzu6ch2bIwGEMVdPD4X6OVUj44sQzh2Df9CFRfMEztFbnhlBfH9l3JDsMYLdfeXXVjw6KSdnID8rK/SlavFteYiEE9Ap17NCPf6lFufnqR2N3YckMdfWqTmEb1Uf23FdRMct9oSb4QlIopzFaZ1XTdyR/Yep8lj8e8YcsAZIPd3c51Nm5UAssDVwTHXFRp4rjrTYKApuLiSRG9Rqv1w3zu1ss7z1MUK+PCZD7ge2nfFAXfHpTb1TbM6eDHXX0rCSCSB7c+XwnMUjwN4ahzWbAk+xMpo/+MWQ/Pli4M3Kk1ILBTiKfmmnFv1xS8CDwCHwv2b9r4tsWwqUuCCksSosMZHWYdeE+TQVskFCpJ3NJtjOaJCISt/YVlXL17eEdGFQ3y1nu05sJbCu/UKAH1ulmgmoHA0AUW13w/4tTWkKgwwfBn3+mDP9uhKn/gTa2fYmeZ/+DNfYGJ5PsdU=" | ||
file_glob: true | ||
file: "build/dist/smi2ass.*" | ||
skip_cleanup: true | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# smi2ass | ||
|
||
`smi2ass` is a command-line tool that converts SAMI to SSA/ASS (SubStation Alpha). | ||
|
||
[Download the executable](https://github.com/trustin/smi2ass/releases) and run it with `.smi` file paths: | ||
|
||
``` | ||
$ smi2ass my_subtitles.smi | ||
``` | ||
|
||
`smi2ass` will convert the specified `.smi` files into `.ass` files. It will also generate multiple `.ass` files | ||
if the `.smi` file contains the subtitles of multiple languages. | ||
|
||
``` | ||
$ ls my_subtitles.* | ||
my_subtitles.eng.ass | ||
my_subtitles.kor.ass | ||
``` | ||
|
||
## Supported tags | ||
|
||
`smi2ass` supports `<p>`, `<br>`, `<b>`. `<i>`, `<u>`, `<s>`, `<font>` and `<rt>` (Ruby tags). | ||
|
||
## Fixing a bad SAMI file | ||
|
||
`smi2ass` will not output anything if the conversion went OK. It prints the problematic SAMI fragment if it failed the conversion, | ||
so you can find the location of the problem in your `.smi` file, fix it and run again: | ||
|
||
``` | ||
$ smi2ass my_bad_subtitles.smi | ||
Failed to extract time code: <sync star=1234> | ||
``` | ||
|
||
## Credits | ||
|
||
The conversion script was initially forked from https://github.com/hojel/service.subtitles.gomtv/tree/3a7342961e140eaf8250659b0ac6158ce5e6bc5c/resources/lib. Since then, [@trustin](https://github.com/trustin) made the following changes: | ||
|
||
- Added Ruby tag support | ||
- Improved the preservation of white spaces | ||
- Packaged into a single executable | ||
- Updated Python from 2 to 3 | ||
- Updated BeautifulSoup from 3 to 4 | ||
- Miscellaneous cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash -e | ||
export PATH="$PWD/build/venv/bin:$PWD/build/venv/Scripts:$PATH" | ||
if [[ ! -d "$PWD/build/venv" ]]; then | ||
echo "virtualenv not ready" | ||
exit 1 | ||
fi | ||
|
||
# Install the core packages. | ||
pip install \ | ||
'PyInstaller==3.3.1' \ | ||
'beautifulsoup4==4.6.0' \ | ||
'chardet==3.0.4' | ||
|
||
# Build the binary. | ||
python -OO -m PyInstaller \ | ||
--noconfirm \ | ||
--console \ | ||
--onefile \ | ||
--distpath build/dist \ | ||
--specpath build \ | ||
smi2ass.py | ||
|
||
# Rename the binary. | ||
OS_CLASSIFIER="$(./os_classifier.sh)" | ||
if [[ -f build/dist/smi2ass.exe ]]; then | ||
SMI2ASS_BIN="build/dist/smi2ass.$OS_CLASSIFIER.exe" | ||
mv -v build/dist/smi2ass.exe "$SMI2ASS_BIN" | ||
else | ||
SMI2ASS_BIN="build/dist/smi2ass.$OS_CLASSIFIER" | ||
mv -v build/dist/smi2ass "$SMI2ASS_BIN" | ||
fi | ||
|
||
# Generate the SHA256 checksum. | ||
if [[ -x /usr/local/bin/gsha256sum ]]; then | ||
SHA256SUM_BIN=/usr/local/bin/gsha256sum | ||
else | ||
SHA256SUM_BIN=sha256sum | ||
fi | ||
"$SHA256SUM_BIN" -b "$SMI2ASS_BIN" | sed 's/ .*//g' > "$SMI2ASS_BIN.sha256" | ||
echo "sha256sum: $(cat "$SMI2ASS_BIN.sha256") ($SMI2ASS_BIN.sha256)" | ||
|
||
# Build a test site with the binary to make sure it really works. | ||
"build/dist/smi2ass.$OS_CLASSIFIER" 'test_smis/Psycho-Pass - S01E15.smi' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash -e | ||
cd "$(dirname "$0")" | ||
rm -fr build | ||
|
||
# Install or find Python 3.6. | ||
if [[ "$(uname)" =~ ([Ll]inux) ]]; then | ||
if [[ "$TRAVIS_OS_NAME" == 'linux' ]]; then | ||
sudo add-apt-repository -y ppa:deadsnakes/ppa | ||
sudo apt-get update | ||
sudo apt-get install -y python3.6 python3.6-venv python3.6-dev | ||
fi | ||
PYTHON=/usr/bin/python3.6 | ||
elif [[ "$(uname)" =~ ([Dd]arwin) ]]; then | ||
if brew ls --versions python > /dev/null; then | ||
brew upgrade python3 | ||
else | ||
brew install python3 | ||
fi | ||
PYTHON=/usr/local/bin/python3 | ||
elif [[ -n "$APPVEYOR" ]]; then | ||
if [[ "$(./os_classifier.sh)" == 'windows-x86_32' ]]; then | ||
PYTHON=/c/Python36/python | ||
else | ||
PYTHON=/c/Python36-x64/python | ||
fi | ||
else | ||
echo "Unsupported build environment: $(uname -a)" | ||
exit 1 | ||
fi | ||
|
||
# Create and activate a Python 3.6 virtualenv. | ||
echo "Creating a new virtualenv with $PYTHON" | ||
"$PYTHON" -m venv build/venv | ||
export PATH="$PWD/build/venv/bin:$PWD/build/venv/Scripts:$PATH" | ||
|
||
# Upgrade pip and setuptools. | ||
if [[ -n "$APPVEYOR" ]]; then | ||
# Windows | ||
python -m pip install --upgrade pip setuptools | ||
else | ||
pip install --upgrade pip setuptools | ||
fi | ||
|
||
# Make sure we use Python 3.6. | ||
PYVER="$(python --version)" | ||
PIPVER="$(pip --version)" | ||
echo "$(which python) --version: $PYVER" | ||
echo "$(which pip) --version: $PIPVER" | ||
echo "os.classifier: $(./os_classifier.sh)" | ||
if [[ ! "$PYVER" =~ (^Python 3\.6\.) ]] || \ | ||
[[ ! "$(which python)" =~ (^.*/build/venv/.*$) ]] || \ | ||
[[ ! "$PIPVER" =~ (^.*pip 10\..*[\\/]build[\\/]venv[\\/].*3\.6[^0-9].*$) ]]; then | ||
echo 'Must run on Python 3.6 virtualenv with pip 10' | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash -e | ||
if [[ "$(uname)" =~ ([Ll]inux) ]]; then | ||
echo linux-x86_64 | ||
elif [[ "$(uname)" =~ ([Dd]arwin) ]]; then | ||
echo osx-x86_64 | ||
elif [[ -n "$APPVEYOR" ]]; then | ||
if [[ "$APPVEYOR_BITS" == '32' ]]; then | ||
echo windows-x86_32 | ||
else | ||
echo windows-x86_64 | ||
fi | ||
else | ||
echo unknown | ||
fi |
Oops, something went wrong.