Permalink
Browse files

Add the ability to store more than one onlineid

  • Loading branch information...
phate89 committed Jun 3, 2016
1 parent dfbb1aa commit f438970acb9bfc8646e91f298c62e8a786e72551
@@ -8694,7 +8694,7 @@ std::string CGUIInfoManager::GetVideoLabel(int item)
return StringUtils::Join(m_currentFile->GetVideoInfoTag()->m_director, g_advancedSettings.m_videoItemSeparator);
break;
case VIDEOPLAYER_IMDBNUMBER:
return m_currentFile->GetVideoInfoTag()->m_strIMDBNumber;
return m_currentFile->GetVideoInfoTag()->GetUniqueID();
case VIDEOPLAYER_RATING:
{
std::string strRating;
@@ -10229,7 +10229,7 @@ std::string CGUIInfoManager::GetItemLabel(const CFileItem *item, int info, std::
if (item->HasEPGInfoTag())
return item->GetEPGInfoTag()->IMDBNumber();
if (item->HasVideoInfoTag())
return item->GetVideoInfoTag()->m_strIMDBNumber;
return item->GetVideoInfoTag()->GetUniqueID();
break;
}
case LISTITEM_EPISODENAME:
@@ -1035,16 +1035,16 @@ bool CScraper::GetArtistDetails(CCurlFile &fcurl, const CScraperUrl &scurl,

bool CScraper::GetArtwork(XFILE::CCurlFile &fcurl, CVideoInfoTag &details)
{
if (details.m_strIMDBNumber.empty())
if (!details.HasUniqueID())
return false;

CLog::Log(LOGDEBUG, "%s: Reading artwork for '%s' using %s scraper "
"(file: '%s', content: '%s', version: '%s')", __FUNCTION__, details.m_strIMDBNumber.c_str(),
"(file: '%s', content: '%s', version: '%s')", __FUNCTION__, details.GetUniqueID().c_str(),
Name().c_str(), Path().c_str(), ADDON::TranslateContent(Content()).c_str(), Version().asString().c_str());

std::vector<std::string> vcsIn;
CScraperUrl scurl;
vcsIn.push_back(details.m_strIMDBNumber);
vcsIn.push_back(details.GetUniqueID());
std::vector<std::string> vcsOut = RunNoThrow("GetArt", scurl, fcurl, &vcsIn);

bool fRet(false);
@@ -1002,6 +1002,8 @@ int CVideoLibrary::RequiresAdditionalDetails(const MediaType& mediaType, const C
details = details | VideoDbDetailsCast;
else if (propertyValue == "ratings")
details = details | VideoDbDetailsRating;
else if (propertyValue == "uniqueid")
details = details | VideoDbDetailsUniqueID;
else if (propertyValue == "showlink")
details = details | VideoDbDetailsShowLink;
else if (propertyValue == "streamdetails")
@@ -1141,7 +1143,24 @@ void CVideoLibrary::UpdateVideoTag(const CVariant &parameterObject, CVideoInfoTa
if (ParameterNotNull(parameterObject, "mpaa"))
details.SetMPAARating(parameterObject["mpaa"].asString());
if (ParameterNotNull(parameterObject, "imdbnumber"))
details.SetIMDBNumber(parameterObject["imdbnumber"].asString());
details.SetUniqueID(parameterObject["imdbnumber"].asString());
if (ParameterNotNull(parameterObject, "uniqueid"))
{
CVariant uniqueids = parameterObject["uniqueid"];
for (CVariant::const_iterator_map idIt = uniqueids.begin_map(); idIt != uniqueids.end_map(); idIt++)
{
if (idIt->second.isString() && !idIt->second.asString().empty())
{
details.SetUniqueID(idIt->second.asString(), idIt->first);
updatedDetails.insert("uniqueid");
}
else if (idIt->second.isNull() && idIt->first != details.GetDefaultUniqueID())
{
details.RemoveUniqueID(idIt->first);
updatedDetails.insert("uniqueid");
}
}
}
if (ParameterNotNull(parameterObject, "premiered"))
{
CDateTime premiered;
@@ -1493,7 +1493,8 @@
{ "name": "userrating", "$ref": "Optional.Integer" },
{ "name": "ratings", "$ref": "Video.Ratings.Set" },
{ "name": "dateadded", "$ref": "Optional.String" },
{ "name": "premiered", "$ref": "Optional.String", "description": "linked with year. Overriedes year" }
{ "name": "premiered", "$ref": "Optional.String", "description": "linked with year. Overriedes year" },
{ "name": "uniqueid", "type": [ "null", { "$ref": "Media.UniqueID.Set", "required": true } ], "default": null }
],
"returns": "string"
},
@@ -1538,7 +1539,8 @@
{ "name": "ratings", "$ref": "Video.Ratings.Set" },
{ "name": "dateadded", "$ref": "Optional.String" },
{ "name": "runtime", "$ref": "Optional.Integer", "description": "Runtime in seconds" },
{ "name": "status", "$ref": "Optional.String" }
{ "name": "status", "$ref": "Optional.String" },
{ "name": "uniqueid", "type": [ "null", { "$ref": "Media.UniqueID.Set", "required": true } ], "default": null }
],
"returns": "string"
},
@@ -1581,7 +1583,8 @@
{ "name": "resume", "type": [ "null", { "$ref": "Video.Resume", "required": true } ], "default": null },
{ "name": "userrating", "$ref": "Optional.Integer" },
{ "name": "ratings", "$ref": "Video.Ratings.Set" },
{ "name": "dateadded", "$ref": "Optional.String" }
{ "name": "dateadded", "$ref": "Optional.String" },
{ "name": "uniqueid", "type": [ "null", { "$ref": "Media.UniqueID.Set", "required": true } ], "default": null }
],
"returns": "string"
},
@@ -408,6 +408,14 @@
"type": "object",
"additionalProperties": { "type": [ "null", { "$ref": "Video.Rating", "required": true } ] }
},
"Media.UniqueID": {
"type": "object",
"additionalProperties": { "$ref": "Global.String.NotEmpty" }
},
"Media.UniqueID.Set": {
"type": "object",
"additionalProperties": { "type": [ "null", { "$ref": "Global.String.NotEmpty", "required": true } ] }
},
"Library.Fields.Genre": {
"extends": "Item.Fields.Base",
"items": { "type": "string", "enum": [ "title", "thumbnail" ] }
@@ -618,13 +626,14 @@
"Video.Fields.Movie": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
"description": "Requesting the cast, ratings, showlink, streamdetails and/or tag field will result in increased response times",
"description": "Requesting the cast, ratings, showlink, streamdetails, uniqueid and/or tag field will result in increased response times",
"enum": [ "title", "genre", "year", "rating", "director", "trailer",
"tagline", "plot", "plotoutline", "originaltitle", "lastplayed",
"playcount", "writer", "studio", "mpaa", "cast", "country",
"imdbnumber", "runtime", "set", "showlink", "streamdetails",
"top250", "votes", "fanart", "thumbnail", "file", "sorttitle",
"resume", "setid", "dateadded", "tag", "art", "userrating", "ratings", "premiered" ]
"resume", "setid", "dateadded", "tag", "art", "userrating",
"ratings", "premiered", "uniqueid" ]
}
},
"Video.Fields.MovieSet": {
@@ -636,13 +645,14 @@
"Video.Fields.TVShow": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
"description": "Requesting the cast, ratings and/or tag field will result in increased response times",
"description": "Requesting the cast, ratings, uniqueid and/or tag field will result in increased response times",
"enum": [ "title", "genre", "year", "rating", "plot",
"studio", "mpaa", "cast", "playcount", "episode",
"imdbnumber", "premiered", "votes", "lastplayed",
"fanart", "thumbnail", "file", "originaltitle",
"sorttitle", "episodeguide", "season", "watchedepisodes",
"dateadded", "tag", "art", "userrating", "ratings", "runtime" ]
"dateadded", "tag", "art", "userrating", "ratings",
"runtime", "uniqueid" ]
}
},
"Video.Fields.Season": {
@@ -655,7 +665,7 @@
"Video.Fields.Episode": {
"extends": "Item.Fields.Base",
"items": { "type": "string",
"description": "Requesting the cast, ratings, streamdetails and/or tag field will result in increased response times",
"description": "Requesting the cast, ratings, streamdetails, uniqueid and/or tag field will result in increased response times",
"enum": [ "title", "plot", "votes", "rating", "writer",
"firstaired", "playcount", "runtime", "director",
"productioncode", "season", "episode", "originaltitle",
@@ -789,7 +799,8 @@
"tag": { "$ref": "Array.String" },
"userrating": { "type": "integer" },
"ratings": { "type": "Video.Ratings" },
"premiered": { "type": "string" }
"premiered": { "type": "string" },
"uniqueid": { "$ref": "Media.UniqueID" }
}
},
"Video.Details.MovieSet": {
@@ -830,7 +841,8 @@
"tag": { "$ref": "Array.String" },
"userrating": { "type": "integer" },
"ratings": { "type": "Video.Ratings" },
"runtime": { "type": "integer", "description": "Runtime in seconds" }
"runtime": { "type": "integer", "description": "Runtime in seconds" },
"uniqueid": { "$ref": "Media.UniqueID" }
}
},
"Video.Details.Season": {
@@ -856,7 +868,7 @@
"productioncode": { "type": "string" },
"season": { "type": "integer" },
"episode": { "type": "integer" },
"uniqueid": { "type": "object", "additionalProperties": { "type": "string", "minLength": 1 } },
"uniqueid": { "$ref": "Media.UniqueID" },
"originaltitle": { "type": "string" },
"showtitle": { "type": "string" },
"cast": { "$ref": "Video.Cast" },
@@ -1392,7 +1404,7 @@
"disc": { "type": "integer" },
"tag": { "$ref": "Array.String" },
"albumartistid": { "$ref": "Array.Integer" },
"uniqueid": { "type": "object", "additionalProperties": { "type": "string", "minLength": 1 } },
"uniqueid": { "$ref": "Media.UniqueID" },
"episodeguide": { "type": "string" },
"sorttitle": { "type": "string" },
"description": { "type": "string" },
@@ -1 +1 @@
7.18.0
7.19.0
@@ -119,7 +119,7 @@ namespace XBMCAddon

String InfoTagVideo::getIMDBNumber()
{
return infoTag->m_strIMDBNumber;
return infoTag->GetUniqueID();
}

int InfoTagVideo::getSeason()
@@ -147,6 +147,17 @@ namespace XBMCAddon
}
}

void ListItem::setUniqueIDs(const Properties& dictionary)
{
if (!item) return;
if (!item->HasVideoInfoTag()) return;

LOCKGUI;
CVideoInfoTag& vtag = *item->GetVideoInfoTag();
for (Properties::const_iterator it = dictionary.begin(); it != dictionary.end(); ++it)
vtag.SetUniqueID(it->second, it->first);
}

void ListItem::select(bool selected)
{
if (!item) return;
@@ -230,6 +241,12 @@ namespace XBMCAddon
return item->GetArt(key);
}

String ListItem::getUniqueID(const char* key)
{
LOCKGUI;
return item->GetVideoInfoTag()->GetUniqueID(key);
}


void ListItem::setPath(const String& path)
{
@@ -398,7 +415,7 @@ namespace XBMCAddon
else if (key == "set")
item->GetVideoInfoTag()->m_strSet = value;
else if (key == "imdbnumber")
item->GetVideoInfoTag()->m_strIMDBNumber = value;
item->GetVideoInfoTag()->SetUniqueID(value);
else if (key == "code")
item->GetVideoInfoTag()->m_strProductionCode = value;
else if (key == "aired")
@@ -255,6 +255,39 @@ namespace XBMCAddon
void setArt(const Properties& dictionary);
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_listitem
/// @brief \python_func{ setUniqueIDs(values) }
///-----------------------------------------------------------------------
/// Sets the listitem's setUniqueIDs
///
/// @param values dictionary - pairs of `{ label: value }`.
/// - Some example values (any string possible):
/// | Label | Type |
/// |:-------------:|:--------------------------------------------------|
/// | imdb | string - image filename
/// | tvdb | string - image filename
/// | tmdb | string - image filename
/// | anidb | string - image filename
///
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// # setUniqueIDs(values)
/// self.list.getSelectedItem().setUniqueIDs({ 'imdb': 'tt8938399', 'tmdb' : '9837493' })
/// ...
/// ~~~~~~~~~~~~~
///
setUniqueIDs(...);
#else
void setUniqueIDs(const Properties& dictionary);
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_listitem
@@ -291,6 +324,38 @@ namespace XBMCAddon
String getArt(const char* key);
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_listitem
/// @brief \python_func{ getUniqueID(key) }
///-----------------------------------------------------------------------
/// Returns a listitem uniqueID as a string, similar to an infolabel.\n
///
/// @param key string - uniqueID type.
/// - Some default uniqueID values (any string possible):
/// | Label | Type |
/// |---------------|--------------------------------------------------|
/// | imdb | string - image filename
/// | tvdb | string - image filename
/// | tmdb | string - image filename
/// | anidb | string - image filename
///
///
///
///-----------------------------------------------------------------------
///
/// **Example:**
/// ~~~~~~~~~~~~~{.py}
/// ...
/// uniqueID = self.list.getSelectedItem().getUniqueID('imdb')
/// ...
/// ~~~~~~~~~~~~~
///
getUniqueID(key);
#else
String getUniqueID(const char* key);
#endif

#ifdef DOXYGEN_SHOULD_USE_THIS
///
/// \ingroup python_xbmcgui_listitem
@@ -315,7 +315,7 @@ PopulateObjectFromTag(CVideoInfoTag& tag,
object.m_XbmcInfo.date_added = tag.m_dateAdded.GetAsW3CDate().c_str();
object.m_XbmcInfo.rating = tag.GetRating().rating;
object.m_XbmcInfo.votes = tag.GetRating().votes;
object.m_XbmcInfo.unique_identifier = tag.m_strIMDBNumber.c_str();
object.m_XbmcInfo.unique_identifier = tag.GetUniqueID().c_str();
for (const auto& country : tag.m_country)
object.m_XbmcInfo.countries.Add(country.c_str());
object.m_XbmcInfo.user_rating = tag.m_iUserRating;
@@ -820,7 +820,7 @@ PopulateTagFromObject(CVideoInfoTag& tag,

tag.m_dateAdded.SetFromW3CDate((const char*)object.m_XbmcInfo.date_added);
tag.AddRating(object.m_XbmcInfo.rating, object.m_XbmcInfo.votes);
tag.m_strIMDBNumber = object.m_XbmcInfo.unique_identifier;
tag.SetUniqueID(object.m_XbmcInfo.unique_identifier.GetChars());
for (unsigned int index = 0; index < object.m_XbmcInfo.countries.GetItemCount(); index++)
tag.m_country.push_back(object.m_XbmcInfo.countries.GetItem(index)->GetChars());
tag.m_iUserRating = object.m_XbmcInfo.user_rating;
@@ -226,7 +226,7 @@ std::string DatabaseUtils::GetField(Field field, const MediaType &mediaType, Dat
else if (field == FieldDirector) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_DIRECTOR);
else if (field == FieldSeason) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SEASON);
else if (field == FieldEpisodeNumber) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_EPISODE);
else if (field == FieldUniqueId) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_UNIQUEID);
else if (field == FieldUniqueId) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_IDENT_ID);
else if (field == FieldEpisodeNumberSpecialSort) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SORTEPISODE);
else if (field == FieldSeasonSpecialSort) result = StringUtils::Format("episode_view.c%02d", VIDEODB_ID_EPISODE_SORTSEASON);
else if (field == FieldFilename) return "episode_view.strFilename";
@@ -645,7 +645,7 @@ int DatabaseUtils::GetField(Field field, const MediaType &mediaType, bool asInde
else if (field == FieldDirector) index = VIDEODB_ID_EPISODE_DIRECTOR;
else if (field == FieldSeason) index = VIDEODB_ID_EPISODE_SEASON;
else if (field == FieldEpisodeNumber) index = VIDEODB_ID_EPISODE_EPISODE;
else if (field == FieldUniqueId) index = VIDEODB_ID_EPISODE_UNIQUEID;
else if (field == FieldUniqueId) index = VIDEODB_ID_EPISODE_IDENT_ID;
else if (field == FieldEpisodeNumberSpecialSort) index = VIDEODB_ID_EPISODE_SORTEPISODE;
else if (field == FieldSeasonSpecialSort) index = VIDEODB_ID_EPISODE_SORTSEASON;
else if (field == FieldFilename) return VIDEODB_DETAILS_EPISODE_FILE;
Oops, something went wrong.

0 comments on commit f438970

Please sign in to comment.