Database version
#1
Question 
Tried to search for it but no luck and also went through the wiki but I might just be blind,
but is there a way to get the video database version through JSON?

/Fox
If you find any spelling mistakes you can keep them ;)
Reply
#2
Nope. Any specific reason why you need it?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
Ya, I'm trying to connect to the db directly.
I have a script that import/export watched status and doing loads of updates through JSON seems quite slow.
If you find any spelling mistakes you can keep them ;)
Reply
#4
You can use RSS to determine database changes or version (?) http://forum.xbmc.org/showthread.php?tid...pid1236284

uNi
Reply
#5
Thanks uNiversal but that don't help me that much, I need know which version xbmc is using on the running system.
With the http api you could just query the version table and get running version but now when that is being removed I have to figure out another way. Sad

Guess I could do it the hard way and make a table with all versions and compare it to the xbmc version, but I would have to keep it updated all the time so that's not so practical.
If you find any spelling mistakes you can keep them ;)
Reply
#6
Was worth a shot, encountered it while on the Image

uNi
Reply
#7
We do not encourage or support direct access to XBMC's database in 3rd party applications (one of the reasons why the HTTP API was removed was the direct database access it provided) because there's a lot that can go sideways so we also don't (want to) provide you with the database version through JSON-RPC.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#8
Perhaps this will help

Code:
ls /home/xbmc/.xbmc/userdata/Database | egrep -o [0-9]+

In my case it outputs this

Code:
15
7
30
72
13
22
4

or for Myvideos*.db

Code:
ls /home/xbmc/.xbmc/userdata/Database/MyVideos*.db | egrep -o [0-9]+

that outputs just 72

You get the idea.

uNi
Reply
#9
Ok thanks for the clear answer Montellese, then I can stop looking and not expect to find something like that. Smile
Sad part is that doing 1k+ updates one at the time through the JSON-RPC isn't that fun.

uNiversal, ya I guess that would work for the local databases, but quite often people have more then one video db due to updates or other reasons so it's not really that safe. And for mysql that don't work at all. Thanks for the ideas though, it's widening my views. Smile
If you find any spelling mistakes you can keep them ;)
Reply
#10
Are you sending batch requests? That could speed up the process greatly..
Image
Reply
#11
What do your update queries do like? Do you update the same info on multiple items based on a specific condition?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#12
(2012-11-13, 08:21)N3MIS15 Wrote: Are you sending batch requests? That could speed up the process greatly..
Didn't know you could!
I'll have a look at that and see how flexible they are, thanks!

Montellese, the basic version just update playcount.
If you find any spelling mistakes you can keep them ;)
Reply
#13
I got ccurious so I made a little python script to see how long it would take to get my all episodes from 1 xbmc instance and find episodes with playcount then update the playcount for those episodes on another instance. i sent the request in 100 episodes per batch and they were sent 1 after the other. here are the results..

Quote:total episodes: 9997
played episodes: 5880
total requests: 59
total time: 0:11:52

and the script incase you want to try it out:

Code:
########
#Gets episodes from server1 and filters out unwatched episodes
#Updates playcounts on server2 and sends in 100 episode batches
#Records time and episode counts when complete
########

import json, urllib2, base64, time, datetime
start = time.time()

server1 = {'hostname': '127.0.0.1', 'port': '1234', 'username': '', 'password': ''}
server2 = {'hostname': '192.168.1.113', 'port': '1234', 'username': '', 'password': ''}

def send_json(request, server):
    addr = 'http://%s:%s/jsonrpc' % (server['hostname'], server['port'])

    for i in range(len(request)):
        request[i]['id'] = i
        request[i]['jsonrpc'] = '2.0'

    data = json.JSONEncoder().encode(request)
    content = {'Content-Type': 'application/json', 'Content-Length': len(data)}

    json_request = urllib2.Request(addr, data, content)

    if server['username'] and server['password']:
        base64string = base64.encodestring('%s:%s' % (server['username'], server['password'])).replace('\n', '')
        json_request.add_header("Authorization", "Basic %s" % base64string)

    response = urllib2.urlopen(json_request).read()
    return json.JSONDecoder().decode(response)


def get_episodes():
    params = [{'method': 'VideoLibrary.GetEpisodes', 'params': {'properties': ['playcount']}}]
    return send_json(params, server1)[0]['result']['episodes']

def chunks(l, n):
    return [l[i:i+n] for i in range(0, len(l), n)]


def update_playcount(chunked_episodes):
    total_chunks = len(chunked_episodes)
    for chunk in range(total_chunks):
        print 'sending chunk %s out of %s' % (chunk+1, total_chunks)
        send_json(chunked_episodes[chunk], server2)


episodes = get_episodes()
played_episodes = [x for x in episodes if x['playcount']]
json_episodes = [{'method': 'VideoLibrary.SetEpisodeDetails', 'params': {'episodeid': x['episodeid'], 'playcount': 1}} for x in played_episodes]
chunked_episodes = chunks(json_episodes, 100)

update_playcount(chunked_episodes)

print 'total episodes: %s' % len(episodes)
print 'played episodes: %s' % len(played_episodes)
print 'total requests: %s' % len(chunked_episodes)
print 'total time: %s' % datetime.timedelta(seconds=int(time.time()-start))


@Montellese there was a lot of gui "flickering" going on while i updated those playcounts. Its most noticable towards the end of the video.
Image
Reply
#14
N3MIS15 that seems similar to what I had on the httpapi so that should be ok.
Thanks for your testing and since I'm new to JSON the script will surely help so thanks for that too! Smile
If you find any spelling mistakes you can keep them ;)
Reply
#15
@N3MIS15: yeah the GUI flickering is a result of XBMC updating the currently active list whenever someone changes the properties of an item. During XBMC's library update those updates are stopped until all the items have been updated because we know that there might be multiple updates. But JSON-RPC handles every request independent of the others so it does the update whenever something changes.

I'm considering if I should add the advanced filtering functionality available in FooLibrary.GetBars methods to FooLibrary.SetBarDetails methods. That would e.g. to allow to update the playcount of all movies (or e.g. all movies with genre "Action" or whatever the filters offer) to a specific value. The problem is that it wouldn't be possible to support things like "increase all playcounts by one" only specific values would be possible. It would still be slower than a direct SQL query but it would allow to send much less JSON-RPC requests and the flickering could be reduced as well because in that case JSON-RPC would know that there are multiple updates incoming.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply

Logout Mark Read Team Forum Stats Members Help
Database version0