Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeerror i donnot know why #1

Closed
libsu opened this issue Dec 23, 2017 · 8 comments
Closed

typeerror i donnot know why #1

libsu opened this issue Dec 23, 2017 · 8 comments

Comments

@libsu
Copy link

libsu commented Dec 23, 2017

C:\Users\Libsu\Desktop\sub2xml-master>sub2xml.py 1.ass Traceback (most recent call last): File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 275, in <module> main() File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 91, in main subs, sub_styles = sub_load(input_sub) File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 184, in sub_load with open(inp_fname, "r", encoding='utf-8') as f: TypeError: 'encoding' is an invalid keyword argument for this function

win10 py2.7

@pyahmed
Copy link
Owner

pyahmed commented Dec 23, 2017

This script was tested only with Python 3.4+ - can't comment on Python 2.x
If you want to stay with Python 2.x / can't update to 3.x etc you can try to remove this part:

, encoding='utf-8'

and see if that helps.

Though ideally you would run it with Python3.

@libsu
Copy link
Author

libsu commented Dec 23, 2017

I re-install py3 and this time had a new situation , seem not work again:
`Installing easy_install-3.5.exe.manifest script to C:\Python3\Scripts

Using c:\python3\lib\site-packages
Finished processing dependencies for ass==0.4.2

C:\Users\Libsu\Desktop\python-ass-master>cd C:\Users\Libsu\Desktop\sub2xml-master

C:\Users\Libsu\Desktop\sub2xml-master>sub2xml.py 2333.ass
[] 0.0%Traceback (most recent call last):
File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 275, in
main()
File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 111, in main
title, prtl_warning = generate_prtl(sub_text, stl_data, preset)
File "C:\Users\Libsu\Desktop\sub2xml-master\sub2xml.py", line 246, in generate_prtl
root.find('.//gSizeX').text = str(new_width)
AttributeError: 'NoneType' object has no attribute 'text'`

@pyahmed
Copy link
Owner

pyahmed commented Dec 23, 2017

Hmm can you provide the ass-file? I don't see anything obvious that would cause this error.

@libsu
Copy link
Author

libsu commented Dec 24, 2017

1.zip
here is

@pyahmed
Copy link
Owner

pyahmed commented Dec 25, 2017

When I run it via
sub2xml.py 1.ass

I get:

Traceback (most recent call last): File "D:\github\sub2xml\sub2xml.py", line 40, in <module> input_sub = sys.argv[1] IndexError: list index out of range

However with:
python sub2xml.py 1.ass

it works:

[#################################################] 99.9%

 XML-file: 1.xml
 Project folder: D:\github\sub2xml\premiere_proj_0856-37
 Subs folder: D:\github\sub2xml\premiere_proj_0856-37\subs

 ---FINISHED---

Press <ENTER> to open project dir

This is because of sys.argv[1] etc.

I guess I should update the script to properly use argparse or something like it. Can you try with the command above and see if it helps?

@libsu
Copy link
Author

libsu commented Dec 25, 2017

It successfully created, but I found another problem that the PRTL template is encoded in the utf-16, but the encoding for the ass subtitle is utf-8, I try to change either of them, and the program do not work(UnicodeDecodeError), when I generating Chinese characters (simplified Chinese), it's going to fail, part of word show "□□". But it does worked perfect in English.

@pyahmed
Copy link
Owner

pyahmed commented Dec 25, 2017

The PRTL has to be UTF-16LE encoded, this is a requirement by Adobe Premiere.

I checked the .ass file and there are only Chinese characters in the defined styles, but there are none within the actual subs.

All subs are using the default style. As stated in the README, this script ignores any styling, it just dumps the text from the subtitle into the PRTL files.

If you have a sample .ass file with Chinese characters I can try it here.

@pyahmed
Copy link
Owner

pyahmed commented Jan 4, 2018

Since there is no further issue I will close this.

@pyahmed pyahmed closed this as completed Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants