i96751414 / script.flix.magneto

Provider for Flix, using Torrest
4 stars 1 forks source link

Settings provider detection problem #1

Closed BTopbas closed 4 years ago

BTopbas commented 4 years ago

Here is problem: My settings.xml:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
    <!-- General -->
    <category label="30000">
    </category>
    <!-- Providers -->
    <category label="30001">
        <setting id="1" type="bool" label="testex" default="<true|false>"/>
    </category>
</settings>

My providers.json:

[
  {
    "name": "testex",
    "base_url": "https://torrentapi.org/pubapi_v2.php",
    "results_parser": {
      "url": "?mode=search&search_string={query:q}&format=json_extended&app_id=script.elementum.burst&token=36gja8ncme",
      "type": "json",
      "rows": "./torrent_results",
      "data": {
        "title": "./title/text()",
        "size": "./size/text()",
        "seeds": "./seeders/text()",
        "leeches": "./leechers/text()",
        "magnet": "./download/text()"
      }
    },
    "keywords": {
      "movie": "{title} {year}",
      "show": "{title}",
      "season": "{title} S{season:02}",
      "episode": "{title} S{season:02}E{episode:02}"
    },
    "attributes": {
      "color": "FFF14E13",
      "icon": "provider_icons/example.png"
    }
  }
]

DEBUG : found key /userdata/addon_data/script.flix.magneto/settings.xml 2020-07-19 19:40:46.931 T:1541736 DEBUG <CAddonSettings[script.flix.magneto]>: loading setting values 2020-07-19 19:40:46.931 T:1541736 DEBUG : requested setting () was not found. 2020-07-19 19:40:46.931 T:1541736 DEBUG <CAddonSettings[script.flix.magneto]>: failed to find definition for setting . Creating a setting on-the-fly... 2020-07-19 19:40:46.931 T:1541736 DEBUG : requested setting (testex) was not found.

i96751414 commented 4 years ago

Please note that the settings id must match the provider json name in lowercase with spaces replaced by dots. I will add that to the documentation later. Also, default needs to be either true or false.

BTopbas commented 4 years ago

Please note that the settings id must match the provider json name in lowercase with spaces replaced by dots. I will add that to the documentário later. Also, default needs to be either true or false.

So settings sections will be like this? : <setting id="testex" type="bool" label="testex" default="true"/>

i96751414 commented 4 years ago

Exactly

BTopbas commented 4 years ago

Exactly

Worked! I am very close!! Now I can't parse JSON values. I have returned JSON like this:

{
   "torrent_results":[
      {
         "title":"item_title",
         "size":"item_size",
         "download":"download_magnet"
      },
      {
         "title":"item_title",
         "category":"item_category",
         "download":"download_magnet"
      }
   ]
}

And my provider parse section like this:

"type": "json",
      "rows": "./torrent_results",
      "data": {
        "title": "./title/text()",
        "size": "./size/text()",
        "magnet": "./download/text()"
      }

But its return this error Failed running scraper testex: 'NoneType' object has no attribute 'text' I tried different combinations but always fail.

BTopbas commented 4 years ago

Okey. Now works like a charm!

"type": "json",
      "rows": ".//torrent_results/",
      "data": {
        "title": ".title/text()",
        "size": ".size/text()",
        "magnet": ".download/text()"
      }