BingLingGroup / autosub

Command-line utility to transcribe/translate from video/audio/subtitles to subtitles
GNU General Public License v2.0
1.98k stars 244 forks source link

AttributeError: 'NoneType' object has no attribute 'encode' #127

Closed kr4t0n closed 4 years ago

kr4t0n commented 4 years ago

Make sure you have read the readme, searched and read the issues related to yours. Otherwise it will be considered as a duplicate which will be closed immediately.

Describe the bug AttributeError: 'NoneType' object has no attribute 'encode'

To Reproduce Steps to reproduce the behavior:

  1. Command line arguments you are using.
  2. A complete copy of command line output of the autosub. You can use Ctrl-A and Ctrl-C to copy all of them. Use the following markdown code block syntax is recommended. Copy them into the place between ```.
autosub -i 1.mov -S ja-jp -D zh-cn

Traceback (most recent call last):
  File "/root/miniconda3/envs/autosub/bin/autosub", line 8, in <module>
    sys.exit(main())
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/autosub/__init__.py", line 159, in main
    styles_list=styles_list)
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/autosub/cmdline_utils.py", line 1369, in audio_or_video_prcs
    delete_chars=args.gt_delete_chars)
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/autosub/core.py", line 580, in list_to_googletrans
    service_urls=service_urls)
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/googletrans/client.py", line 62, in __init__
    'User-Agent': user_agent,
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/httpx/_models.py", line 480, in update
    headers = Headers(headers)
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/httpx/_models.py", line 395, in __init__
    for k, v in headers.items()
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/httpx/_models.py", line 395, in <listcomp>
    for k, v in headers.items()
  File "/root/miniconda3/envs/autosub/lib/python3.7/site-packages/httpx/_utils.py", line 53, in normalize_header_value
    return value.encode(encoding or "ascii")
AttributeError: 'NoneType' object has no attribute 'encode'
  1. etc.

Expected behavior Translate and obtain sub.

Screenshots If applicable, add screenshots to help explain your problem. But it is not recommended using screenshots to demonstrate the commandline output unless you think it really matters.

Environment (please complete the following information):

Additional context (Optional) Add any other context about the problem here.

BingLingGroup commented 4 years ago

It seems that using different service urls could solve the problem https://github.com/ssut/py-googletrans/issues/165 . BTW, I will update py-googletrans in the next version of autosub.

isuzjc commented 4 years ago

It seems that using different service urls could solve the problem ssut/py-googletrans#165 . BTW, I will update py-googletrans in the next version of autosub.

It doesn't work now.

BingLingGroup commented 4 years ago

@isuzjc It still works. You can just use different service url like translate.google.cn by option -surl "translate.google.cn" and it's OK.

BingLingGroup commented 4 years ago

Commit https://github.com/BingLingGroup/autosub/commit/d1133b37fcfc3ea03458063f73841dcbe732b483 should fix this. Thanks for your report.