[FileItem] Fix mimetype content lookup
[xbmc.git] / addons / metadata.demo.tv / demo.py
blobadbb5060db3a7905bc2c168f9c6b0ff6377a9de5
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
11 import xbmcgui
12 import xbmcplugin
13 import xbmc
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 {}
23 params = get_params()
24 plugin_handle = int(sys.argv[1])
25 action = params.get('action')
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)
32 liz = xbmcgui.ListItem('Demo show 1', offscreen=True)
33 liz.setArt({'thumb': 'DefaultVideo.png'})
34 liz.setProperty('relevance', '0.5')
35 xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/show', listitem=liz, isFolder=True)
36 liz = xbmcgui.ListItem('Demo show 2', offscreen=True)
37 liz.setArt({'thumb': 'DefaultVideo.png'})
38 liz.setProperty('relevance', '0.3')
39 xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/show2', listitem=liz, isFolder=True)
41 elif action == 'getdetails':
42 url = params['url']
43 if url == '/path/to/show':
44 xbmc.log('Get tv show details callback', xbmc.LOGDEBUG)
45 liz = xbmcgui.ListItem('Demo show 1', offscreen=True)
46 tags = liz.getVideoInfoTag()
47 tags.setTitle('Demo show 1')
48 tags.setOriginalTitle('Demo shåvv 1')
49 tags.setSortTitle('2')
50 tags.setUserRating(5)
51 tags.setPlotOutline('Outline yo')
52 tags.setPlot('Plot yo')
53 tags.setTagLine('Tag yo')
54 tags.setDuration(110)
55 tags.setMpaa('T')
56 tags.setTrailer('/home/akva/fluffy/bunnies.mkv')
57 tags.setGenres(['Action', 'Comedy'])
58 tags.setWriters(['None', 'Want', 'To Admit It'])
59 tags.setDirectors(['Director 1', 'Director 2'])
60 tags.setStudios(['Studio1', 'Studio2'])
61 tags.setDateAdded('2016-01-01')
62 tags.setPremiered('2015-01-01')
63 tags.setFirstAired('2007-01-01')
64 tags.setTvShowStatus('Cancelled')
65 tags.setEpisodeGuide('/path/to/show/guide')
66 tags.setTagLine('Family / Mom <3')
67 tags.setRatings({'imdb': (9, 100000), 'tvdb': (8.9, 1000)}, defaultrating='imdb')
68 tags.setUniqueIDs({'imdb': 'tt8938399', 'tmdb': '9837493'}, defaultuniqueid='tvdb')
69 tags.addSeason(1, 'Beautiful')
70 tags.addSeason(2, 'Sun')
71 tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'),
72 xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')])
73 tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
74 tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
75 liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
76 {'image': '/home/akva/Pictures/hawaii-shirt.png',
77 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
78 xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)
80 elif action == 'getepisodelist':
81 url = params['url']
82 xbmc.log(f'Get episode list callback "{url}"', xbmc.LOGDEBUG)
83 if url == '/path/to/show/guide':
84 liz = xbmcgui.ListItem('Demo Episode 1x1', offscreen=True)
85 tags = liz.getVideoInfoTag()
86 tags.setTitle('Demo Episode 1')
87 tags.setSeason(1)
88 tags.setEpisode(1)
89 tags.setFirstAired('2015-01-01')
90 tags.addAvailableArtwork('/path/to/episode1', 'banner')
91 xbmcplugin.addDirectoryItem(handle=plugin_handle, url="/path/to/episode1", listitem=liz, isFolder=False)
93 liz = xbmcgui.ListItem('Demo Episode 2x2', offscreen=True)
94 tags = liz.getVideoInfoTag()
95 tags.setTitle('Demo Episode 2')
96 tags.setSeason(2)
97 tags.setEpisode(2)
98 tags.setFirstAired('2014-01-01')
99 tags.addAvailableArtwork('/path/to/episode2', 'banner')
100 xbmcplugin.addDirectoryItem(handle=plugin_handle, url="/path/to/episode1", listitem=liz, isFolder=False)
102 elif action == 'getepisodedetails':
103 url = params['url']
104 if url == '/path/to/episode1':
105 xbmc.log('Get episode 1 details callback', xbmc.LOGDEBUG)
106 liz = xbmcgui.ListItem('Demo Episode 1', offscreen=True)
107 tags = liz.getVideoInfoTag()
108 tags.setTitle('Demo Episode 1')
109 tags.setOriginalTitle('Demo æpisod 1x1')
110 tags.setSeason(1)
111 tags.setEpisode(1)
112 tags.setUserRating(5)
113 tags.setPlotOutline('Outline yo')
114 tags.setPlot('Plot yo')
115 tags.setTagLine('Tag yo')
116 tags.setDuration(110)
117 tags.setMpaa('T')
118 tags.setTrailer('/home/akva/fluffy/unicorns.mkv')
119 tags.setGenres(['Action', 'Comedy'])
120 tags.setCountries(['Norway', 'Sweden', 'China'])
121 tags.setWriters(['None', 'Want', 'To Admit It'])
122 tags.setDirectors(['Director 1', 'Director 2'])
123 tags.setStudios(['Studio1', 'Studio2'])
124 tags.setDateAdded('2016-01-01')
125 tags.setPremiered('2015-01-01')
126 tags.setFirstAired('2007-01-01')
127 tags.setTagLine('Family / Dad <3')
128 tags.setRatings({'imdb': (9, 100000), 'tvdb': (8.9, 1000)}, defaultrating='imdb')
129 tags.setUniqueIDs({'tvdb': '3894', 'imdb': 'tt384940'}, defaultuniqueid='tvdb')
130 tags.addSeason(1, 'Beautiful')
131 tags.addSeason(2, 'Sun')
132 tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'),
133 xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')])
134 tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
135 tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
136 liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
137 {'image': '/home/akva/Pictures/hawaii-shirt.png',
138 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
139 xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)
141 elif url == '/path/to/episode2':
142 xbmc.log('Get episode 2 details callback', xbmc.LOGDEBUG)
143 liz = xbmcgui.ListItem('Demo Episode 2', offscreen=True)
144 tags = liz.getVideoInfoTag()
145 tags.setTitle('Demo Episode 2')
146 tags.setOriginalTitle('Demo æpisod 2x2')
147 tags.setSortTitle('1')
148 tags.setSeason(2)
149 tags.setEpisode(2)
150 tags.setUserRating(8)
151 tags.setPlotOutline('Outline yo')
152 tags.setPlot('Plot yo')
153 tags.setTagLine('Tag yo')
154 tags.setDuration(110)
155 tags.setMpaa('T')
156 tags.setTrailer('/home/akva/fluffy/puppies.mkv')
157 tags.setGenres(['Action', 'Comedy'])
158 tags.setCountries(['Norway', 'Sweden', 'China'])
159 tags.setWriters(['None', 'Want', 'To Admit It'])
160 tags.setDirectors(['Director 1', 'Director 2'])
161 tags.setStudios(['Studio1', 'Studio2'])
162 tags.setDateAdded('2016-01-01')
163 tags.setPremiered('2015-01-01')
164 tags.setFirstAired('2007-01-01')
165 tags.setTagLine('Something / Else')
166 tags.setRatings({'imdb': (7, 25457), 'tvdb': (8.1, 5478)}, defaultrating='imdb')
167 tags.setUniqueIDs({'tvdb': '3894', 'imdb': 'tt384940'}, defaultuniqueid='tvdb')
168 tags.addSeason(1, 'Beautiful')
169 tags.addSeason(2, 'Sun')
170 tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'),
171 xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')])
172 tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
173 tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
174 liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
175 {'image': '/home/akva/Pictures/hawaii-shirt.png',
176 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
177 xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)
179 elif action == 'nfourl':
180 nfo = params['nfo']
181 xbmc.log('Find url from nfo file', xbmc.LOGDEBUG)
182 liz = xbmcgui.ListItem('Demo show 1', offscreen=True)
183 xbmcplugin.addDirectoryItem(handle=plugin_handle, url="/path/to/show", listitem=liz, isFolder=True)
185 elif action is not None:
186 xbmc.log(f'Action "{action}" not implemented', xbmc.LOGDEBUG)
188 xbmcplugin.endOfDirectory(plugin_handle)