From 6e1aaed2348cec0000ada8b6efb6d8a0aaf83cf7 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Tue, 22 Jul 2014 21:33:39 +0200 Subject: [PATCH 01/11] Added initial Files.AddSource to JSON-RPC --- xbmc/interfaces/json-rpc/FileOperations.cpp | 34 +++++++++++++++++++ xbmc/interfaces/json-rpc/FileOperations.h | 2 ++ .../json-rpc/JSONServiceDescription.cpp | 1 + xbmc/interfaces/json-rpc/schema/methods.json | 14 +++++++- 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 50e74e1c192e8..8eb7d3f456f95 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -227,6 +227,40 @@ JSONRPC_STATUS CFileOperations::Download(const std::string &method, ITransportLa return transport->Download(parameterObject["path"].asString().c_str(), result) ? OK : InvalidParams; } +JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) +{ + std::string media = parameterObject["media"].asString(); + std::string initalName = parameterObject["name"].asString(); + std::string directory = parameterObject["directory"].asString(); + StringUtils::ToLower(media); + + std::vector paths; + paths.push_back(directory); + + CMediaSource share; + unsigned int i, j=2; + bool bConfirmed=false; + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(media); + std::string name = initalName; + while (!bConfirmed) + { + for (i = 0; i < pShares->size(); ++i) + { + if (StringUtils::EqualsNoCase((*pShares)[i].strName, name)) + break; + } + if (i < pShares->size()) // found a match - try next + name = StringUtils::Format("%s (%i)", initalName.c_str(), j++); + else + bConfirmed = true; + } + + share.FromNameAndPaths(media, name, paths); + CMediaSourceSettings::Get().AddShare(media, share); + + return OK; +} + bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItemPtr &item, std::string media /* = "" */, const CVariant ¶meterObject /* = CVariant(CVariant::VariantTypeArray) */) { if (originalItem.get() == NULL) diff --git a/xbmc/interfaces/json-rpc/FileOperations.h b/xbmc/interfaces/json-rpc/FileOperations.h index 25f01b5e18730..78278152d934f 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.h +++ b/xbmc/interfaces/json-rpc/FileOperations.h @@ -34,6 +34,8 @@ namespace JSONRPC static JSONRPC_STATUS PrepareDownload(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); static JSONRPC_STATUS Download(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static JSONRPC_STATUS AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result); + static bool FillFileItem(const CFileItemPtr &originalItem, CFileItemPtr &item, std::string media = "", const CVariant ¶meterObject = CVariant(CVariant::VariantTypeArray)); static bool FillFileItemList(const CVariant ¶meterObject, CFileItemList &list); }; diff --git a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp index ec889f37278e8..d81ce937e6754 100644 --- a/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp +++ b/xbmc/interfaces/json-rpc/JSONServiceDescription.cpp @@ -98,6 +98,7 @@ JsonRpcMethodMap CJSONServiceDescription::m_methodMaps[] = { { "Files.GetFileDetails", CFileOperations::GetFileDetails }, { "Files.PrepareDownload", CFileOperations::PrepareDownload }, { "Files.Download", CFileOperations::Download }, + { "Files.AddSource", CFileOperations::AddSource }, // Music Library { "AudioLibrary.GetArtists", CAudioLibrary::GetArtists }, diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index d7175a764d0b7..cbd2db8dd5aaa 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -583,6 +583,18 @@ ], "returns": { "type": "any", "required": true } }, + "Files.AddSource": { + "type": "method", + "description": "Add a source for the media windows", + "transport": "Response", + "permission": "ReadData", + "params": [ + { "name": "media", "$ref": "Files.Media", "required": true }, + { "name": "name", "type": "string", "required": true }, + { "name": "directory", "type": "string", "required": true } + ], + "returns": { "type": "any", "required": true } + }, "Files.GetDirectory": { "type": "method", "description": "Get the directories and files in the given directory", @@ -2323,4 +2335,4 @@ ], "returns": "string" } -} \ No newline at end of file +} From b17978ca8e1ea65577741c8580bb884bce193e7d Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Wed, 23 Jul 2014 09:55:19 +0200 Subject: [PATCH 02/11] initial Files.AddSource to JSON-RPC --- xbmc/interfaces/json-rpc/FileOperations.cpp | 21 +++++--------------- xbmc/interfaces/json-rpc/schema/methods.json | 2 +- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 8eb7d3f456f95..8bdeb70b6ed14 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -230,35 +230,24 @@ JSONRPC_STATUS CFileOperations::Download(const std::string &method, ITransportLa JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { std::string media = parameterObject["media"].asString(); - std::string initalName = parameterObject["name"].asString(); + std::string name = parameterObject["name"].asString(); std::string directory = parameterObject["directory"].asString(); - StringUtils::ToLower(media); std::vector paths; paths.push_back(directory); CMediaSource share; - unsigned int i, j=2; - bool bConfirmed=false; VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(media); - std::string name = initalName; - while (!bConfirmed) + for (unsigned int i = 0; i < pShares->size(); ++i) { - for (i = 0; i < pShares->size(); ++i) - { - if (StringUtils::EqualsNoCase((*pShares)[i].strName, name)) - break; - } - if (i < pShares->size()) // found a match - try next - name = StringUtils::Format("%s (%i)", initalName.c_str(), j++); - else - bConfirmed = true; + if (StringUtils::EqualsNoCase((*pShares)[i].strName, name)) + return InvalidParams; } share.FromNameAndPaths(media, name, paths); CMediaSourceSettings::Get().AddShare(media, share); - return OK; + return ACK; } bool CFileOperations::FillFileItem(const CFileItemPtr &originalItem, CFileItemPtr &item, std::string media /* = "" */, const CVariant ¶meterObject /* = CVariant(CVariant::VariantTypeArray) */) diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index cbd2db8dd5aaa..efcd2aab0538d 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -593,7 +593,7 @@ { "name": "name", "type": "string", "required": true }, { "name": "directory", "type": "string", "required": true } ], - "returns": { "type": "any", "required": true } + "returns": { "type": "string", "required": true } }, "Files.GetDirectory": { "type": "method", From e72798dee07d1ddcc2aa0cf9e1224fdcf166b24b Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Thu, 24 Jul 2014 12:19:34 +0200 Subject: [PATCH 03/11] Added content to Files.AddSource --- xbmc/interfaces/json-rpc/FileOperations.cpp | 45 ++++++++++++++++++++ xbmc/interfaces/json-rpc/schema/methods.json | 3 +- xbmc/interfaces/json-rpc/schema/types.json | 4 ++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 8bdeb70b6ed14..1da1ad449f60d 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -31,6 +31,12 @@ #include "URL.h" #include "utils/URIUtils.h" #include "utils/FileUtils.h" +#include "Application.h" +#include "addons/AddonManager.h" +#include "addons/Scraper.h" +#include "video/VideoDatabase.h" +#include "video/VideoInfoScanner.h" +#include "music/MusicDatabase.h" using namespace XFILE; using namespace JSONRPC; @@ -227,11 +233,27 @@ JSONRPC_STATUS CFileOperations::Download(const std::string &method, ITransportLa return transport->Download(parameterObject["path"].asString().c_str(), result) ? OK : InvalidParams; } +CONTENT_TYPE contentTypeFromString(const std::string &content) { + if (content == "movies") + return CONTENT_MOVIES; + else if (content == "tvshows") + return CONTENT_TVSHOWS; + else if (content == "musicvideos") + return CONTENT_MUSICVIDEOS; + else if (content == "albums") + return CONTENT_ALBUMS; + else if (content == "artists") + return CONTENT_ARTISTS; + else + return CONTENT_NONE; +} + JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { std::string media = parameterObject["media"].asString(); std::string name = parameterObject["name"].asString(); std::string directory = parameterObject["directory"].asString(); + std::string content = parameterObject["content"].asString("none"); std::vector paths; paths.push_back(directory); @@ -247,6 +269,29 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL share.FromNameAndPaths(media, name, paths); CMediaSourceSettings::Get().AddShare(media, share); + if (content != "none") + { + CONTENT_TYPE c = contentTypeFromString(content); + + ADDON::AddonPtr scraperAddon; + ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(c), scraperAddon); + ADDON::ScraperPtr scraper = boost::dynamic_pointer_cast(scraperAddon); + + if (media == "video" && scraper) + { + CVideoDatabase db; + db.Open(); + + VIDEO::SScanSettings settings; + db.SetScraperForPath(directory, scraper, settings); + } else if (media == "music") { + CMusicDatabase db; + db.Open(); + + db.SetScraperForPath(directory, scraper); + } + } + return ACK; } diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index efcd2aab0538d..79907fb949dd7 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -590,10 +590,11 @@ "permission": "ReadData", "params": [ { "name": "media", "$ref": "Files.Media", "required": true }, + { "name": "content", "$ref": "Files.Content", "required": false }, { "name": "name", "type": "string", "required": true }, { "name": "directory", "type": "string", "required": true } ], - "returns": { "type": "string", "required": true } + "returns": "string" }, "Files.GetDirectory": { "type": "method", diff --git a/xbmc/interfaces/json-rpc/schema/types.json b/xbmc/interfaces/json-rpc/schema/types.json index 8912630503d6b..1962f4f913d95 100644 --- a/xbmc/interfaces/json-rpc/schema/types.json +++ b/xbmc/interfaces/json-rpc/schema/types.json @@ -78,6 +78,10 @@ "type": "string", "enum": [ "video", "music", "pictures", "files", "programs" ] }, + "Files.Content": { + "type": "string", + "enum": [ "movies", "tvshows", "musicvideos", "albums", "artists" ] + }, "List.Amount": { "type": "integer", "default": -1, From a273b389e55109a2f68da2dd2e921068cd14f7a0 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Fri, 25 Jul 2014 08:02:30 +0200 Subject: [PATCH 04/11] Files.AddSource combined media and content --- xbmc/interfaces/json-rpc/FileOperations.cpp | 30 ++++++-------------- xbmc/interfaces/json-rpc/schema/methods.json | 5 ++-- xbmc/interfaces/json-rpc/schema/types.json | 2 +- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 1da1ad449f60d..398e54891facc 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -240,24 +240,22 @@ CONTENT_TYPE contentTypeFromString(const std::string &content) { return CONTENT_TVSHOWS; else if (content == "musicvideos") return CONTENT_MUSICVIDEOS; - else if (content == "albums") - return CONTENT_ALBUMS; - else if (content == "artists") - return CONTENT_ARTISTS; else return CONTENT_NONE; } JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { - std::string media = parameterObject["media"].asString(); std::string name = parameterObject["name"].asString(); std::string directory = parameterObject["directory"].asString(); std::string content = parameterObject["content"].asString("none"); + std::vector contents = StringUtils::Split(content, "."); std::vector paths; paths.push_back(directory); + std::string media = contents[0] == "audio" ? "music" : contents[0]; + CMediaSource share; VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(media); for (unsigned int i = 0; i < pShares->size(); ++i) @@ -269,27 +267,17 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL share.FromNameAndPaths(media, name, paths); CMediaSourceSettings::Get().AddShare(media, share); - if (content != "none") + if (media == "video" && contents.size() > 1) { - CONTENT_TYPE c = contentTypeFromString(content); - ADDON::AddonPtr scraperAddon; - ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(c), scraperAddon); + ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(contentTypeFromString(contents[1])), scraperAddon); ADDON::ScraperPtr scraper = boost::dynamic_pointer_cast(scraperAddon); - if (media == "video" && scraper) - { - CVideoDatabase db; - db.Open(); - - VIDEO::SScanSettings settings; - db.SetScraperForPath(directory, scraper, settings); - } else if (media == "music") { - CMusicDatabase db; - db.Open(); + CVideoDatabase db; + db.Open(); - db.SetScraperForPath(directory, scraper); - } + VIDEO::SScanSettings settings; + db.SetScraperForPath(directory, scraper, settings); } return ACK; diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index 79907fb949dd7..f71a30c82c8ce 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -589,10 +589,9 @@ "transport": "Response", "permission": "ReadData", "params": [ - { "name": "media", "$ref": "Files.Media", "required": true }, - { "name": "content", "$ref": "Files.Content", "required": false }, { "name": "name", "type": "string", "required": true }, - { "name": "directory", "type": "string", "required": true } + { "name": "directory", "type": "string", "required": true }, + { "name": "content", "$ref": "Files.Content", "required": false } ], "returns": "string" }, diff --git a/xbmc/interfaces/json-rpc/schema/types.json b/xbmc/interfaces/json-rpc/schema/types.json index 1962f4f913d95..698355eef54e1 100644 --- a/xbmc/interfaces/json-rpc/schema/types.json +++ b/xbmc/interfaces/json-rpc/schema/types.json @@ -80,7 +80,7 @@ }, "Files.Content": { "type": "string", - "enum": [ "movies", "tvshows", "musicvideos", "albums", "artists" ] + "enum": [ "video", "video.movies", "video.tvshows", "video.musicvideos", "audio.music", "pictures", "files", "programs" ] }, "List.Amount": { "type": "integer", From 6c5752578e87323a9f37f4e271fa7fd7ec0df793 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Fri, 10 Oct 2014 18:32:35 +0100 Subject: [PATCH 05/11] Added stupid smb specific user/password prune which should be moved to a better place probably --- xbmc/interfaces/json-rpc/FileOperations.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 398e54891facc..a9d0f42c5c3a1 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -37,6 +37,7 @@ #include "video/VideoDatabase.h" #include "video/VideoInfoScanner.h" #include "music/MusicDatabase.h" +#include "PasswordManager.h" using namespace XFILE; using namespace JSONRPC; @@ -265,6 +266,24 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL } share.FromNameAndPaths(media, name, paths); + + for (unsigned int i = 0; i < paths.size(); i++) + { + if (!paths[i].empty()) + { // strip off the user and password for smb paths (anything that the password manager can auth) + // and add the user/pass to the password manager - note, we haven't confirmed that it works + // at this point, but if it doesn't, the user will get prompted anyway in SMBDirectory. + CURL url(paths[i]); + if (url.IsProtocol("smb")) + { + CPasswordManager::GetInstance().SaveAuthenticatedURL(url); + url.SetPassword(""); + url.SetUserName(""); + } + paths.push_back(url.Get()); + } + } + CMediaSourceSettings::Get().AddShare(media, share); if (media == "video" && contents.size() > 1) From ae7d70e47b8641663a9e65c6ddcec46b1d6a1d60 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sat, 11 Oct 2014 17:08:11 +0100 Subject: [PATCH 06/11] Moved around the password removal and moved to iterators and added multiple directories to be allowed as parameter --- xbmc/interfaces/json-rpc/FileOperations.cpp | 40 ++++++++++++-------- xbmc/interfaces/json-rpc/schema/methods.json | 2 +- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index a9d0f42c5c3a1..7abe3e491f463 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -248,42 +248,49 @@ CONTENT_TYPE contentTypeFromString(const std::string &content) { JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { std::string name = parameterObject["name"].asString(); - std::string directory = parameterObject["directory"].asString(); std::string content = parameterObject["content"].asString("none"); - std::vector contents = StringUtils::Split(content, "."); - std::vector paths; - paths.push_back(directory); - std::string media = contents[0] == "audio" ? "music" : contents[0]; + CVariant directory = parameterObject["directory"]; + std::vector paths; - CMediaSource share; - VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(media); - for (unsigned int i = 0; i < pShares->size(); ++i) + if (directory.isArray()) { - if (StringUtils::EqualsNoCase((*pShares)[i].strName, name)) - return InvalidParams; + for (CVariant::iterator_array itr = directory.begin_array(); itr != directory.end_array(); itr++) + paths.push_back(itr->asString()); } + else + paths.push_back(directory.asString()); - share.FromNameAndPaths(media, name, paths); + std::string media = contents[0] == "audio" ? "music" : contents[0]; - for (unsigned int i = 0; i < paths.size(); i++) + for (std::vector::iterator itr = paths.begin(); itr != paths.end(); itr++) { - if (!paths[i].empty()) + if (!itr->empty()) { // strip off the user and password for smb paths (anything that the password manager can auth) // and add the user/pass to the password manager - note, we haven't confirmed that it works // at this point, but if it doesn't, the user will get prompted anyway in SMBDirectory. - CURL url(paths[i]); + CURL url(*itr); if (url.IsProtocol("smb")) { CPasswordManager::GetInstance().SaveAuthenticatedURL(url); url.SetPassword(""); url.SetUserName(""); } - paths.push_back(url.Get()); + itr->assign(url.Get()); } } + CMediaSource share; + VECSOURCES* pShares = CMediaSourceSettings::Get().GetSources(media); + for (VECSOURCES::iterator itr = pShares->begin(); itr != pShares->end(); itr++) + { + if (StringUtils::EqualsNoCase(itr->strName, name)) + return InvalidParams; + } + + share.FromNameAndPaths(media, name, paths); + CMediaSourceSettings::Get().AddShare(media, share); if (media == "video" && contents.size() > 1) @@ -296,7 +303,8 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL db.Open(); VIDEO::SScanSettings settings; - db.SetScraperForPath(directory, scraper, settings); + for (std::vector::const_iterator itr = paths.begin(); itr != paths.end(); itr++) + db.SetScraperForPath(*itr, scraper, settings); } return ACK; diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index f71a30c82c8ce..aa17c4e5aafa3 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -590,7 +590,7 @@ "permission": "ReadData", "params": [ { "name": "name", "type": "string", "required": true }, - { "name": "directory", "type": "string", "required": true }, + { "name": "directory", "type": [ "string", { "$ref": "Array.String" } ], "required": true }, { "name": "content", "$ref": "Files.Content", "required": false } ], "returns": "string" From a28758ea4414af54e80745e7c2bc778d0b2e196d Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sun, 12 Oct 2014 09:18:56 +0100 Subject: [PATCH 07/11] Switched to use scraper TranslateContent --- xbmc/interfaces/json-rpc/FileOperations.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 7abe3e491f463..c41bf987e55c7 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -296,7 +296,7 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL if (media == "video" && contents.size() > 1) { ADDON::AddonPtr scraperAddon; - ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(contentTypeFromString(contents[1])), scraperAddon); + ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(ADDON::TranslateContent(contents[1])), scraperAddon); ADDON::ScraperPtr scraper = boost::dynamic_pointer_cast(scraperAddon); CVideoDatabase db; From 0b509e86e7c8bd565b508a27c321eb0e49b69abe Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sun, 12 Oct 2014 09:23:05 +0100 Subject: [PATCH 08/11] Fixed required true needed in refed item --- xbmc/interfaces/json-rpc/schema/methods.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index aa17c4e5aafa3..a0b68be2c8fcc 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -590,7 +590,7 @@ "permission": "ReadData", "params": [ { "name": "name", "type": "string", "required": true }, - { "name": "directory", "type": [ "string", { "$ref": "Array.String" } ], "required": true }, + { "name": "directory", "type": [ "string", { "$ref": "Array.String", "required": true } ], "required": true }, { "name": "content", "$ref": "Files.Content", "required": false } ], "returns": "string" From 9627f560217f70a2d0797852217fa9259f33e288 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sun, 12 Oct 2014 09:48:18 +0100 Subject: [PATCH 09/11] Check for no scraper addon in Files.AddSource --- xbmc/interfaces/json-rpc/FileOperations.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index c41bf987e55c7..c07ef1b41dae1 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -296,15 +296,17 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL if (media == "video" && contents.size() > 1) { ADDON::AddonPtr scraperAddon; - ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(ADDON::TranslateContent(contents[1])), scraperAddon); - ADDON::ScraperPtr scraper = boost::dynamic_pointer_cast(scraperAddon); + if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(ADDON::TranslateContent(contents[1])), scraperAddon)) + { + ADDON::ScraperPtr scraper = boost::dynamic_pointer_cast(scraperAddon); - CVideoDatabase db; - db.Open(); + CVideoDatabase db; + db.Open(); - VIDEO::SScanSettings settings; - for (std::vector::const_iterator itr = paths.begin(); itr != paths.end(); itr++) - db.SetScraperForPath(*itr, scraper, settings); + VIDEO::SScanSettings settings; + for (std::vector::const_iterator itr = paths.begin(); itr != paths.end(); itr++) + db.SetScraperForPath(*itr, scraper, settings); + } } return ACK; From 90636ffde54da413ad541e693ed8e9707fcdf010 Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sun, 12 Oct 2014 11:16:10 +0100 Subject: [PATCH 10/11] Add an audio.music path to the music database so its possible to scan --- xbmc/interfaces/json-rpc/FileOperations.cpp | 10 ++++++++++ xbmc/interfaces/json-rpc/schema/types.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index c07ef1b41dae1..46be011f5252a 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -308,6 +308,16 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL db.SetScraperForPath(*itr, scraper, settings); } } + else if (content == "audio.music") + { + CMusicDatabase db; + db.Open(); + + for (std::vector::const_iterator itr = paths.begin(); itr != paths.end(); itr++) + db.AddPath(*itr); + + db.Close(); + } return ACK; } diff --git a/xbmc/interfaces/json-rpc/schema/types.json b/xbmc/interfaces/json-rpc/schema/types.json index 698355eef54e1..d4693d62c9ca5 100644 --- a/xbmc/interfaces/json-rpc/schema/types.json +++ b/xbmc/interfaces/json-rpc/schema/types.json @@ -80,7 +80,7 @@ }, "Files.Content": { "type": "string", - "enum": [ "video", "video.movies", "video.tvshows", "video.musicvideos", "audio.music", "pictures", "files", "programs" ] + "enum": [ "video", "video.movies", "video.tvshows", "video.musicvideos", "audio", "audio.music", "pictures", "files", "programs" ] }, "List.Amount": { "type": "integer", From 0ec814894c97ac1c5f1f35f2e92193fcfda4d59f Mon Sep 17 00:00:00 2001 From: Tobias Arrskog Date: Sun, 12 Oct 2014 11:38:39 +0100 Subject: [PATCH 11/11] Added videosettings to the Files.AddSource --- xbmc/interfaces/json-rpc/FileOperations.cpp | 7 +++++++ xbmc/interfaces/json-rpc/schema/methods.json | 13 ++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xbmc/interfaces/json-rpc/FileOperations.cpp b/xbmc/interfaces/json-rpc/FileOperations.cpp index 46be011f5252a..79614a3cea0fd 100644 --- a/xbmc/interfaces/json-rpc/FileOperations.cpp +++ b/xbmc/interfaces/json-rpc/FileOperations.cpp @@ -304,6 +304,13 @@ JSONRPC_STATUS CFileOperations::AddSource(const std::string &method, ITransportL db.Open(); VIDEO::SScanSettings settings; + + settings.parent_name = parameterObject["parent_name"].asBoolean(); + settings.parent_name_root = parameterObject["parent_name_root"].asBoolean(); + settings.recurse = parameterObject["recurse"].asBoolean(); + settings.noupdate = parameterObject["noupdate"].asBoolean(); + settings.exclude = parameterObject["exclude"].asBoolean(); + for (std::vector::const_iterator itr = paths.begin(); itr != paths.end(); itr++) db.SetScraperForPath(*itr, scraper, settings); } diff --git a/xbmc/interfaces/json-rpc/schema/methods.json b/xbmc/interfaces/json-rpc/schema/methods.json index a0b68be2c8fcc..89769b0843872 100644 --- a/xbmc/interfaces/json-rpc/schema/methods.json +++ b/xbmc/interfaces/json-rpc/schema/methods.json @@ -591,7 +591,18 @@ "params": [ { "name": "name", "type": "string", "required": true }, { "name": "directory", "type": [ "string", { "$ref": "Array.String", "required": true } ], "required": true }, - { "name": "content", "$ref": "Files.Content", "required": false } + { "name": "content", "$ref": "Files.Content", "required": false }, + { + "name": "settings", + "properties": { + "parent_name": { "type": "boolean", "required": false }, + "parent_name_root": { "type": "boolean", "required": false }, + "recurse": { "type": "boolean", "required": false, "default": true }, + "noupdate": { "type": "boolean", "required": false }, + "exclude": { "type": "boolean", "required": false } + }, + "required": false + } ], "returns": "string" },