Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changed: Split scrapers into separate extension points per content ty…

…pe. Cleanup to come.

git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@30619 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
  • Loading branch information...
commit 6a9704f737fbf1957a9deefcd1e14c0314c04661 1 parent d5dddfb
jmarshallnz authored
View
9 xbmc/FileSystem/AddonsDirectory.cpp
@@ -113,7 +113,8 @@ bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &it
items.m_strPath = strPath;
// add content types
- if (type == ADDON_SCRAPER && path.GetOptions().IsEmpty())
+ // FIXME: Categorisation of addons may need improving
+/* if (type == ADDON_SCRAPER && path.GetOptions().IsEmpty())
{
for (int i=CONTENT_MOVIES;i<CONTENT_ARTISTS;++i)
{
@@ -149,14 +150,14 @@ bool CAddonsDirectory::GetDirectory(const CStdString& strPath, CFileItemList &it
CStdStringArray array;
StringUtils::SplitString(path.GetOptions(),"=",array);
content = TranslateContent(array[1]);
- }
+ }*/
for (unsigned int j=0;j<addons.size();++j)
{
if (addons[j]->Type() != type)
addons.erase(addons.begin()+j--);
- else if (type == ADDON_SCRAPER &&
+ /* else if (type == ADDON_SCRAPER &&
!addons[j]->Supports(content))
- addons.erase(addons.begin()+j--);
+ addons.erase(addons.begin()+j--);*/
}
}
View
5 xbmc/GUIDialogContentSettings.cpp
@@ -245,12 +245,13 @@ void CGUIDialogContentSettings::FillContentTypes(const CONTENT_TYPE &content)
{
// grab all scrapers which support this content-type
VECADDONS addons;
- if (!CAddonMgr::Get().GetAddons(ADDON_SCRAPER, addons, content))
+ TYPE type = ScraperTypeFromContent(content);
+ if (!CAddonMgr::Get().GetAddons(type, addons))
return;
AddonPtr addon;
CStdString defaultID;
- if (CAddonMgr::Get().GetDefault(ADDON_SCRAPER, addon, content))
+ if (CAddonMgr::Get().GetDefault(type, addon))
defaultID = addon->ID();
for (IVECADDONS it = addons.begin(); it != addons.end(); it++)
View
8 xbmc/GUISettings.cpp
@@ -301,7 +301,7 @@ void CGUISettings::Initialize()
AddBool(ml, "musiclibrary.showcompilationartists", 13414, true);
AddSeparator(ml,"musiclibrary.sep1");
AddBool(ml,"musiclibrary.downloadinfo", 20192, false);
- AddDefaultAddon(ml, "musiclibrary.scraper", 20194, "metadata.allmusic.com", ADDON_SCRAPER, CONTENT_ALBUMS);
+ AddDefaultAddon(ml, "musiclibrary.scraper", 20194, "metadata.allmusic.com", ADDON_SCRAPER_ALBUMS);
AddBool(ml, "musiclibrary.updateonstartup", 22000, false);
AddBool(NULL, "musiclibrary.backgroundupdate", 22001, false);
AddSeparator(ml,"musiclibrary.sep2");
@@ -682,9 +682,9 @@ void CGUISettings::Initialize()
AddBool(NULL, "postprocessing.dering", 311, false);
CSettingsCategory* scp = AddCategory(5, "scrapers", 21412);
- AddDefaultAddon(scp, "scrapers.moviedefault", 21413, "metadata.themoviedb.org", ADDON_SCRAPER, CONTENT_MOVIES);
- AddDefaultAddon(scp, "scrapers.tvshowdefault", 21414, "metadata.tvdb.com", ADDON_SCRAPER, CONTENT_TVSHOWS);
- AddDefaultAddon(scp, "scrapers.musicvideodefault", 21415, "metadata.mtv.com", ADDON_SCRAPER, CONTENT_MUSICVIDEOS);
+ AddDefaultAddon(scp, "scrapers.moviedefault", 21413, "metadata.themoviedb.org", ADDON_SCRAPER_MOVIES);
+ AddDefaultAddon(scp, "scrapers.tvshowdefault", 21414, "metadata.tvdb.com", ADDON_SCRAPER_TVSHOWS);
+ AddDefaultAddon(scp, "scrapers.musicvideodefault", 21415, "metadata.mtv.com", ADDON_SCRAPER_MUSICVIDEOS);
AddSeparator(scp,"scrapers.sep2");
AddBool(scp, "scrapers.langfallback", 21416, false);
View
2  xbmc/GUIWindowMusicNav.cpp
@@ -732,7 +732,7 @@ bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
if (!m_musicdatabase.GetScraperForPath(path,scraper))
{
ADDON::AddonPtr defaultScraper;
- if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER, defaultScraper, CONTENT_ALBUMS))
+ if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER_ALBUMS, defaultScraper))
{
scraper = boost::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper->Clone(defaultScraper));
}
View
6 xbmc/MusicDatabase.cpp
@@ -4097,7 +4097,8 @@ bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::Scraper
else
{ // use default scraper for this content type
ADDON::AddonPtr defaultScraper;
- if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER, defaultScraper, content))
+ // FIXME: Content is none, so what content type should we be using? This works currently as we only have one default music scraper
+ if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER_ALBUMS, defaultScraper))
{
info = boost::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper->Clone(defaultScraper));
if (info)
@@ -4112,7 +4113,8 @@ bool CMusicDatabase::GetScraperForPath(const CStdString& strPath, ADDON::Scraper
if (!info)
{ // use default music scraper instead
ADDON::AddonPtr addon;
- if(ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER, addon, CONTENT_ALBUMS))
+ // FIXME: Content is none, so what content type should we be using? This works currently as we only have one default music scraper
+ if(ADDON::CAddonMgr::Get().GetDefault(ADDON::ADDON_SCRAPER_ALBUMS, addon))
{
info = boost::dynamic_pointer_cast<ADDON::CScraper>(addon);
return (info);
View
4 xbmc/NfoFile.cpp
@@ -70,7 +70,7 @@ CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr
AddonPtr addon;
ScraperPtr defaultScraper;
- if (!CAddonMgr::Get().GetDefault(ADDON_SCRAPER, addon, m_content))
+ if (!CAddonMgr::Get().GetDefault(ScraperTypeFromContent(m_content), addon))
return NO_NFO;
else
defaultScraper = boost::dynamic_pointer_cast<CScraper>(addon);
@@ -125,7 +125,7 @@ CNfoFile::NFOResult CNfoFile::Create(const CStdString& strPath, const ScraperPtr
if (g_guiSettings.GetBool("scrapers.langfallback"))
{
VECADDONS addons;
- CAddonMgr::Get().GetAddons(ADDON_SCRAPER,addons);
+ CAddonMgr::Get().GetAddons(ScraperTypeFromContent(m_content),addons);
for (unsigned i=0;i<addons.size();++i)
{
// skip selected and default scraper
View
69 xbmc/addons/Addon.cpp
@@ -70,21 +70,25 @@ typedef struct
} TypeMapping;
static const TypeMapping types[] =
- {{"unknown", ADDON_UNKNOWN, 0 },
- {"xbmc.metadata.scraper", ADDON_SCRAPER, 24007 },
- {"xbmc.metadata.scraper.library", ADDON_SCRAPER_LIBRARY, 0 },
- {"xbmc.ui.screensaver", ADDON_SCREENSAVER, 24008 },
- {"xbmc.player.musicviz", ADDON_VIZ, 24010 },
- {"visualization-library", ADDON_VIZ_LIBRARY, 0 },
- {"xbmc.python.pluginsource", ADDON_PLUGIN, 24005 },
- {"xbmc.python.script", ADDON_SCRIPT, 24009 },
- {"xbmc.python.weather", ADDON_SCRIPT_WEATHER, 24027 },
- {"xbmc.python.subtitles", ADDON_SCRIPT_SUBTITLES, 24012 },
- {"xbmc.python.lyrics", ADDON_SCRIPT_LYRICS, 24013 },
- {"xbmc.python.library", ADDON_SCRIPT_LIBRARY, 24014 },
- {"xbmc.gui.skin", ADDON_SKIN, 166 },
- {"xbmc.addon.repository", ADDON_REPOSITORY, 24011 },
- {"pvrclient", ADDON_PVRDLL, 0 }};
+ {{"unknown", ADDON_UNKNOWN, 0 },
+ {"xbmc.metadata.scraper.albums", ADDON_SCRAPER_ALBUMS, 24007 },
+ {"xbmc.metadata.scraper.artists", ADDON_SCRAPER_ARTISTS, 24007 },
+ {"xbmc.metadata.scraper.movies", ADDON_SCRAPER_MOVIES, 24007 },
+ {"xbmc.metadata.scraper.musicvideos", ADDON_SCRAPER_MUSICVIDEOS, 24007 },
+ {"xbmc.metadata.scraper.tvshows", ADDON_SCRAPER_TVSHOWS, 24007 },
+ {"xbmc.metadata.scraper.library", ADDON_SCRAPER_LIBRARY, 0 },
+ {"xbmc.ui.screensaver", ADDON_SCREENSAVER, 24008 },
+ {"xbmc.player.musicviz", ADDON_VIZ, 24010 },
+ {"visualization-library", ADDON_VIZ_LIBRARY, 0 },
+ {"xbmc.python.pluginsource", ADDON_PLUGIN, 24005 },
+ {"xbmc.python.script", ADDON_SCRIPT, 24009 },
+ {"xbmc.python.weather", ADDON_SCRIPT_WEATHER, 24027 },
+ {"xbmc.python.subtitles", ADDON_SCRIPT_SUBTITLES, 24012 },
+ {"xbmc.python.lyrics", ADDON_SCRIPT_LYRICS, 24013 },
+ {"xbmc.python.library", ADDON_SCRIPT_LIBRARY, 24014 },
+ {"xbmc.gui.skin", ADDON_SKIN, 166 },
+ {"xbmc.addon.repository", ADDON_REPOSITORY, 24011 },
+ {"pvrclient", ADDON_PVRDLL, 0 }};
const CStdString TranslateContent(const CONTENT_TYPE &type, bool pretty/*=false*/)
{
@@ -140,6 +144,25 @@ const TYPE TranslateType(const CStdString &string)
return ADDON_UNKNOWN;
}
+const TYPE ScraperTypeFromContent(const CONTENT_TYPE &content)
+{
+ switch (content)
+ {
+ case CONTENT_ALBUMS:
+ return ADDON_SCRAPER_ALBUMS;
+ case CONTENT_ARTISTS:
+ return ADDON_SCRAPER_ARTISTS;
+ case CONTENT_MOVIES:
+ return ADDON_SCRAPER_MOVIES;
+ case CONTENT_MUSICVIDEOS:
+ return ADDON_SCRAPER_MUSICVIDEOS;
+ case CONTENT_TVSHOWS:
+ return ADDON_SCRAPER_TVSHOWS;
+ default:
+ return ADDON_UNKNOWN;
+ }
+}
+
/**
* AddonVersion
*
@@ -274,7 +297,11 @@ void CAddon::BuildLibName(cp_plugin_info_t *props)
CStdString ext;
switch (m_props.type)
{
- case ADDON_SCRAPER:
+ case ADDON_SCRAPER_ALBUMS:
+ case ADDON_SCRAPER_ARTISTS:
+ case ADDON_SCRAPER_MOVIES:
+ case ADDON_SCRAPER_MUSICVIDEOS:
+ case ADDON_SCRAPER_TVSHOWS:
case ADDON_SCRAPER_LIBRARY:
ext = ADDON_SCRAPER_EXT;
break;
@@ -314,7 +341,11 @@ void CAddon::BuildLibName(cp_plugin_info_t *props)
case ADDON_SCRIPT_LYRICS:
case ADDON_SCRIPT_WEATHER:
case ADDON_SCRIPT_SUBTITLES:
- case ADDON_SCRAPER:
+ case ADDON_SCRAPER_ALBUMS:
+ case ADDON_SCRAPER_ARTISTS:
+ case ADDON_SCRAPER_MOVIES:
+ case ADDON_SCRAPER_MUSICVIDEOS:
+ case ADDON_SCRAPER_TVSHOWS:
case ADDON_SCRAPER_LIBRARY:
case ADDON_PLUGIN:
{
@@ -582,9 +613,7 @@ CAddonLibrary::CAddonLibrary(const AddonProps& props)
TYPE CAddonLibrary::SetAddonType()
{
- if (Type() == ADDON_SCRAPER_LIBRARY)
- return ADDON_SCRAPER;
- else if (Type() == ADDON_VIZ_LIBRARY)
+ if (Type() == ADDON_VIZ_LIBRARY)
return ADDON_VIZ;
else
return ADDON_UNKNOWN;
View
1  xbmc/addons/Addon.h
@@ -40,6 +40,7 @@ const CStdString TranslateContent(const CONTENT_TYPE &content, bool pretty=fa
const CONTENT_TYPE TranslateContent(const CStdString &string);
const CStdString TranslateType(const TYPE &type, bool pretty=false);
const TYPE TranslateType(const CStdString &string);
+const TYPE ScraperTypeFromContent(const CONTENT_TYPE &content);
class AddonVersion
{
View
68 xbmc/addons/AddonManager.cpp
@@ -95,7 +95,12 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
case ADDON_SCRIPT_WEATHER:
case ADDON_SCRIPT_SUBTITLES:
return AddonPtr(new CAddon(props->plugin));
- case ADDON_SCRAPER:
+ case ADDON_SCRAPER_ALBUMS:
+ case ADDON_SCRAPER_ARTISTS:
+ case ADDON_SCRAPER_MOVIES:
+ case ADDON_SCRAPER_MUSICVIDEOS:
+ case ADDON_SCRAPER_TVSHOWS:
+ case ADDON_SCRAPER_LIBRARY:
return AddonPtr(new CScraper(props->plugin));
case ADDON_VIZ:
case ADDON_SCREENSAVER:
@@ -130,7 +135,6 @@ AddonPtr CAddonMgr::Factory(const cp_extension_t *props)
}
case ADDON_SKIN:
return AddonPtr(new CSkinInfo(props->plugin));
- case ADDON_SCRAPER_LIBRARY:
case ADDON_VIZ_LIBRARY:
return AddonPtr(new CAddonLibrary(props->plugin));
case ADDON_REPOSITORY:
@@ -324,40 +328,28 @@ bool CAddonMgr::GetAddon(const CStdString &str, AddonPtr &addon, const TYPE &typ
//TODO handle all 'default' cases here, not just scrapers & vizs
bool CAddonMgr::GetDefault(const TYPE &type, AddonPtr &addon, const CONTENT_TYPE &content)
{
- if (type != ADDON_SCRAPER && type != ADDON_VIZ)
- return false;
-
CStdString setting;
- if (type == ADDON_VIZ)
- setting = g_guiSettings.GetString("musicplayer.visualisation");
- else
+ switch (type)
{
- switch (content)
- {
- case CONTENT_MOVIES:
- {
- setting = g_guiSettings.GetString("scrapers.moviedefault");
- break;
- }
- case CONTENT_TVSHOWS:
- {
- setting = g_guiSettings.GetString("scrapers.tvshowdefault");
- break;
- }
- case CONTENT_MUSICVIDEOS:
- {
- setting = g_guiSettings.GetString("scrapers.musicvideodefault");
- break;
- }
- case CONTENT_ALBUMS:
- case CONTENT_ARTISTS:
- {
- setting = g_guiSettings.GetString("musiclibrary.scraper");
- break;
- }
- default:
- return false;
- }
+ case ADDON_VIZ:
+ setting = g_guiSettings.GetString("musicplayer.visualisation");
+ break;
+ case ADDON_SCRAPER_ALBUMS:
+ case ADDON_SCRAPER_ARTISTS:
+ // FIXME: Split these up?
+ setting = g_guiSettings.GetString("musiclibrary.scraper");
+ break;
+ case ADDON_SCRAPER_MOVIES:
+ setting = g_guiSettings.GetString("scrapers.moviedefault");
+ break;
+ case ADDON_SCRAPER_MUSICVIDEOS:
+ setting = g_guiSettings.GetString("scrapers.musicvideodefault");
+ break;
+ case ADDON_SCRAPER_TVSHOWS:
+ setting = g_guiSettings.GetString("scrapers.tvshowdefault");
+ break;
+ default:
+ return false;
}
return GetAddon(setting, addon, type);
}
@@ -417,7 +409,12 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
case ADDON_SCRIPT_WEATHER:
case ADDON_SCRIPT_SUBTITLES:
return AddonPtr(new CAddon(addonProps));
- case ADDON_SCRAPER:
+ case ADDON_SCRAPER_ALBUMS:
+ case ADDON_SCRAPER_ARTISTS:
+ case ADDON_SCRAPER_MOVIES:
+ case ADDON_SCRAPER_MUSICVIDEOS:
+ case ADDON_SCRAPER_TVSHOWS:
+ case ADDON_SCRAPER_LIBRARY:
return AddonPtr(new CScraper(addonProps));
case ADDON_SKIN:
return AddonPtr(new CSkinInfo(addonProps));
@@ -427,7 +424,6 @@ AddonPtr CAddonMgr::AddonFromProps(AddonProps& addonProps)
#endif
case ADDON_SCREENSAVER:
return AddonPtr(new CScreenSaver(addonProps));
- case ADDON_SCRAPER_LIBRARY:
case ADDON_VIZ_LIBRARY:
return AddonPtr(new CAddonLibrary(addonProps));
case ADDON_REPOSITORY:
View
6 xbmc/addons/IAddon.h
@@ -49,7 +49,11 @@ namespace ADDON
ADDON_SCRIPT_WEATHER,
ADDON_SCRIPT_SUBTITLES,
ADDON_SCRIPT_LYRICS,
- ADDON_SCRAPER,
+ ADDON_SCRAPER_ALBUMS,
+ ADDON_SCRAPER_ARTISTS,
+ ADDON_SCRAPER_MOVIES,
+ ADDON_SCRAPER_MUSICVIDEOS,
+ ADDON_SCRAPER_TVSHOWS,
ADDON_SCREENSAVER,
ADDON_PLUGIN,
ADDON_REPOSITORY,
View
2  xbmc/lib/libhttpapi/XBMChttp.cpp
@@ -2243,7 +2243,7 @@ int CXbmcHttp::xbmcLookupAlbum(int numParas, CStdString paras[])
double relevance;
bool rel = false;
AddonPtr addon;
- if (!CAddonMgr::Get().GetDefault(ADDON_SCRAPER, addon, CONTENT_ALBUMS))
+ if (!CAddonMgr::Get().GetDefault(ADDON_SCRAPER_ALBUMS, addon))
return -1;
ScraperPtr info = boost::dynamic_pointer_cast<CScraper>(addon);
if (!info)
Please sign in to comment.
Something went wrong with that request. Please try again.