Created
April 26, 2017 01:22
-
-
Save tskrynnyk/ed5af79e26d649ae368b280b3ad53497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
import sys | |
import os | |
import datetime | |
import json | |
import xbmc | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
home_path = os.getenv('HOME') | |
screenshot_path = home_path + '/docs/images/screenshots/kodi' | |
def get_video_titles(): | |
""" | |
Get info about the currently played file via JSON-RPC. | |
""" | |
request = json.dumps({'jsonrpc': '2.0', | |
'method': 'Player.GetItem', | |
'params': { | |
'properties': ['title', 'showtitle', 'season', 'episode'], | |
'playerid': 1 | |
}, | |
'id': '1', | |
}) | |
return json.loads(xbmc.executeJSONRPC(request))['result']['item'] | |
def get_video_time(): | |
request = json.dumps({'jsonrpc': '2.0', | |
'method': 'Player.GetProperties', | |
'params': { | |
'properties': ['time'], | |
'playerid': 1 | |
}, | |
'id': '1' | |
}) | |
return json.loads(xbmc.executeJSONRPC(request))['result']['time'] | |
vtitles = get_video_titles() | |
vtime = get_video_time() | |
#if vtitles['type'] == 'episode': | |
if vtitles['showtitle']: | |
title = "%s S%02dE%02d %s" % (vtitles['showtitle'], vtitles['season'], vtitles['episode'], vtitles['title']) | |
else: | |
title = vtitles['title'] | |
fname = "%s [%02d:%02d:%02d].png" % (title, vtime['hours'], vtime['minutes'], vtime['seconds']) | |
#xbmc.executebuiltin('Action(ShowSubtitles)') | |
xbmc.executebuiltin('TakeScreenshot(%s)' % (screenshot_path + '/' + fname)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment