aboutsummaryrefslogtreecommitdiff
path: root/addons/metadata.demo.movies
diff options
context:
space:
mode:
authorCastagnaIT <gottardo.stefano.83@gmail.com>2021-10-18 18:11:59 +0200
committerCastagnaIT <gottardo.stefano.83@gmail.com>2021-10-18 19:48:32 +0200
commit1ea8924c319f647cf55c4fc8ebf9f01effdaeb56 (patch)
treeaf8e0262571e2f9af27b6ed82235ba04d278e5c6 /addons/metadata.demo.movies
parentee52b1ee67a9d94a9a9968773f4a2608261277cd (diff)
[addons][python] Updated metadata.demo.movies scraper code
Diffstat (limited to 'addons/metadata.demo.movies')
-rw-r--r--addons/metadata.demo.movies/addon.xml9
-rw-r--r--addons/metadata.demo.movies/demo.py166
2 files changed, 89 insertions, 86 deletions
diff --git a/addons/metadata.demo.movies/addon.xml b/addons/metadata.demo.movies/addon.xml
index a75c3d5a3c..0ac4b4ee1f 100644
--- a/addons/metadata.demo.movies/addon.xml
+++ b/addons/metadata.demo.movies/addon.xml
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="metadata.demo.movies"
name="Demo movies python scraper"
- version="1.0.0"
+ version="1.1.0"
provider-name="spiff">
<requires>
+ <import addon="xbmc.python" version="3.0.0"/>
<import addon="xbmc.metadata" version="2.1.0"/>
</requires>
<extension point="xbmc.metadata.scraper.movies"
library="demo.py"/>
<extension point="xbmc.addon.metadata">
- <summary lang="en">Demo movies python scraper</summary>
- <description lang="en">Demo movies python scraper.</description>
+ <summary lang="en_GB">Demo movies python scraper</summary>
+ <description lang="en_GB">Demo movies python scraper.</description>
<platform>all</platform>
- <license>GPL v2.0</license>
+ <license>GPL-2.0-only</license>
</extension>
</addon>
diff --git a/addons/metadata.demo.movies/demo.py b/addons/metadata.demo.movies/demo.py
index e643c769fa..d32b39c7ec 100644
--- a/addons/metadata.demo.movies/demo.py
+++ b/addons/metadata.demo.movies/demo.py
@@ -1,98 +1,100 @@
-#!/usr/bin/env python3
-# -*- coding: UTF-8 -*-
+# -*- coding: utf-8 -*-
+"""
+ Copyright (C) 2005-2021 Team Kodi
+ This file is part of Kodi - kodi.tv
+ SPDX-License-Identifier: GPL-2.0-or-later
+ See LICENSES/README.md for more information.
+"""
+import sys
+import urllib.parse
-import xbmcplugin,xbmcgui,xbmc,xbmcaddon
-import os,sys,urllib
+import xbmcgui
+import xbmcplugin
+import xbmc
-def get_params():
- param=[]
- paramstring=sys.argv[2]
- if len(paramstring)>=2:
- params=sys.argv[2]
- cleanedparams=params.replace('?','')
- if (params[len(params)-1]=='/'):
- params=params[0:len(params)-2]
- pairsofparams=cleanedparams.split('&')
- param={}
- for i in range(len(pairsofparams)):
- splitparams={}
- splitparams=pairsofparams[i].split('=')
- if (len(splitparams))==2:
- param[splitparams[0]]=splitparams[1]
-
- return param
+def get_params():
+ param_string = sys.argv[2][1:]
+ if param_string:
+ return dict(urllib.parse.parse_qsl(param_string))
+ return {}
-params=get_params()
-action=urllib.unquote_plus(params["action"])
+params = get_params()
+plugin_handle = int(sys.argv[1])
+action = params.get('action')
if action == 'find':
- year = 0
- title=urllib.unquote_plus(params["title"])
- try:
- year=int(urllib.unquote_plus(params["year"]))
- except:
- pass
+ title = params['title']
+ year = params.get('year', 'not specified')
+ xbmc.log(f'Find movie with title "{title}" from year {year}', xbmc.LOGDEBUG)
- print('Find movie with title %s from year %i' %(title, int(year)))
- liz=xbmcgui.ListItem('Demo movie 1', thumbnailImage='DefaultVideo.png', offscreen=True)
+ liz = xbmcgui.ListItem('Demo movie 1', offscreen=True)
+ liz.setArt({'thumb': 'DefaultVideo.png'})
liz.setProperty('relevance', '0.5')
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url="/path/to/movie", listitem=liz, isFolder=True)
- liz=xbmcgui.ListItem('Demo movie 2', thumbnailImage='DefaultVideo.png', offscreen=True)
+ xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie', listitem=liz, isFolder=True)
+ liz = xbmcgui.ListItem('Demo movie 2', offscreen=True)
+ liz.setArt({'thumb': 'DefaultVideo.png'})
liz.setProperty('relevance', '0.3')
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url="/path/to/movie2", listitem=liz, isFolder=True)
+ xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie2', listitem=liz, isFolder=True)
+
elif action == 'getdetails':
- url=urllib.unquote_plus(params["url"])
+ url = params['url']
if url == '/path/to/movie':
- liz=xbmcgui.ListItem('Demo movie 1', offscreen=True)
- liz.setInfo('video',
- {'title': 'Demo movie 1',
- 'originaltitle': 'Demo måvie 1',
- 'sorttitle': '2',
- 'userrating': 5,
- 'top250': 3,
- 'plotoutline': 'Outline yo',
- 'plot': 'Plot yo',
- 'tagline': 'Tag yo',
- 'duration': 110,
- 'mpaa': 'T',
- 'trailer': '/home/akva/bunnies/unicorns.mkv',
- 'genre': ['Action', 'Comedy'],
- 'country': ['Norway', 'Sweden', 'China'],
- 'credits': ['None', 'Want', 'To Admit It'],
- 'director': ['spiff', 'spiff2'],
- 'set': 'Spiffy creations',
- 'setoverview': 'Horrors created by spiff',
- 'studio': ['Studio1', 'Studio2'],
- 'dateadded': '2016-01-01',
- 'premiered': '2015-01-01',
- 'showlink': ['Demo show 1']
- })
- #todo: missing actor thumb aspect
- liz.setRating("imdb", 9, 100000, True )
- liz.setRating("themoviedb", 8.9, 1000)
- liz.setUniqueIDs({ 'imdb': 'tt8938399', 'tmdb' : '9837493' }, 'imdb')
- liz.setCast([{'name': 'spiff', 'role': 'himself', 'thumbnail': '/home/akva/Pictures/fish.jpg', 'order': 2},
- {'name': 'monkey', 'role': 'orange', 'thumbnail': '/home/akva/Pictures/coffee.jpg', 'order': 1}])
- liz.addAvailableArtwork('DefaultBackFanart.png', 'banner')
- liz.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
- liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
- {'image': '/home/akva/Pictures/hawaii-shirt.png', 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
- xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=liz)
+ xbmc.log('Get movie details callback', xbmc.LOGDEBUG)
+ liz = xbmcgui.ListItem('Demo movie 1', offscreen=True)
+ tags = liz.getVideoInfoTag()
+ tags.setTitle('Demo movie 1')
+ tags.setOriginalTitle('Demo måvie 1')
+ tags.setSortTitle('2')
+ tags.setUserRating(5)
+ tags.setTop250(3)
+ tags.setPlotOutline('Outline yo')
+ tags.setPlot('Plot yo')
+ tags.setTagLine('Tag yo')
+ tags.setDuration(110)
+ tags.setMpaa('T')
+ tags.setTrailer('/home/akva/bunnies/unicorns.mkv')
+ tags.setGenres(['Action', 'Comedy'])
+ tags.setWriters(['None', 'Want', 'To Admit It'])
+ tags.setDirectors(['Director 1', 'Director 2'])
+ tags.setSet('Spiffy creations')
+ tags.setSetOverview('Horrors created by spiff')
+ tags.setStudios(['Studio1', 'Studio2'])
+ tags.setDateAdded('2016-01-01')
+ tags.setPremiered('2015-01-01')
+ tags.setShowLinks(['Demo show 1'])
+ tags.setRatings({'imdb': (9, 100000), 'themoviedb': (8.9, 1000)}, defaultRating='imdb')
+ tags.setUniqueIDs({'imdb': 'tt8938399', 'tmdb': '9837493'}, defaultUniqueID='imdb')
+ tags.setCast([xbmc.Actor('spiff', 'himself', order=2, thumbnail='/home/akva/Pictures/fish.jpg'),
+ xbmc.Actor('monkey', 'orange', order=1, thumbnail='/home/akva/Pictures/coffee.jpg')])
+ tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
+ tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
+ liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
+ {'image': '/home/akva/Pictures/hawaii-shirt.png',
+ 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
+ xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)
+
elif action == 'getartwork':
- url=urllib.unquote_plus(params["id"])
+ url = params['id']
if url == '456':
- liz=xbmcgui.ListItem('Demo movie 1', offscreen=True)
- liz.addAvailableArtwork('DefaultBackFanart.png', 'banner')
- liz.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
- liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
- {'image': '/home/akva/Pictures/hawaii-shirt.png', 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
- xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=liz)
+ xbmc.log('Get movie artworks callback', xbmc.LOGDEBUG)
+ liz = xbmcgui.ListItem('Demo movie 1', offscreen=True)
+ tags = liz.getVideoInfoTag()
+ tags.addAvailableArtwork('DefaultBackFanart.png', 'banner')
+ tags.addAvailableArtwork('/home/akva/Pictures/hawaii-shirt.png', 'poster')
+ liz.setAvailableFanart([{'image': 'DefaultBackFanart.png', 'preview': 'DefaultBackFanart.png'},
+ {'image': '/home/akva/Pictures/hawaii-shirt.png',
+ 'preview': '/home/akva/Pictures/hawaii-shirt.png'}])
+ xbmcplugin.setResolvedUrl(handle=plugin_handle, succeeded=True, listitem=liz)
+
elif action == 'nfourl':
- nfo=urllib.unquote_plus(params["nfo"])
- print 'Find url from nfo file'
- liz=xbmcgui.ListItem('Demo movie 1', offscreen=True)
- xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url="/path/to/movie1", listitem=liz, isFolder=True)
+ nfo = params["nfo"]
+ xbmc.log('Find url from nfo file', xbmc.LOGDEBUG)
+ liz = xbmcgui.ListItem('Demo movie 1', offscreen=True)
+ xbmcplugin.addDirectoryItem(handle=plugin_handle, url='/path/to/movie1', listitem=liz, isFolder=True)
+
+elif action is not None:
+ xbmc.log(f'Action "{action}" not implemented', xbmc.LOGDEBUG)
-xbmcplugin.endOfDirectory(int(sys.argv[1]))
+xbmcplugin.endOfDirectory(plugin_handle)