diff options
author | Unknown <phates89@gmail.com> | 2017-08-20 22:33:54 +0200 |
---|---|---|
committer | phate89 <phates89@gmail.com> | 2018-02-18 12:37:27 +0100 |
commit | c946a1c849b116147ddae7758bf7aeeb7a56e8b4 (patch) | |
tree | b381684cb11890f10265e8960a36786f1553b003 | |
parent | 1877d5a1a66ba875f0270df7aaef0ad740422081 (diff) |
Add support for nfo url to python scrapers
-rw-r--r-- | addons/metadata.demo.movies/demo.py | 5 | ||||
-rw-r--r-- | addons/metadata.demo.tv/demo.py | 6 | ||||
-rw-r--r-- | xbmc/addons/Scraper.cpp | 21 |
3 files changed, 32 insertions, 0 deletions
diff --git a/addons/metadata.demo.movies/demo.py b/addons/metadata.demo.movies/demo.py index 48ea53df7c..06aa7352fa 100644 --- a/addons/metadata.demo.movies/demo.py +++ b/addons/metadata.demo.movies/demo.py @@ -112,5 +112,10 @@ elif action == 'getartwork': liz.setProperty('video.fanart2.preview', '/home/akva/Pictures/hawaii-shirt.png') liz.setProperty('video.fanart2.dim', '1080') xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), 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) xbmcplugin.endOfDirectory(int(sys.argv[1])) diff --git a/addons/metadata.demo.tv/demo.py b/addons/metadata.demo.tv/demo.py index fa3dadca21..cb55be6dd3 100644 --- a/addons/metadata.demo.tv/demo.py +++ b/addons/metadata.demo.tv/demo.py @@ -196,6 +196,12 @@ elif action == 'getepisodedetails': liz.setProperty('video.actor2.thumb', '/home/akva/Pictures/coffee.jpg') liz.setProperty('video.date_added', '2016-01-01') xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=liz) +elif action == 'nfourl': + nfo=urllib.unquote_plus(params["nfo"]) + print 'Find url from nfo file' + liz=xbmcgui.ListItem('Demo show 1', offscreen=True) + xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url="/path/to/show", listitem=liz, isFolder=True) + diff --git a/xbmc/addons/Scraper.cpp b/xbmc/addons/Scraper.cpp index 2f6ace9f3a..c615d9c3c7 100644 --- a/xbmc/addons/Scraper.cpp +++ b/xbmc/addons/Scraper.cpp @@ -440,6 +440,27 @@ CScraperUrl CScraper::NfoUrl(const std::string &sNfoContent) if (IsNoop()) return scurlRet; + if (m_isPython) + { + std::stringstream str; + str << "plugin://" << ID() << "?action=NfoUrl&nfo=" + << CURL::Encode(sNfoContent); + CFileItemList items; + if (!XFILE::CDirectory::GetDirectory(str.str(), items)) + return scurlRet; + + if (items.Size() == 0) + return scurlRet; + if (items.Size() > 1) + CLog::Log(LOGWARNING, "%s: scraper returned multiple results; using first", __FUNCTION__); + + CScraperUrl::SUrlEntry surl; + surl.m_type = CScraperUrl::URL_TYPE_GENERAL; + surl.m_url = items[0]->GetPath(); + scurlRet.m_url.emplace_back(surl); + return scurlRet; + } + // scraper function takes contents of .nfo file, returns XML (see below) std::vector<std::string> vcsIn; vcsIn.push_back(sNfoContent); |