From ac07c7e15cc19ef354e61dedc08d7cc146389577 Mon Sep 17 00:00:00 2001 From: Amine A Date: Mon, 4 May 2020 02:59:31 +0200 Subject: [PATCH 1/3] Added user play time to games, and associated sort method to sort by play time. Also added some unique IDs to the ListItems (Steam appid and the unique image hash id provided by Steam API) --- resources/main.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/main.py b/resources/main.py index 5121304..3fe0c19 100644 --- a/resources/main.py +++ b/resources/main.py @@ -39,6 +39,7 @@ def all_games(): xbmcplugin.addDirectoryItems(plugin.handle, directory_items) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) + xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_PLAYCOUNT) xbmcplugin.endOfDirectory(plugin.handle, succeeded=True) @@ -70,6 +71,7 @@ def installed_games(): xbmcplugin.addDirectoryItems(plugin.handle, directory_items) xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) + xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_PLAYCOUNT) xbmcplugin.endOfDirectory(plugin.handle, succeeded=True) @@ -90,7 +92,9 @@ def recent_games(): directory_items = create_directory_items(steam_games_details) xbmcplugin.addDirectoryItems(plugin.handle, directory_items) - xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_UNSORTED) + xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_UNSORTED, "Last played") + xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_PLAYCOUNT) + xbmcplugin.addSortMethod(plugin.handle, xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(plugin.handle, succeeded=True) @@ -128,6 +132,8 @@ def create_directory_items(app_entries): run_url = plugin.url_for(run, appid=appid) item = xbmcgui.ListItem(name) + item.setUniqueIDs({'steam': appid, 'steam_img_icon': app_entry['img_icon_url']}) + item.setInfo('video', {'playcount': app_entry.get('playtime_forever', 0)}) item.addContextMenuItems([('Play', 'RunPlugin(' + run_url + ')'), ('Install', 'RunPlugin(' + plugin.url_for(install, appid=appid) + ')')]) From c906cb8ec9e07388929dc19f95e4b212f78182e1 Mon Sep 17 00:00:00 2001 From: Amine A Date: Mon, 4 May 2020 03:02:20 +0200 Subject: [PATCH 2/3] Disabled content lookup for game items, so that Kodi does not treat our virtual "run game" urls as media URLs --- resources/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/main.py b/resources/main.py index 3fe0c19..5f9c873 100644 --- a/resources/main.py +++ b/resources/main.py @@ -134,6 +134,7 @@ def create_directory_items(app_entries): item = xbmcgui.ListItem(name) item.setUniqueIDs({'steam': appid, 'steam_img_icon': app_entry['img_icon_url']}) item.setInfo('video', {'playcount': app_entry.get('playtime_forever', 0)}) + item.setContentLookup(False) # Tells Kodi not to send HEAD requests (used to determine MIME type for example) to the item's run URL. item.addContextMenuItems([('Play', 'RunPlugin(' + run_url + ')'), ('Install', 'RunPlugin(' + plugin.url_for(install, appid=appid) + ')')]) From 3d453dfb166fa53f8c8f2641d34b9add933fef92 Mon Sep 17 00:00:00 2001 From: Amine A Date: Mon, 4 May 2020 03:02:43 +0200 Subject: [PATCH 3/3] Added a link to the repository in the addon.xml file --- addon.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/addon.xml b/addon.xml index f940670..fefa6ed 100644 --- a/addon.xml +++ b/addon.xml @@ -47,5 +47,6 @@ resources/screenshot-03.jpg resources/screenshot-04.jpg + https://github.com/aanderse/plugin.program.steam.library