aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-31 01:51:43 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-10-31 01:51:43 -0400
commitb91dcdbff43559e4cbaa4148d56f6b7295256b7a (patch)
treebc7b2be61108c8edbc3ea8e8218e6996a1ddcb7f /MediaBrowser.Server.Implementations
parent3bf72b71b35c031e89a1b45ddc717e3d5d45afb0 (diff)
update audio queries
Diffstat (limited to 'MediaBrowser.Server.Implementations')
-rw-r--r--MediaBrowser.Server.Implementations/Channels/ChannelManager.cs41
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs90
2 files changed, 127 insertions, 4 deletions
diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
index ffb9c96e7..300973ce1 100644
--- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
+++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs
@@ -252,6 +252,42 @@ namespace MediaBrowser.Server.Implementations.Channels
return item;
}
+ private List<ChannelMediaInfo> GetSavedMediaSources(BaseItem item)
+ {
+ var path = Path.Combine(item.GetInternalMetadataPath(), "channelmediasources.json");
+
+ try
+ {
+ return _jsonSerializer.DeserializeFromFile<List<ChannelMediaInfo>>(path) ?? new List<ChannelMediaInfo>();
+ }
+ catch
+ {
+ return new List<ChannelMediaInfo>();
+ }
+ }
+
+ private void SaveMediaSources(BaseItem item, List<ChannelMediaInfo> mediaSources)
+ {
+ var path = Path.Combine(item.GetInternalMetadataPath(), "channelmediasources.json");
+
+ if (mediaSources == null || mediaSources.Count == 0)
+ {
+ try
+ {
+ _fileSystem.DeleteFile(path);
+ }
+ catch
+ {
+
+ }
+ return;
+ }
+
+ _fileSystem.CreateDirectory(Path.GetDirectoryName(path));
+
+ _jsonSerializer.SerializeToFile(mediaSources, path);
+ }
+
public async Task<IEnumerable<MediaSourceInfo>> GetStaticMediaSources(BaseItem item, bool includeCachedVersions, CancellationToken cancellationToken)
{
IEnumerable<ChannelMediaInfo> results = new List<ChannelMediaInfo>();
@@ -263,7 +299,7 @@ namespace MediaBrowser.Server.Implementations.Channels
var audio = item as Audio;
if (audio != null)
{
- results = audio.ChannelMediaSources ?? new List<ChannelMediaInfo>();
+ results = audio.ChannelMediaSources ?? GetSavedMediaSources(audio);
}
var sources = SortMediaInfoResults(results)
@@ -1385,7 +1421,6 @@ namespace MediaBrowser.Server.Implementations.Channels
if (channelAudioItem != null)
{
channelAudioItem.ExtraType = info.ExtraType;
- channelAudioItem.ChannelMediaSources = info.MediaSources;
var mediaSource = info.MediaSources.FirstOrDefault();
item.Path = mediaSource == null ? null : mediaSource.Path;
@@ -1426,6 +1461,8 @@ namespace MediaBrowser.Server.Implementations.Channels
await item.UpdateToRepository(ItemUpdateType.None, cancellationToken).ConfigureAwait(false);
}
+ SaveMediaSources(item, info.MediaSources);
+
return item;
}
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index ffae9a6f0..5fcd38f87 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -285,6 +285,10 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(Logger, "TypedBaseItems", "ProductionLocations", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "ThemeSongIds", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "ThemeVideoIds", "Text");
+ _connection.AddColumn(Logger, "TypedBaseItems", "TotalBitrate", "INT");
+ _connection.AddColumn(Logger, "TypedBaseItems", "ExtraType", "Text");
+ _connection.AddColumn(Logger, "TypedBaseItems", "Artists", "Text");
+ _connection.AddColumn(Logger, "TypedBaseItems", "AlbumArtists", "Text");
_connection.AddColumn(Logger, "ItemValues", "CleanValue", "Text");
@@ -435,7 +439,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
"Images",
"ProductionLocations",
"ThemeSongIds",
- "ThemeVideoIds"
+ "ThemeVideoIds",
+ "TotalBitrate",
+ "ExtraType",
+ "Artists",
+ "AlbumArtists"
};
private readonly string[] _mediaStreamSaveColumns =
@@ -566,7 +574,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
"Images",
"ProductionLocations",
"ThemeSongIds",
- "ThemeVideoIds"
+ "ThemeVideoIds",
+ "TotalBitrate",
+ "ExtraType",
+ "Artists",
+ "AlbumArtists"
};
_saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@@ -1046,6 +1058,35 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = null;
}
+ _saveItemCommand.GetParameter(index++).Value = item.TotalBitrate;
+ _saveItemCommand.GetParameter(index++).Value = item.ExtraType;
+
+ var hasArtists = item as IHasArtist;
+ if (hasArtists != null)
+ {
+ if (hasArtists.Artists.Count > 0)
+ {
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasArtists.Artists.ToArray());
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
+ }
+
+ var hasAlbumArtists = item as IHasAlbumArtist;
+ if (hasAlbumArtists != null)
+ {
+ if (hasAlbumArtists.AlbumArtists.Count > 0)
+ {
+ _saveItemCommand.GetParameter(index++).Value = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
+ }
+
_saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery();
@@ -1305,6 +1346,25 @@ namespace MediaBrowser.Server.Implementations.Persistence
return false;
}
}
+ if (_config.Configuration.SkipDeserializationForAudio)
+ {
+ if (type == typeof(Audio))
+ {
+ return false;
+ }
+ if (type == typeof(LiveTvAudioRecording))
+ {
+ return false;
+ }
+ if (type == typeof(AudioPodcast))
+ {
+ return false;
+ }
+ if (type == typeof(MusicAlbum))
+ {
+ return false;
+ }
+ }
return true;
}
@@ -1884,6 +1944,32 @@ namespace MediaBrowser.Server.Implementations.Persistence
index++;
}
+ if (!reader.IsDBNull(index))
+ {
+ item.TotalBitrate = reader.GetInt32(index);
+ }
+ index++;
+
+ if (!reader.IsDBNull(index))
+ {
+ item.ExtraType = (ExtraType)Enum.Parse(typeof(ExtraType), reader.GetString(index), true);
+ }
+ index++;
+
+ var hasArtists = item as IHasArtist;
+ if (hasArtists != null && !reader.IsDBNull(index))
+ {
+ hasArtists.Artists = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+ }
+ index++;
+
+ var hasAlbumArtists = item as IHasAlbumArtist;
+ if (hasAlbumArtists != null && !reader.IsDBNull(index))
+ {
+ hasAlbumArtists.AlbumArtists = reader.GetString(index).Split('|').Where(i => !string.IsNullOrWhiteSpace(i)).ToList();
+ }
+ index++;
+
if (string.IsNullOrWhiteSpace(item.Tagline))
{
var movie = item as Movie;