|
|
|
@ -274,6 +274,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesId", "GUID");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "SeriesSortName", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "ExternalSeriesId", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "ShortOverview", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "Tagline", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "Keywords", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "ProviderIds", "Text");
|
|
|
|
|
_connection.AddColumn(Logger, "TypedBaseItems", "Images", "Text");
|
|
|
|
|
|
|
|
|
|
_connection.AddColumn(Logger, "UserDataKeys", "Priority", "INT");
|
|
|
|
|
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
|
|
|
|
@ -418,7 +423,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
"PresentationUniqueKey",
|
|
|
|
|
"InheritedParentalRatingValue",
|
|
|
|
|
"InheritedTags",
|
|
|
|
|
"ExternalSeriesId"
|
|
|
|
|
"ExternalSeriesId",
|
|
|
|
|
"ShortOverview",
|
|
|
|
|
"Tagline",
|
|
|
|
|
"Keywords",
|
|
|
|
|
"ProviderIds",
|
|
|
|
|
"Images"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly string[] _mediaStreamSaveColumns =
|
|
|
|
@ -541,7 +551,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
"SeasonId",
|
|
|
|
|
"SeriesId",
|
|
|
|
|
"SeriesSortName",
|
|
|
|
|
"ExternalSeriesId"
|
|
|
|
|
"ExternalSeriesId",
|
|
|
|
|
"ShortOverview",
|
|
|
|
|
"Tagline",
|
|
|
|
|
"Keywords",
|
|
|
|
|
"ProviderIds",
|
|
|
|
|
"Images"
|
|
|
|
|
};
|
|
|
|
|
_saveItemCommand = _connection.CreateCommand();
|
|
|
|
|
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
|
|
|
|
@ -982,6 +997,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = item.ExternalSeriesId;
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = item.ShortOverview;
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = item.Tagline;
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Keywords.ToArray());
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = SerializeProviderIds(item);
|
|
|
|
|
_saveItemCommand.GetParameter(index++).Value = SerializeImages(item);
|
|
|
|
|
|
|
|
|
|
_saveItemCommand.Transaction = transaction;
|
|
|
|
|
|
|
|
|
@ -1031,6 +1051,99 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string SerializeProviderIds(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
var ids = item.ProviderIds.ToList();
|
|
|
|
|
|
|
|
|
|
if (ids.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Join("|", ids.Select(i => i.Key + "=" + i.Value).ToArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeserializeProviderIds(string value, BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.ProviderIds.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
foreach (var part in parts)
|
|
|
|
|
{
|
|
|
|
|
var idParts = part.Split('=');
|
|
|
|
|
|
|
|
|
|
item.SetProviderId(idParts[0], idParts[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string SerializeImages(BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
var images = item.ImageInfos.ToList();
|
|
|
|
|
|
|
|
|
|
if (images.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string.Join("|", images.Select(ToValueString).ToArray());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeserializeImages(string value, BaseItem item)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item.ImageInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var parts = value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
foreach (var part in parts)
|
|
|
|
|
{
|
|
|
|
|
item.ImageInfos.Add(ItemImageInfoFromValueString(part));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string ToValueString(ItemImageInfo image)
|
|
|
|
|
{
|
|
|
|
|
var delimeter = "*";
|
|
|
|
|
|
|
|
|
|
return (image.Path ?? string.Empty) +
|
|
|
|
|
delimeter +
|
|
|
|
|
image.DateModified.Ticks.ToString(CultureInfo.InvariantCulture) +
|
|
|
|
|
delimeter +
|
|
|
|
|
image.Type +
|
|
|
|
|
delimeter +
|
|
|
|
|
image.IsPlaceholder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ItemImageInfo ItemImageInfoFromValueString(string value)
|
|
|
|
|
{
|
|
|
|
|
var parts = value.Split(new[] { '*' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
|
|
|
|
|
var image = new ItemImageInfo();
|
|
|
|
|
|
|
|
|
|
image.Path = parts[0];
|
|
|
|
|
image.DateModified = new DateTime(long.Parse(parts[1], CultureInfo.InvariantCulture), DateTimeKind.Utc);
|
|
|
|
|
image.Type = (ImageType)Enum.Parse(typeof(ImageType), parts[2], true);
|
|
|
|
|
image.IsPlaceholder = string.Equals(parts[3], true.ToString(), StringComparison.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
return image;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Internal retrieve from items or users table
|
|
|
|
|
/// </summary>
|
|
|
|
@ -1064,6 +1177,51 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BaseItem GetItem(IDataReader reader)
|
|
|
|
|
{
|
|
|
|
|
return GetItem(reader, new InternalItemsQuery());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool TypeRequiresDeserialization(Type type)
|
|
|
|
|
{
|
|
|
|
|
if (_config.Configuration.SkipDeserializationForBasicTypes)
|
|
|
|
|
{
|
|
|
|
|
if (type == typeof(MusicGenre))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == typeof(GameGenre))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == typeof(Genre))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == typeof(Studio))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == typeof(Year))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (type == typeof(Book))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_config.Configuration.SkipDeserializationForPrograms)
|
|
|
|
|
{
|
|
|
|
|
if (type == typeof(LiveTvProgram))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private BaseItem GetItem(IDataReader reader, InternalItemsQuery query)
|
|
|
|
|
{
|
|
|
|
|
var typeString = reader.GetString(0);
|
|
|
|
|
|
|
|
|
@ -1078,34 +1236,37 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
|
|
|
|
|
BaseItem item = null;
|
|
|
|
|
|
|
|
|
|
using (var stream = reader.GetMemoryStream(1, _memoryStreamProvider))
|
|
|
|
|
if (TypeRequiresDeserialization(type))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
|
|
|
|
|
}
|
|
|
|
|
catch (SerializationException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deserializing item", ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
using (var stream = reader.GetMemoryStream(1, _memoryStreamProvider))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
item = Activator.CreateInstance(type) as BaseItem;
|
|
|
|
|
item = _jsonSerializer.DeserializeFromStream(stream, type) as BaseItem;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
catch (SerializationException ex)
|
|
|
|
|
{
|
|
|
|
|
Logger.ErrorException("Error deserializing item", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
item = Activator.CreateInstance(type) as BaseItem;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(2))
|
|
|
|
|
{
|
|
|
|
|
var hasStartDate = item as IHasStartDate;
|
|
|
|
@ -1179,194 +1340,275 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(15))
|
|
|
|
|
{
|
|
|
|
|
item.CommunityRating = reader.GetFloat(15);
|
|
|
|
|
}
|
|
|
|
|
var index = 15;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(16))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.CustomRating = reader.GetString(16);
|
|
|
|
|
item.CommunityRating = reader.GetFloat(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(17))
|
|
|
|
|
if (query.HasField(ItemFields.CustomRating))
|
|
|
|
|
{
|
|
|
|
|
item.IndexNumber = reader.GetInt32(17);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.CustomRating = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(18))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.IsLocked = reader.GetBoolean(18);
|
|
|
|
|
item.IndexNumber = reader.GetInt32(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(19))
|
|
|
|
|
if (query.HasField(ItemFields.Settings))
|
|
|
|
|
{
|
|
|
|
|
item.PreferredMetadataLanguage = reader.GetString(19);
|
|
|
|
|
}
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.IsLocked = reader.GetBoolean(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(20))
|
|
|
|
|
{
|
|
|
|
|
item.PreferredMetadataCountryCode = reader.GetString(20);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.PreferredMetadataLanguage = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.PreferredMetadataCountryCode = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(21))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.IsHD = reader.GetBoolean(21);
|
|
|
|
|
item.IsHD = reader.GetBoolean(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(22))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ExternalEtag = reader.GetString(22);
|
|
|
|
|
item.ExternalEtag = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(23))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.DateLastRefreshed = reader.GetDateTime(23).ToUniversalTime();
|
|
|
|
|
item.DateLastRefreshed = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(24))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Name = reader.GetString(24);
|
|
|
|
|
item.Name = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(25))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Path = reader.GetString(25);
|
|
|
|
|
item.Path = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(26))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.PremiereDate = reader.GetDateTime(26).ToUniversalTime();
|
|
|
|
|
item.PremiereDate = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(27))
|
|
|
|
|
if (query.HasField(ItemFields.Overview))
|
|
|
|
|
{
|
|
|
|
|
item.Overview = reader.GetString(27);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Overview = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(28))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ParentIndexNumber = reader.GetInt32(28);
|
|
|
|
|
item.ParentIndexNumber = reader.GetInt32(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(29))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ProductionYear = reader.GetInt32(29);
|
|
|
|
|
item.ProductionYear = reader.GetInt32(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(30))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.OfficialRating = reader.GetString(30);
|
|
|
|
|
item.OfficialRating = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(31))
|
|
|
|
|
if (query.HasField(ItemFields.OfficialRatingDescription))
|
|
|
|
|
{
|
|
|
|
|
item.OfficialRatingDescription = reader.GetString(31);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.OfficialRatingDescription = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(32))
|
|
|
|
|
if (query.HasField(ItemFields.HomePageUrl))
|
|
|
|
|
{
|
|
|
|
|
item.HomePageUrl = reader.GetString(32);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.HomePageUrl = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(33))
|
|
|
|
|
if (query.HasField(ItemFields.DisplayMediaType))
|
|
|
|
|
{
|
|
|
|
|
item.DisplayMediaType = reader.GetString(33);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.DisplayMediaType = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(34))
|
|
|
|
|
if (query.HasField(ItemFields.SortName))
|
|
|
|
|
{
|
|
|
|
|
item.ForcedSortName = reader.GetString(34);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ForcedSortName = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(35))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.RunTimeTicks = reader.GetInt64(35);
|
|
|
|
|
item.RunTimeTicks = reader.GetInt64(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(36))
|
|
|
|
|
if (query.HasField(ItemFields.VoteCount))
|
|
|
|
|
{
|
|
|
|
|
item.VoteCount = reader.GetInt32(36);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.VoteCount = reader.GetInt32(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(37))
|
|
|
|
|
if (query.HasField(ItemFields.DateCreated))
|
|
|
|
|
{
|
|
|
|
|
item.DateCreated = reader.GetDateTime(37).ToUniversalTime();
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.DateCreated = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(38))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.DateModified = reader.GetDateTime(38).ToUniversalTime();
|
|
|
|
|
item.DateModified = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
item.Id = reader.GetGuid(39);
|
|
|
|
|
item.Id = reader.GetGuid(index);
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(40))
|
|
|
|
|
if (query.HasField(ItemFields.Genres))
|
|
|
|
|
{
|
|
|
|
|
item.Genres = reader.GetString(40).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Genres = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(41))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ParentId = reader.GetGuid(41);
|
|
|
|
|
item.ParentId = reader.GetGuid(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(42))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Audio = (ProgramAudio)Enum.Parse(typeof(ProgramAudio), reader.GetString(42), true);
|
|
|
|
|
item.Audio = (ProgramAudio)Enum.Parse(typeof(ProgramAudio), reader.GetString(index), true);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(43))
|
|
|
|
|
if (query.HasField(ItemFields.ServiceName))
|
|
|
|
|
{
|
|
|
|
|
item.ServiceName = reader.GetString(43);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ServiceName = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(44))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.IsInMixedFolder = reader.GetBoolean(44);
|
|
|
|
|
item.IsInMixedFolder = reader.GetBoolean(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(45))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.DateLastSaved = reader.GetDateTime(45).ToUniversalTime();
|
|
|
|
|
item.DateLastSaved = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(46))
|
|
|
|
|
if (query.HasField(ItemFields.Settings))
|
|
|
|
|
{
|
|
|
|
|
item.LockedFields = reader.GetString(46).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList();
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.LockedFields = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (MetadataFields)Enum.Parse(typeof(MetadataFields), i, true)).ToList();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(47))
|
|
|
|
|
if (query.HasField(ItemFields.Studios))
|
|
|
|
|
{
|
|
|
|
|
item.Studios = reader.GetString(47).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Studios = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(48))
|
|
|
|
|
if (query.HasField(ItemFields.Tags))
|
|
|
|
|
{
|
|
|
|
|
item.Tags = reader.GetString(48).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Tags = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(49))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.SourceType = (SourceType)Enum.Parse(typeof(SourceType), reader.GetString(49), true);
|
|
|
|
|
item.SourceType = (SourceType)Enum.Parse(typeof(SourceType), reader.GetString(index), true);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
var trailer = item as Trailer;
|
|
|
|
|
if (trailer != null)
|
|
|
|
|
{
|
|
|
|
|
if (!reader.IsDBNull(50))
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
trailer.TrailerTypes = reader.GetString(50).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true)).ToList();
|
|
|
|
|
trailer.TrailerTypes = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).Select(i => (TrailerType)Enum.Parse(typeof(TrailerType), i, true)).ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
var index = 51;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
if (query.HasField(ItemFields.OriginalTitle))
|
|
|
|
|
{
|
|
|
|
|
item.OriginalTitle = reader.GetString(index);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.OriginalTitle = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
var video = item as Video;
|
|
|
|
|
if (video != null)
|
|
|
|
@ -1378,12 +1620,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
var folder = item as Folder;
|
|
|
|
|
if (folder != null && !reader.IsDBNull(index))
|
|
|
|
|
if (query.HasField(ItemFields.DateLastMediaAdded))
|
|
|
|
|
{
|
|
|
|
|
folder.DateLastMediaAdded = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
var folder = item as Folder;
|
|
|
|
|
if (folder != null && !reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
folder.DateLastMediaAdded = reader.GetDateTime(index).ToUniversalTime();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
@ -1397,11 +1642,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
if (query.HasField(ItemFields.CriticRatingSummary))
|
|
|
|
|
{
|
|
|
|
|
item.CriticRatingSummary = reader.GetString(index);
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.CriticRatingSummary = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
@ -1480,6 +1728,54 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (query.HasField(ItemFields.ShortOverview))
|
|
|
|
|
{
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.ShortOverview = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query.HasField(ItemFields.Taglines))
|
|
|
|
|
{
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Tagline = reader.GetString(index);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (query.HasField(ItemFields.Keywords))
|
|
|
|
|
{
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
item.Keywords = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
DeserializeProviderIds(reader.GetString(index), item);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (!reader.IsDBNull(index))
|
|
|
|
|
{
|
|
|
|
|
DeserializeImages(reader.GetString(index), item);
|
|
|
|
|
}
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.Tagline))
|
|
|
|
|
{
|
|
|
|
|
var movie = item as Movie;
|
|
|
|
|
if (movie != null && movie.Taglines.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
movie.Tagline = movie.Taglines[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1796,10 +2092,47 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ItemFields> allFields = Enum.GetNames(typeof(ItemFields))
|
|
|
|
|
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
private IEnumerable<string> GetColumnNamesFromField(ItemFields field)
|
|
|
|
|
{
|
|
|
|
|
if (field == ItemFields.Settings)
|
|
|
|
|
{
|
|
|
|
|
return new[] { "IsLocked", "PreferredMetadataCountryCode", "PreferredMetadataLanguage", "LockedFields" };
|
|
|
|
|
}
|
|
|
|
|
if (field == ItemFields.ServiceName)
|
|
|
|
|
{
|
|
|
|
|
return new[] { "ExternalServiceId" };
|
|
|
|
|
}
|
|
|
|
|
if (field == ItemFields.SortName)
|
|
|
|
|
{
|
|
|
|
|
return new[] { "ForcedSortName" };
|
|
|
|
|
}
|
|
|
|
|
if (field == ItemFields.Taglines)
|
|
|
|
|
{
|
|
|
|
|
return new[] { "Tagline" };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new[] { field.ToString() };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string[] GetFinalColumnsToSelect(InternalItemsQuery query, string[] startColumns, IDbCommand cmd)
|
|
|
|
|
{
|
|
|
|
|
var list = startColumns.ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var field in allFields)
|
|
|
|
|
{
|
|
|
|
|
if (!query.HasField(field))
|
|
|
|
|
{
|
|
|
|
|
foreach (var fieldToRemove in GetColumnNamesFromField(field).ToList())
|
|
|
|
|
{
|
|
|
|
|
list.Remove(fieldToRemove);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (EnableJoinUserData(query))
|
|
|
|
|
{
|
|
|
|
|
list.Add("UserDataDb.UserData.UserId");
|
|
|
|
@ -1954,7 +2287,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var item = GetItem(reader);
|
|
|
|
|
var item = GetItem(reader, query);
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(item);
|
|
|
|
@ -2141,7 +2474,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var item = GetItem(reader);
|
|
|
|
|
var item = GetItem(reader, query);
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
list.Add(item);
|
|
|
|
@ -2652,7 +2985,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
|
|
|
|
}
|
|
|
|
|
if (programAttribtues.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
whereClauses.Add("("+string.Join(" OR ", programAttribtues.ToArray())+")");
|
|
|
|
|
whereClauses.Add("(" + string.Join(" OR ", programAttribtues.ToArray()) + ")");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|