Kodi Community Forum

Full Version: Files.GetDirectory changes in JSON-RPC API v3 (pre Eden)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
When calling Files.GetDirectory(), the default Files.Media parameter is "Files". In the previous Dharma API, this would list all directories and files, regardless of if they were music, video, programs, or pictures.

In v3, it will not list any music, video, or pictures by default. Instead, you have to specify "music", "video", or "pictures" and do a separate call for each one.

I'd suggest to keep the old behavior so that when you don't necessarily know what kind of content will be in the directory, you can specify the "files" media type and get everything in the directory.

I know it's not final, but was this an intentional change or a bug created during the reworking for v3 of the JSON-RPC API?

Thanks,
BradVido
Bumping with hopes that someone knowledgeable with JSON-RPC will see this
bradvido88 Wrote:When calling Files.GetDirectory(), the default Files.Media parameter is "Files". In the previous Dharma API, this would list all directories and files, regardless of if they were music, video, programs, or pictures.

In v3, it will not list any music, video, or pictures by default. Instead, you have to specify "music", "video", or "pictures" and do a separate call for each one.

I'd suggest to keep the old behavior so that when you don't necessarily know what kind of content will be in the directory, you can specify the "files" media type and get everything in the directory.

I know it's not final, but was this an intentional change or a bug created during the reworking for v3 of the JSON-RPC API?

Thanks,
BradVido

Hm works fine for me. I just ran it against several directories on different harddiscs in my development machine and I always get all the files in those directories if I just don't provide a "media" parameter or if I set it to "files".
Montellese Wrote:Hm works fine for me. I just ran it against several directories on different harddiscs in my development machine and I always get all the files in those directories if I just don't provide a "media" parameter or if I set it to "files".
I should have mentioned I'm using this to find content in Plugins, so maybe there is something different than listing a traditional directory.
For example, with bluecop's hulu plugin, the command
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory":"plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11674%3Fshow_id%3D5461\"&mode=\"Menu\"&name=\"Episodes\"&art=\"C%3A%5CUsers%5Cbvidovic%5CAppData%5CRoaming%5CXBMC%5Caddons%5Cplugin.video.hulu%5Cresources%5Cimages%5Cicon.png\"&fanart=\"http%3A%2F%2Fassets.hulu.com%2Fshows%2Fkey_art_christmas_cupid.jpg\"&page=\"1\"&popular=\"false\"&updatelisting=\"false\"", "media":"video"}, "id": "1"}
will return
Code:
{     "id": "1",     "jsonrpc": "2.0",     "result": {         "files": [             {                 "file": "plugin://plugin.video.hulu/?url=\"50107134\"&mode=\"TV_play\"&videoid=\"200999\"",                 "filetype": "file",                 "label": "Christmas Cupid",                 "type": "episode"             }         ],         "limits": {             "end": 1,             "start": 0,             "total": 1         }     } }
but if you change it the media parameter to "files", it returns no videos
Code:
{     "id": "1",     "jsonrpc": "2.0",     "result": {         "files": null,         "limits": {             "end": 0,             "start": 0,             "total": 0         }     } }

BTW- thanks to whoever moved my thread to the development forum Smile
Ah yeah querying plugin directories might make a difference but I'll have to test, although I don't really use any plugins that provide directories so it might take me a while to reproduce.

Could you create a bug report ticket on trac so I don't forget?

Thanks
I committed a fix in https://github.com/xbmc/xbmc/commit/be4c...50cbdfac8a so it should be available in tomorrows nightly build. Thanks for the report.
Montellese Wrote:I committed a fix in https://github.com/xbmc/xbmc/commit/be4c...50cbdfac8a so it should be available in tomorrows nightly build. Thanks for the report.
You're the man. Thanks. I will test it out when it's available in the nightlies.
Hi Montellese,

I'v looked at your code and started porting it to linux, also added command line params.

once its ready i can send it to you and you can have a look, to see if you want to add it in.

let me know?

Cheers,
Shay
mata Wrote:Hi Montellese,

I'v looked at your code and started porting it to linux, also added command line params.

once its ready i can send it to you and you can have a look, to see if you want to add it in.

let me know?

Cheers,
Shay

Uhm why does it need porting to linux? It already is available in all operating systems covered by XBMC (win32, linux, osx, ios).
bradvido88 Wrote:You're the man. Thanks. I will test it out when it's available in the nightlies.
I've tested it and it seems to be working as expected. Thanks again.
I could be wrong but the latest version that i am using has issues with locating config.xml on linux due to path, also the paths and separators are all hardcoded window paths.

I grabbed it from google-code , do i have the wrong version?

Shay
mata Wrote:I could be wrong but the latest version that i am using has issues with locating config.xml on linux due to path, also the paths and separators are all hardcoded window paths.

I grabbed it from google-code , do i have the wrong version?

Shay

