XBMC subtitles addon - Sratim fixed
#1
Don't know how to contact the "XBMC subtitles addon" plugin maintainer. Version 2.4.7 removed Sratim service. I have fixed the script for sratim.

I also needed to fix some other stuff on a file called gui.ty

Code:

Code:
self.title     = unicodedata.normalize('NFKD',
unicode(unicode(xbmc.getInfoLabel("VideoPlayer.Title"),
'utf-8'))).encode('ascii','ignore')

the above line of code returned an empty string on my machine Win7 (line 89).

When 'self.title' is empty the service script gets no title to work with, thus I had to make some changes in the gui.ty.

If this is not the right forum to discuss this, please direct me to the right place.

let me know how to submit this fix
Reply
#2
sbentin Wrote:Don't know how to contact the "XBMC subtitles addon" plugin maintainer. Version 2.4.7 removed Sratim service. I have fixed the script for sratim.

I also needed to fix some other stuff on a file called gui.ty

Code:

Code:
self.title     = unicodedata.normalize('NFKD',
unicode(unicode(xbmc.getInfoLabel("VideoPlayer.Title"),
'utf-8'))).encode('ascii','ignore')

the above line of code returned an empty string on my machine Win7 (line 89).

When 'self.title' is empty the service script gets no title to work with, thus I had to make some changes in the gui.ty.

If this is not the right forum to discuss this, please direct me to the right place.

let me know how to submit this fix

http://forum.xbmc.org/showthread.php?tid=75437

for the fix in gui.py you can fork https://github.com/amet/script.xbmc.subtitles and request a pull, for sratim service orivar is your man.

http://forum.xbmc.org/showpost.php?p=793...count=1121
Reply
#3
Quote:for the fix in gui.py you can fork https://github.com/amet/script.xbmc.subtitles and request a pull, for Sratim service orivar is your man.

before I do any forking I'de like to understand why the problem with the decoding happens. This line is part of the main code, not a service and it runs for all services, any idea?

I'll drop a note to orivar about the fix
Reply
#4
sbentin Wrote:before I do any forking I'de like to understand why the problem with the decoding happens. This line is part of the main code, not a service and it runs for all services, any idea?

I'll drop a note to orivar about the fix

it works for me, and by the looks of it for everyone else but you. if you want us to fix it please fork... if not , also good by me Smile

cheers,
amet
Reply
#5
1. I'll PM you my e-mail address, please send me the files for the Sratim service, I'll review and test them before updating them @ github.
2. gui.py is amet's not mine, but I don't mind helping. However like amet said there doesn't seem to be a problem with it for anyone but you: Does it happen on every file you've tried? Are the titles in English?
Reply
#6
Amet, after a short conversation with orivar he put me on the right track regarding the problem. The problem happens when I use the Sratim or Torec movie info scrapers. These grabbers put a hebrew title, which is unicode already and it's characters can not be encoded into ascii. Showing the a title in Hebrew is important to many users. For these users your plugin won't work. Since I wrote these grabbers I've added another piece of info into them called "original title" which holds the original title of the movie.

I don't understand why you decided to do the ascii encoding, but you've been at this game longer then I have so you probably had a good reason. Anyway I propose the following change:

Code:
try :
        self.title     = unicodedata.normalize('NFKD',
                      unicode(unicode(xbmc.getInfoLabel
                      ("VideoPlayer.Title"), 'utf-8'))
                      ).encode('ascii')                            # Title
    except UnicodeEncodeError:
        originalTitle = xbmc.getInfoLabel("VideoPlayer.OriginalTitle")
        if not originalTitle == None and not originalTitle == "":
            self.title     = unicodedata.normalize('NFKD', unicode(originalTitle, 'utf-8')).encode('ascii', 'ignore')

From the original line of code I removed the 'ignore'. The reasoning is that when you ignore errors you get a partial encoded result which will not be a good search string anyway. If title was bad, you try to get originalTitle, if good everyone is happy if not self.title has not changed and is still the same value it was when first trying to encode.

I pulled a request on githubSmile
Reply
#7
sbentin Wrote:Amet, after a short conversation with orivar he put me on the right track regarding the problem. The problem happens when I use the Sratim or Torec movie info scrapers. These grabbers put a hebrew title, which is unicode already and it's characters can not be encoded into ascii. Showing the a title in Hebrew is important to many users. For these users your plugin won't work. Since I wrote these grabbers I've added another piece of info into them called "original title" which holds the original title of the movie.

I don't understand why you decided to do the ascii encoding, but you've been at this game longer then I have so you probably had a good reason. Anyway I propose the following change:

Code:
try :
        self.title     = unicodedata.normalize('NFKD',
                      unicode(unicode(xbmc.getInfoLabel
                      ("VideoPlayer.Title"), 'utf-8'))
                      ).encode('ascii')                            # Title
    except UnicodeEncodeError:
        originalTitle = xbmc.getInfoLabel("VideoPlayer.OriginalTitle")
        if not originalTitle == None and not originalTitle == "":
            self.title     = unicodedata.normalize('NFKD', unicode(originalTitle, 'utf-8')).encode('ascii', 'ignore')

From the original line of code I removed the 'ignore'. The reasoning is that when you ignore errors you get a partial encoded result which will not be a good search string anyway. If title was bad, you try to get originalTitle, if good everyone is happy if not self.title has not changed and is still the same value it was when first trying to encode.

I pulled a request on githubSmile


what is going to happen here is that if try: fails cos you removed "ignore" and there is no original title there will be no self.title set

we need to rethink this, I would appreciate if you could get me a log when the issue happens so that I can try to reproduce on my side.

ascii encoding is used cos some services we use can only accept those
Reply
#8
There is nothing to see in the log on the original gui.ty since what happens is that 'self.title' fails on all letters encoded, but since errors are ignored it returns an empty string, or in most cases two bytes, but nothing is logged.

After my change I get the following error in the except:

Code:
'ascii' codec can't encode characters in position 0-7: ordinal not in range(128)

and that is all the relavent info in the log. If the title would have been empty (rather then two bytes) I could just do an empty check instead of using the try except, but its not...

If you wan't to see this happening just grab the Sratim movie scraper from the xbmc repository run it on an example movie and try to download subtitles. If you can't give me an email I can send you the scrapers I use....

As a solution to the problem you raised we can add the following code at the end of the except:

Code:
if self.title == ""
     self.title = xbmc.getInfoLabel("VideoPlayer.Title")

at the point of this if we know ascii is no go, originalTitle does not exist so all that's left to do is get the Title as is
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC subtitles addon - Sratim fixed0