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.