mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-04 21:21:57 +00:00
Upgrade code to be compatible with Python 3 (#925)
This commit is contained in:
committed by
Carlos Fernandez Sanz
parent
da132b379a
commit
6e2ce11b26
1
.gitignore
vendored
1
.gitignore
vendored
@@ -130,3 +130,4 @@ mac/install_manifest.txt
|
||||
mac/cmake_install.cmake
|
||||
mac/CMakeFiles/
|
||||
mac/CMakeCache.txt
|
||||
*.py.bak
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from builtins import str
|
||||
import ccextractor as cc
|
||||
import ccx_to_python_g608 as g608
|
||||
import python_srt_generator as srt_generator
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
###
|
||||
#MANDATORY UPDATES IN EVERY PYTHON SCRIPT
|
||||
###
|
||||
@@ -7,7 +8,7 @@ import ccextractor as cc
|
||||
|
||||
|
||||
def callback(line, encoding):
|
||||
print line
|
||||
print(line)
|
||||
|
||||
|
||||
def init_ccextractor(callback):
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import print_function
|
||||
from builtins import str
|
||||
def g608_grid_former(line,text,color,font):
|
||||
if "text[" in line:
|
||||
line = str(line.split(":", 1)[1])
|
||||
@@ -57,5 +59,5 @@ def return_g608_grid(case,text,color,font):
|
||||
if font:
|
||||
ret_val['font']=font
|
||||
else:
|
||||
print help_string
|
||||
print(help_string)
|
||||
return ret_val
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from __future__ import print_function
|
||||
from builtins import zip
|
||||
from builtins import str
|
||||
import ccextractor as cc
|
||||
import re
|
||||
"""
|
||||
@@ -119,23 +122,23 @@ def comparing_text_font_grids(text, font, color):
|
||||
if not i[1]:
|
||||
final.append(i[0])
|
||||
else:
|
||||
print "error"
|
||||
print("error")
|
||||
return (final,font,color)
|
||||
|
||||
|
||||
def generate_output_srt(filename,d, encoding):
|
||||
if encoding in encodings_map.keys():
|
||||
if encoding in list(encodings_map.keys()):
|
||||
if encoding!='0':
|
||||
encoding_format = encodings_map[encoding]
|
||||
else:
|
||||
encoding_format = ""
|
||||
else:
|
||||
print "encoding error in python"
|
||||
print("encoding error in python")
|
||||
return
|
||||
if encoding_format:
|
||||
d['text'] = [unicode(item,encoding_format) for item in d['text']]
|
||||
d['text'] = [str(item,encoding_format) for item in d['text']]
|
||||
else:
|
||||
d['text'] = [unicode(item) for item in d['text']]
|
||||
d['text'] = [str(item) for item in d['text']]
|
||||
d['text'],d['font'],d['color']= comparing_text_font_grids(d['text'],d['font'],d['color'])
|
||||
for item in d['text']:
|
||||
if item.count(" ")<32:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
@@ -6,11 +7,11 @@ output_formats = ['.srt','.ass','.ssa','.webvtt','.sami','.txt','.original','.py
|
||||
args_list = sys.argv[1:]
|
||||
args_count = len(args_list)
|
||||
if args_count>1:
|
||||
print "wrong usage"
|
||||
print("wrong usage")
|
||||
exit(0)
|
||||
directory = args_list[0]
|
||||
if not os.path.isdir(directory):
|
||||
print "error: path given is not a directory"
|
||||
print("error: path given is not a directory")
|
||||
exit(0)
|
||||
files = []
|
||||
for item in os.listdir(directory):
|
||||
@@ -18,8 +19,8 @@ for item in os.listdir(directory):
|
||||
if ext not in output_formats:
|
||||
files.append(os.path.join(directory,item))
|
||||
for sample in files:
|
||||
print "Processing file: "+sample
|
||||
print("Processing file: "+sample)
|
||||
#command=['../linux/ccextractor',sample]
|
||||
command = ['python','api_testing.py',sample]
|
||||
subprocess.call(command)
|
||||
print "Finished processing file: "+sample
|
||||
print("Finished processing file: "+sample)
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
# Email : harryyunull@gmail.com
|
||||
# Link : https://github.com/harrynull
|
||||
|
||||
from __future__ import print_function
|
||||
from builtins import range
|
||||
from builtins import object
|
||||
Version = "1.0.0"
|
||||
|
||||
import sys
|
||||
@@ -10,7 +13,7 @@ import time
|
||||
import datetime
|
||||
from io import open
|
||||
|
||||
class Line:
|
||||
class Line(object):
|
||||
def __init__(self, lines):
|
||||
lines = [line.replace("\n", "").strip() for line in lines]
|
||||
self.id = int(lines[0]) # the first line is the number of the subtile
|
||||
|
||||
Reference in New Issue
Block a user