Error when clicking 'Download' (ascii codec can't encode)

Bug #306589 reported by Baptiste Lafontaine
80
This bug affects 10 people
Affects Status Importance Assigned to Milestone
SubDownloader
Status tracked in Trunk
Trunk
Fix Committed
High
Marco Rodrigues
subdownloader (Debian)
Fix Released
Unknown
subdownloader (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Hello,

I'm using version 2.0.9 on ubuntu intrepid.

When I try to clic on "Download" when I've selected a subtitle, the message box "Downloading" freezes, and in the console I've :
Traceback (most recent call last):
  File "/usr/share/subdownloader/gui/main.py", line 1041, in onButtonDownload
    destinationPath = self.getDownloadPath(sub.getVideo(), sub)
  File "/usr/share/subdownloader/gui/main.py", line 1013, in getDownloadPath
    downloadFullPath = os.path.join(folderPath, subFileName).decode('utf8')
  File "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 18: ordinal not in range(128)

I needed the subtitle in question is : http://www.opensubtitles.org/en/subtitles/3375310/heroes-fr

Contact me if you need more informations

Tags: patch
Revision history for this message
Baptiste Lafontaine (magnetik) wrote :

Additional information : it's happening only when I select the option "Same folder as video file" for the "Destination folder".
The option "Ask user" works well when I select the path of the video.

Revision history for this message
Baptiste Lafontaine (magnetik) wrote :

last information that i've forgotten, the video path contain a "é".
But I've to repeat that when I select the path with the option "ask user" it works well, only the option "Same folder as video file" raises the error.

Revision history for this message
Ivan Garcia (capiscuas) wrote :

what is the folder name?

Revision history for this message
Baptiste Lafontaine (magnetik) wrote :

Its "/home/magnetik/Vidéos/Heroes S3"

For information, the ouput when I clic on 'Play' is :
['"/usr/bin/totem"', u'/home/magnetik/Vid\xe9os/Heroes S3/Heroes.S03E11.HDTV.XviD-LOL/heroes.311.hdtv-lol.avi', u'/tmp/subdownloader.tmp.srt']
[19:26] INFO::subdownloader.gui.main # Running this command:
/usr/bin/totem ['"/usr/bin/totem"', u'/home/magnetik/Vid\xe9os/Heroes S3/Heroes.S03E11.HDTV.XviD-LOL/heroes.311.hdtv-lol.avi', u'/tmp/subdownloader.tmp.srt']

Is it normal that the srt file is not in the same folder as the video file when I click play ?

Revision history for this message
Ivan Garcia (capiscuas) wrote :

when you click on PLAY, we just download the subtitle in the temporary folder, in linux is /tmp.

the cause of this bug is that Vid\xe9os/ has some special character. :-(, we'll try to fix this in the future.

Revision history for this message
Baptiste Lafontaine (magnetik) wrote :

Any idea if it will be fixed soon ?

"Vidéos" is the default name of the video location on french ubuntu, I think lot of people can't use SubDownloader atm.

I don't get why it works when I've the option "ask the user" and I select the folder and it doesn't work with the "Same folder as video" while it is the same folder in fact.

Revision history for this message
Marco Rodrigues (gothicx) wrote :

I think this problem is fixed at version 2.0.9.3, I can't reproduce it.

Could you test it ?

PPA: https://edge.launchpad.net/~subdownloader-developers/+archive/ppa

Thanks

Changed in subdownloader:
importance: Undecided → Medium
status: New → Triaged
Revision history for this message
Baptiste Lafontaine (magnetik) wrote :

tested with the PPA version 2.0.9.3, and still the same error :

Traceback (most recent call last):
  File "/usr/share/subdownloader/gui/main.py", line 1062, in onButtonDownload
    destinationPath = self.getDownloadPath(sub.getVideo(), sub)
  File "/usr/share/subdownloader/gui/main.py", line 1034, in getDownloadPath
    downloadFullPath = os.path.join(folderPath, subFileName).decode('utf8')
  File "/usr/lib/python2.5/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 18: ordinal not in range(128)

Changed in subdownloader:
status: Triaged → Confirmed
Revision history for this message
Marco Rodrigues (gothicx) wrote :

Hi!

Please download the latest version from PPA and run it with -d (debug) option and show here the debug information when it breaks.

Thanks

Revision history for this message
WinZ (witz-sebastien) wrote :
Download full text (5.3 KiB)

Hi, I think this is the same bug.

I m running the version 2.0.10, and I got that error (with the -d mode : ) when i try to scan a certain directory

-------
winz@pc-ubuntu:~/Videos/Various/Prison Break Season 3 Episodes 1-13 Complete$ subdownloader -d
/usr/lib/python2.6/dist-packages/kaa/notifier/popen.py:52: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
  import popen2
/usr/lib/python2.6/dist-packages/kaa/metadata/disc/cdrom.py:37: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import md5
[12:46] DEBUG::subdownloader.gui.main # Building main dialog
[12:46] DEBUG::subdownloader.gui.main # Showing main dialog
[12:46] DEBUG::subdownloader.gui.main # Scanning translation files .mo in folder: /usr/share/locale/
[12:46] DEBUG::subdownloader.gui.main # Found these translations languages: ['el', 'pt_PT', 'hu', 'eu', 'en', 'ja', 'gl', 'pl', 'sq', 'nl', 'es_ES', 'vi', 'sr', 'ko', 'pt_BR', 'id', 'et', 'cs', 'sk', 'mk', 'he', 'ru', 'fr', 'it', 'bg', 'sv', 'zh_TW', 'hr', 'de', 'ro', 'fi', 'da']
[12:46] DEBUG::subdownloader.gui.main # Interface language: en
[12:46] DEBUG::subdownloader.gui.main # Current directory: /media/data/Documents and Settings/Winz/Mes documents/Downloads/Movies/Various/Prison Break Season 3 Episodes 1-13 Complete
[12:46] DEBUG::subdownloader.SDService.SDService # Creating Server with server = None and proxy = None
[12:46] DEBUG::subdownloader.SDService.SDService # Creating XMLRPC server connection...
[12:46] DEBUG::subdownloader.SDService.SDService # Connecting with parameters ('http://www.opensubtitles.org/xml-rpc', None)
[12:46] DEBUG::subdownloader.SDService.SDService # Trying direct connection...
[12:46] DEBUG::subdownloader.SDService.SDService # ...connected
[12:46] DEBUG::subdownloader.SDService.SDService # Creating Server with server = None and proxy = None
[12:46] DEBUG::subdownloader.SDService.SDService # Creating XMLRPC server connection...
[12:46] DEBUG::subdownloader.SDService.SDService # Connecting with parameters ('http://sddb.subdownloader.net/xmlrpc/', None)
[12:46] DEBUG::subdownloader.SDService.SDService # Trying direct connection...
[12:46] DEBUG::subdownloader.SDService.SDService # ...connected
[12:46] DEBUG::subdownloader.SDService.SDService # ----------------
[12:46] DEBUG::subdownloader.SDService.SDService # CheckSoftwareUpdates RPC method starting...
[12:46] DEBUG::subdownloader.SDService.SDService # ----------------
[12:46] DEBUG::subdownloader.SDService.SDService # Logging in (username:'winz79')...
[12:46] DEBUG::subdownloader.SDService.SDService # Latest SubDownloader Version Found: 2.0.9
[12:46] DEBUG::subdownloader.SDService.SDService # Login ended in 0.018 with status: 200 OK
[12:46] DEBUG::subdownloader.SDService.SDService # Session ID: g43fncif75td5toh95il2kigk1
[12:46] DEBUG::subdownloader.SDService.SDService # ----------------
[12:46] DEBUG::subdownloader.FileManagement.FileScan # Scanning: /media/data/Documents and Settings/Winz/Mes documents/Downloads/Movies/Various/Prison Break Season 3 Episodes 1-13 Complete
[12:46] DEBUG::subdownloader.FileManagement.FileScan # Scanning Folder /media/data/Documents and Settings/Winz/Mes documents/Do...

Read more...

Revision history for this message
Selmi (selmi) wrote :

similar problem

Traceback (most recent call last):
  File "gui\main.pyo", line 925, in onFolderTreeClicked
  File "gui\main.pyo", line 762, in SearchVideos
  File "FileManagement\FileScan.pyo", line 43, in ScanFilesFolders
  File "FileManagement\FileScan.pyo", line 91, in ScanFolder
  File "encodings\mbcs.pyo", line 21, in decode
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)

it happens on windows xp when i clicked on folder which has russian letters in name (my system is set to win-1250 central europe)

Revision history for this message
Ludovic Isabelle (ludovic-isabelle) wrote :

Hello,

I have the same problem, running the version 2.0.10.

This is a workaround for linux users:

1 - Edit file /usr/share/subdownloader/gui/main.py as root
2 - Go to line 1009
3 - Uncomment the line downloadFullPath = dir.filePath(QString(subFileName)).__str__()
4 - Comment the next line (1010) downloadFullPath = os.path.join(folderPath, subFileName).decode('utf8')
5 - Save

As I don't have the history of the project, I don't know why this line commented/uncommented, but the bug is maybe because the program tries to decode the filesystem as utf-8 instead of iso 8859-1 (for me).

Revision history for this message
Ludovic Isabelle (ludovic-isabelle) wrote :

As I though in the previous comment, the file system encoding isn't taken in account, resulting that some characters cannot be read.
I joined to this comment a diff of the corrected file.

Revision history for this message
Adam Vlasák (k23) wrote :

I fixed this by removing decode call, like this:

downloadFullPath = os.path.join(folderPath, subFileName)

I guess downloadFullPath is already UTF8.

Hope this helps.

Changed in subdownloader:
milestone: none → 2.0.15
assignee: nobody → Marco Rodrigues (gothicx)
Revision history for this message
Marco Rodrigues (gothicx) wrote :

The patch was applied to trunk.

I applied Ludovic patch, because I think it's the best way to solve this problem.

Changed in subdownloader:
status: Confirmed → Fix Committed
importance: Medium → High
Changed in subdownloader (Ubuntu):
status: New → Confirmed
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "patch.txt" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Erik Paixao (erikpaixao18-gmail) wrote :

I solved this problem by removing the accents of the name of the destination folder

Changed in subdownloader (Debian):
status: Unknown → Confirmed
Revision history for this message
Emilien Klein (emilien-klein) wrote :

The original patch (by Ludovic) that got applied does not fix the core of the problem, which is cause by calling .decode() on that string. On my French system:

>>> print sys.getfilesystemencoding()
UTF-8

So replacing decode('utf8') by decode(sys.getfilesystemencoding()) doesn't do anything useful.

I've attached a new patch to bug #913453 that removes the whole decode() part, and now subtitles can be properly downloaded to folders containing accents. When the patch is applied, both issues can be closed.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package subdownloader - 2.0.14-1.1

---------------
subdownloader (2.0.14-1.1) unstable; urgency=low

  * Non-maintainer upload.
  * debian/patches/fix-non-ascii-download-path.patch:
    + Fix downloading subtitles in folders containing non-ASCII characters
      (Closes: #606993), (LP: #913453, #306589)
  * debian/source/format:
    Update to "3.0 (quilt)" to apply the previous patch in a proper way

 -- Emilien Klein <email address hidden> Sat, 10 Nov 2012 12:43:07 +0100

Changed in subdownloader (Ubuntu):
status: Confirmed → Fix Released
Changed in subdownloader (Debian):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.