| 1 |
# -*- coding: utf-8 -*- |
| 2 |
""" |
| 3 |
Copyright (C) 2005-2021 Team Kodi |
| 4 |
This file is part of Kodi - kodi.tv |
| 5 |
SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
See LICENSES/README.md for more information. |
| 7 |
""" |
| 8 |
import sys |
| 9 |
import urllib.parse |
| 10 |
|
| 11 |
import xbmcgui |
| 12 |
import xbmcplugin |
| 13 |
import xbmc |
| 14 |
|
| 15 |
|
| 16 |
def get_params(): |
| 17 |
param_string = sys.argv[2][1:] |
| 18 |
if param_string: |
| 19 |
return dict(urllib.parse.parse_qsl(param_string)) |
| 20 |
return {} |
| 21 |
|
| 22 |
|
| 23 |
params = get_params() |
| 24 |
plugin_handle = int(sys.argv[1]) |
| 25 |
action = params.get('action') |
| 26 |
|
| 27 |
if action == 'find': |
| 28 |
title = params['title'] |
| 29 |
year = params.get('year', 'not specified') |
| 30 |
xbmc.log(f'Find movie with title "{title}" from year {year}', xbmc.LOGDEBUG) |
| 31 |
|
| 32 |
liz = xbmcgui.ListItem('Demo movie 1', offscreen=True) |
| 33 |
liz.setArt({'thumb': 'DefaultVideo.png'}) |
| 34 |
liz.setProperty('relevance', '0.5') |
| 35 |
xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie', listitem=liz, isFolder=True) |
| 36 |
liz = xbmcgui.ListItem('Demo movie 2', offscreen=True) |
| 37 |
liz.setArt({'thumb': 'DefaultVideo.png'}) |
| 38 |
liz.setProperty('relevance', '0.3') |
| 39 |
xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie2', listitem=liz, isFolder=True) |
| 40 |
|
| 41 |
elif action == 'getdetails': |
| 42 |
url = params['url'] |
| 43 |
if url == '/path/to/movie': |
| 44 |
xbmc.log('Get movie details callback', xbmc.LOGDEBUG) |
| 45 |
liz = xbmcgui.ListItem('Demo movie 1', offscreen=True) |
| 46 |
tags = liz.getVideoInfoTag() |
| 47 |
tags.setTitle('Demo movie 1') |
| 48 |
tags.setOriginalTitle('Demo måvie 1') |
| 49 |
tags.setSortTitle('2') |
| 50 |
tags.setUserRating(5) |
| 51 |
tags.setTop250(3) |
| 52 |
tags.setPlotOutline('Outline yo') |
| 53 |
tags.setPlot('Plot yo') |
| 54 |
tags.setTagLine('Tag yo') |
| 55 |
tags.setDuration(110) |
| 56 |
tags.setMpaa('T') |
| 57 |
tags.setTrailer('/home/akva/bunnies/unicorns.mkv') |
| 58 |
tags.setGenres(['Action', 'Comedy']) |
| 59 |
tags.setWriters(['None', 'Want', 'To Admit It']) |
| 60 |
tags.setDirectors(['Director 1', 'Director 2']) |
| 61 |
tags.setSet('Spiffy creations') |
| 62 |
tags.setSetOverview('Horrors created by spiff') |
| 63 |
tags.setStudios(['Studio1', 'Studio2']) |
| 64 |
tags.setDateAdded('2016-01-01') |
| 65 |
tags.setPremiered('2015-01-01') |
| 66 |
tags.setShowLinks(['Demo show 1']) |
| 67 |
tags.setRatings({'imdb': (9, 100000), 'themoviedb': (8.9, 1000)}, defaultrating='imdb') |
| 68 |
tags.setUniqueIDs({'imdb': 'tt8938399', 'tmdb': '9837493'}, defaultuniqueid='imdb') |
| 69 |
tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'), |
| 70 |
xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')]) |
| 71 |
tags.addAvailableArtwork('DefaultBackFanart.png', 'banner') |
| 72 |
tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster') |
| 73 |
liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'}, |
| 74 |
{'image': '/home/akva/Pictures/hawaii-shirt.png', |
| 75 |
'preview': '/home/akva/Pictures/hawaii-shirt.png'}]) |
| 76 |
xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz) |
| 77 |
|
| 78 |
elif action == 'getartwork': |
| 79 |
url = params['id'] |
| 80 |
if url == '456': |
| 81 |
xbmc.log('Get movie artworks callback', xbmc.LOGDEBUG) |
| 82 |
liz = xbmcgui.ListItem('Demo movie 1', offscreen=True) |
| 83 |
tags = liz.getVideoInfoTag() |
| 84 |
tags.addAvailableArtwork('DefaultBackFanart.png', 'banner') |
| 85 |
tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster') |
| 86 |
liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'}, |
| 87 |
{'image': '/home/akva/Pictures/hawaii-shirt.png', |
| 88 |
'preview': '/home/akva/Pictures/hawaii-shirt.png'}]) |
| 89 |
xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz) |
| 90 |
|
| 91 |
elif action == 'nfourl': |
| 92 |
nfo = params["nfo"] |
| 93 |
xbmc.log('Find url from nfo file', xbmc.LOGDEBUG) |
| 94 |
liz = xbmcgui.ListItem('Demo movie 1', offscreen=True) |
| 95 |
xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie1', listitem=liz, isFolder=True) |
| 96 |
|
| 97 |
elif action is not None: |
| 98 |
xbmc.log(f'Action "{action}" not implemented', xbmc.LOGDEBUG) |
| 99 |
|
| 100 |
xbmcplugin.endOfDirectory(plugin_handle) |