reverendj1 / kodi-couch-ripper

Kodi addon for ripping DVDs/Blu-rays.
MIT License
10 stars 4 forks source link

Initial settings contain ids and not strings #6

Open twhitehead opened 3 years ago

twhitehead commented 3 years ago

I'm running kodi 18.9. I added the master branch as a zip file. When I run it, it generates the following errors

2020-12-28 11:46:05.691 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid CPU Priority = 30041 (high,low,normal).  Please Check Your Settings.
2020-12-28 11:46:05.691 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid Encode After Rip.  Please Check Your Settings.
2020-12-28 11:46:05.691 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid Eject After.  Please Check Your Settings.
2020-12-28 11:46:05.691 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid Notify After Rip.  Please Check Your Settings.
2020-12-28 11:46:05.691 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid Notify After Encode.  Please Check Your Settings.
2020-12-28 11:46:05.692 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Could Not Find .  Please Check Your Settings.
2020-12-28 11:46:05.692 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Could Not Find makemkvcon.  Please Check Your Settings.
2020-12-28 11:46:05.692 T:139759510877952   ERROR: script.couch_ripper-0.1.6 : Invalid CPU Priority = 30041 (high,low,normal). Invalid Encode After Rip. Invalid Eject After. Invalid Notify After Rip. Invalid Notify After Encode. Could Not Find . Could Not Find makemkvcon.

where I have augmented the first error message as follows

    # 30013 == High, 30015 == Low, 30019 == Normal                                                    
    if (profiledict['niceness'] != utils.getStringLow(30013) and
            profiledict['niceness'] != utils.getStringLow(30015) and
            profiledict['niceness'] != utils.getStringLow(30019)):
        errors = errors + utils.settingsError(
                '{invalid} {niceness} = {value} ({opt1},{opt2},{opt3}). '.format(
                invalid = utils.getString(30056),
                niceness = utils.getString(30018),
                value = profiledict['niceness'],
                opt1 = utils.getStringLow(30013),
                opt2 = utils.getStringLow(30015),
                opt3 = utils.getStringLow(30019)))

in order to see how what it gets differs from what it expects.

So it looks like there is an issue between the ids and the strings. Looking into the settings file reveals most values are being initialized as ids. Using the CPU priority as an example

    <setting id="defaultniceness" default="true">30015</setting>
...
    <setting id="profile1niceness" default="true">30041</setting>

If I set these settings in the settings menu, these change to strings

    <setting id="defaultniceness">High</setting>
...
    <setting id="profile1niceness">Default</setting>

and the associated error message for that setting goes away

2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Invalid Encode After Rip.  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Invalid Eject After.  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Invalid Notify After Rip.  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Invalid Notify After Encode.  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Could Not Find .  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Could Not Find makemkvcon.  Please Check Your Settings.
2020-12-28 11:54:34.319 T:139758272960256   ERROR: script.couch_ripper-0.1.6 : Invalid Encode After Rip. Invalid Eject After. Invalid Notify After Rip. Invalid Notify After Encode. Could Not Find . Could Not Find makemkvcon.

Erasing the settings and re-running resets it back to the ids.

twhitehead commented 3 years ago

I should add that under Settings/Interface my Regional/Language setting is English.

I don't know if there is any connection, but I looked through my other addons and they all seem to have .po files instead of .xml files under the resources/language/* directories.

twhitehead commented 3 years ago

If I substitute in all the strings in the English/strings.xml file into the settings.xml file the errors go away. Here is a simple script to run in the ~/.kodi/addons/script.couch_ripper directory that does this

#!/bin/sh

eval "$(awk \
          'BEGIN { print("sed -i \\") }
           /string id/ { match($0,"<string id=\"([0-9]+)\">([^<]+)<",a)
                         printf("  -e \"s|%d|%s|\" \\\n",a[1],a[2]) }
           END   { print("  ../../userdata/addon_data/script.couch_ripper/settings.xml") }
           ' resources/language/English/strings.xml)"
reverendj1 commented 3 years ago

Thanks for the info! There were two methods for translations when I was developing Couch Ripper, the strings.xml method that I use, and the newer strings.po method. IIRC, I was using strings.xml since strings.po was still a preview, or there weren't many examples, I forget. Anywho, it's now fully removed and that's why you're running into the issue. I actually stopped using my plugin a few years ago and use ARM (https://github.com/automatic-ripping-machine/automatic-ripping-machine) now instead. I've also since stopped using Kodi, so I don't have any way to rebuild/fix/test this, but I'd accept any PR, or even make you an editor on the project if you wanted to do it.