mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-23 18:50:26 +00:00
update audio queries
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user