I believe you are talking about my supplemental tool XBMC.MyLibrary. I have done some work to make it Linux compatible but haven't updated tr google code project yet. If you have suggestions pass them alOng to me on the thread for that project (in my sig)
yes, i was looking at both threads , and posted on the wrong one
I may have found another bug. I just upgraded from the Eden December 10 build to Eden Beta1, and the Files.GetDirectory() call is no longer returning a "label" for the directory listings in plugins.
This problem does not exist in the Dec. 10 nightly build (f1ae0b6)

Example using the Hulu addon:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory":"plugin://plugin.video.hulu/", "media":"files"}, "id": "1"}
Returns:
Code:
{
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
        "files": [
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11690\"&mode=\"Menu\"&name=\"Popular\"&page=\"1\"&perpage=\"25\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11703\"&mode=\"Menu\"&name=\"Recently+Added\"&page=\"1\"&perpage=\"25\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11742\"&mode=\"Menu\"&name=\"TV\"&page=\"1\"&perpage=\"25\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11810\"&mode=\"Menu\"&name=\"Movies\"&page=\"1\"&perpage=\"25\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2F11898\"&mode=\"Search\"&name=\"Search\"&page=\"1\"&perpage=\"25\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2Fhd_user_queue\"&mode=\"Queue\"&name=\"Queue\"&page=\"1\"&perpage=\"2000\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2Fhd_user_subscriptions\"&mode=\"Subscriptions\"&name=\"Subscriptions\"&page=\"1\"&perpage=\"2000\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            },
            {
                "file": "plugin://plugin.video.hulu/?url=\"http%3A%2F%2Fm.hulu.com%2Fmenu%2Fhd_user_history\"&mode=\"History\"&name=\"History\"&page=\"1\"&perpage=\"2000\"&popular=\"false\"&updatelisting=\"false\"",
                "filetype": "directory",
                "label": "",
                "type": "unknown"
            }
        ],
        "limits": {
            "end": 8,
            "start": 0,
            "total": 8
        }
    }
}
Notice how all the labels are blank. This was not the case before upgrading to Eden beta1.
This may be another bug with the Eden beta1 release (different than my previous post)...

This seems to affect UPNP listings. I can not recurse into the directory listings. This problem does not exist in the Dec. 10 nightly build (f1ae0b6)

Here's an example. I've tried this on two different upnp servers, and both had the same result, so i don't believe it's specific to the upnp server.

To reproduce, the first thing I do is restart XBMC to clear out any caching, then do these JSON-RPC calls.

First call:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory":"upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/", "media":"files"}, "id": "1"}
Response is normal:
Code:
{
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
        "files": [
            {
                "file": "upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/1//",
                "filetype": "directory",
                "label": "Music",
                "type": "unknown"
            },
            {
                "file": "upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/2//",
                "filetype": "directory",
                "label": "Videos",
                "type": "unknown"
            },
            {
                "file": "upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/3//",
                "filetype": "directory",
                "label": "Pictures",
                "type": "unknown"
            },
            {
                "file": "upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/12//",
                "filetype": "directory",
                "label": "Playlists",
                "type": "unknown"
            }
        ],
        "limits": {
            "end": 4,
            "start": 0,
            "total": 4
        }
    }
}
Second call, trying to recurse into the "Videos" subdirectory.
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory":"upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/2//", "media":"files"}, "id": "1"}
But the response from XBMC indicates the call did not work and it returns the label for the root-level UPNP directory:
Code:
{
    "id": "1",
    "jsonrpc": "2.0",
    "result": {
        "files": [
            {
                "file": "upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/2//",
                "filetype": "directory",
                "label": "ONYX: [email protected]:",
                "type": "unknown"
            }
        ],
        "limits": {
            "end": 1,
            "start": 0,
            "total": 1
        }
    }
}
Doing the same thing in the XBMC GUI works (after restarting XBMC). It returns the subdirectory as expected. From xbmc.log, it looks like it is using the same path too, so I'm not sure why the JSON-RPC interface won't return the subdirectory.

xbmc.log opening the same subdirectory in the upnp sever:
Code:
09:22:16 T:6784   DEBUG: CGUIMediaWindow::GetDirectory (upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/)
09:22:16 T:6784   DEBUG:   ParentPath = [upnp://]
09:22:16 T:6744   DEBUG: Thread Background Loader start, auto delete: 0
09:22:16 T:6744   DEBUG: Thread Background Loader 6744 terminating
09:22:17 T:6784   DEBUG: SDLKeyboard: scancode: 48, sym: 0111, unicode: 0000, modifier: 0
09:22:17 T:6784   DEBUG: CApplication::OnKey: up (f080) pressed, action is Up
09:22:17 T:6784   DEBUG: SDLKeyboard: scancode: 1c, sym: 000d, unicode: 000d, modifier: 0
09:22:17 T:6784   DEBUG: CApplication::OnKey: return (f00d) pressed, action is Select
09:22:17 T:6784   DEBUG: CGUIMediaWindow::GetDirectory (upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/2//)
09:22:17 T:6784   DEBUG:   ParentPath = [upnp://40b718d6-f7b8-44a1-8470-5d03596d172b/]
In the GUI, this returns a list of all the content under the videos subdirectory as expected.
Pages: 1 2