Skip to content

Commit

Permalink
Merge pull request #23 from jellyfin/master
Browse files Browse the repository at this point in the history
updating
  • Loading branch information
BaronGreenback committed Jun 15, 2020
2 parents 4d50941 + 100e9d5 commit 862bcdb
Show file tree
Hide file tree
Showing 335 changed files with 4,316 additions and 3,438 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [anthonylavado](https://github.com/anthonylavado)
- [Artiume](https://github.com/Artiume)
- [AThomsen](https://github.com/AThomsen)
- [barronpm](https://github.com/barronpm)
- [bilde2910](https://github.com/bilde2910)
- [bfayers](https://github.com/bfayers)
- [BnMcG](https://github.com/BnMcG)
Expand Down Expand Up @@ -130,6 +131,7 @@
- [XVicarious](https://github.com/XVicarious)
- [YouKnowBlom](https://github.com/YouKnowBlom)
- [KristupasSavickas](https://github.com/KristupasSavickas)
- [Pusta](https://github.com/pusta)

# Emby Contributors

Expand Down
8 changes: 5 additions & 3 deletions Emby.Dlna/ContentDirectory/ContentDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using System.Linq;
using System.Threading.Tasks;
using Emby.Dlna.Service;
using Jellyfin.Data.Entities;
using Jellyfin.Data.Enums;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dlna;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.TV;
Expand All @@ -32,7 +33,8 @@ public class ContentDirectory : BaseService, IContentDirectory
private readonly IMediaEncoder _mediaEncoder;
private readonly ITVSeriesManager _tvSeriesManager;

public ContentDirectory(IDlnaManager dlna,
public ContentDirectory(
IDlnaManager dlna,
IUserDataManager userDataManager,
IImageProcessor imageProcessor,
ILibraryManager libraryManager,
Expand Down Expand Up @@ -131,7 +133,7 @@ private User GetUser(DeviceProfile profile)

foreach (var user in _userManager.Users)
{
if (user.Policy.IsAdministrator)
if (user.HasPermission(PermissionKind.IsAdministrator))
{
return user;
}
Expand Down
39 changes: 23 additions & 16 deletions Emby.Dlna/ContentDirectory/ControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
using System.Xml;
using Emby.Dlna.Didl;
using Emby.Dlna.Service;
using Jellyfin.Data.Entities;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.MediaEncoding;
Expand All @@ -28,6 +28,12 @@
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Querying;
using Microsoft.Extensions.Logging;
using Book = MediaBrowser.Controller.Entities.Book;
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
using Genre = MediaBrowser.Controller.Entities.Genre;
using Movie = MediaBrowser.Controller.Entities.Movies.Movie;
using MusicAlbum = MediaBrowser.Controller.Entities.Audio.MusicAlbum;
using Series = MediaBrowser.Controller.Entities.TV.Series;

namespace Emby.Dlna.ContentDirectory
{
Expand Down Expand Up @@ -460,12 +466,12 @@ private QueryResult<BaseItem> GetChildrenSorted(BaseItem item, User user, Search
}
else if (search.SearchType == SearchType.Playlist)
{
//items = items.OfType<Playlist>();
// items = items.OfType<Playlist>();
isFolder = true;
}
else if (search.SearchType == SearchType.MusicAlbum)
{
//items = items.OfType<MusicAlbum>();
// items = items.OfType<MusicAlbum>();
isFolder = true;
}

Expand Down Expand Up @@ -731,7 +737,7 @@ private QueryResult<ServerItem> GetMovieFolders(BaseItem item, User user, StubTy
return GetGenres(item, user, query);
}

var array = new ServerItem[]
var array = new[]
{
new ServerItem(item)
{
Expand Down Expand Up @@ -920,7 +926,7 @@ private QueryResult<ServerItem> GetMovieMovies(BaseItem parent, User user, Inter
private QueryResult<ServerItem> GetMovieCollections(User user, InternalItemsQuery query)
{
query.Recursive = true;
//query.Parent = parent;
// query.Parent = parent;
query.SetUser(user);

query.IncludeItemTypes = new[] { typeof(BoxSet).Name };
Expand Down Expand Up @@ -1115,7 +1121,7 @@ private QueryResult<ServerItem> GetFavoriteArtists(BaseItem parent, User user, I
private QueryResult<ServerItem> GetMusicPlaylists(User user, InternalItemsQuery query)
{
query.Parent = null;
query.IncludeItemTypes = new[] { typeof(Playlist).Name };
query.IncludeItemTypes = new[] { nameof(Playlist) };
query.SetUser(user);
query.Recursive = true;

Expand All @@ -1132,10 +1138,9 @@ private QueryResult<ServerItem> GetMusicLatest(BaseItem parent, User user, Inter
{
UserId = user.Id,
Limit = 50,
IncludeItemTypes = new[] { typeof(Audio).Name },
ParentId = parent == null ? Guid.Empty : parent.Id,
IncludeItemTypes = new[] { nameof(Audio) },
ParentId = parent?.Id ?? Guid.Empty,
GroupItems = true

}, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToArray();

return ToResult(items);
Expand All @@ -1150,7 +1155,6 @@ private QueryResult<ServerItem> GetNextUp(BaseItem parent, InternalItemsQuery qu
Limit = query.Limit,
StartIndex = query.StartIndex,
UserId = query.User.Id

}, new[] { parent }, query.DtoOptions);

return ToResult(result);
Expand All @@ -1167,7 +1171,6 @@ private QueryResult<ServerItem> GetTvLatest(BaseItem parent, User user, Internal
IncludeItemTypes = new[] { typeof(Episode).Name },
ParentId = parent == null ? Guid.Empty : parent.Id,
GroupItems = false

}, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToArray();

return ToResult(items);
Expand All @@ -1177,14 +1180,14 @@ private QueryResult<ServerItem> GetMovieLatest(BaseItem parent, User user, Inter
{
query.OrderBy = Array.Empty<(string, SortOrder)>();

var items = _userViewManager.GetLatestItems(new LatestItemsQuery
var items = _userViewManager.GetLatestItems(
new LatestItemsQuery
{
UserId = user.Id,
Limit = 50,
IncludeItemTypes = new[] { typeof(Movie).Name },
ParentId = parent == null ? Guid.Empty : parent.Id,
IncludeItemTypes = new[] { nameof(Movie) },
ParentId = parent?.Id ?? Guid.Empty,
GroupItems = true

}, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null).ToArray();

return ToResult(items);
Expand Down Expand Up @@ -1217,7 +1220,11 @@ private QueryResult<ServerItem> GetGenreItems(BaseItem item, Guid parentId, User
Recursive = true,
ParentId = parentId,
GenreIds = new[] { item.Id },
IncludeItemTypes = new[] { typeof(Movie).Name, typeof(Series).Name },
IncludeItemTypes = new[]
{
nameof(Movie),
nameof(Series)
},
Limit = limit,
StartIndex = startIndex,
DtoOptions = GetDtoOptions()
Expand Down
31 changes: 17 additions & 14 deletions Emby.Dlna/Didl/DidlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
using System.Linq;
using System.Text;
using System.Xml;
using Emby.Dlna.Configuration;
using Emby.Dlna.ContentDirectory;
using Jellyfin.Data.Entities;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.MediaEncoding;
using MediaBrowser.Controller.Playlists;
Expand All @@ -23,6 +22,13 @@
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Net;
using Microsoft.Extensions.Logging;
using Episode = MediaBrowser.Controller.Entities.TV.Episode;
using Genre = MediaBrowser.Controller.Entities.Genre;
using Movie = MediaBrowser.Controller.Entities.Movies.Movie;
using MusicAlbum = MediaBrowser.Controller.Entities.Audio.MusicAlbum;
using Season = MediaBrowser.Controller.Entities.TV.Season;
using Series = MediaBrowser.Controller.Entities.TV.Series;
using XmlAttribute = MediaBrowser.Model.Dlna.XmlAttribute;

namespace Emby.Dlna.Didl
{
Expand Down Expand Up @@ -92,21 +98,21 @@ public string GetItemDidl(BaseItem item, User user, BaseItem context, string dev
{
using (var writer = XmlWriter.Create(builder, settings))
{
//writer.WriteStartDocument();
// writer.WriteStartDocument();

writer.WriteStartElement(string.Empty, "DIDL-Lite", NS_DIDL);

writer.WriteAttributeString("xmlns", "dc", null, NS_DC);
writer.WriteAttributeString("xmlns", "dlna", null, NS_DLNA);
writer.WriteAttributeString("xmlns", "upnp", null, NS_UPNP);
//didl.SetAttribute("xmlns:sec", NS_SEC);
// didl.SetAttribute("xmlns:sec", NS_SEC);

WriteXmlRootAttributes(_profile, writer);

WriteItemElement(writer, item, user, context, null, deviceId, filter, streamInfo);

writer.WriteFullEndElement();
//writer.WriteEndDocument();
// writer.WriteEndDocument();
}

return builder.ToString();
Expand Down Expand Up @@ -421,7 +427,6 @@ private string GetDisplayName(BaseItem item, StubType? itemStubType, BaseItem co
case StubType.FavoriteSeries: return _localization.GetLocalizedString("HeaderFavoriteShows");
case StubType.FavoriteEpisodes: return _localization.GetLocalizedString("HeaderFavoriteEpisodes");
case StubType.Series: return _localization.GetLocalizedString("Shows");
default: break;
}
}

Expand Down Expand Up @@ -670,7 +675,7 @@ private void AddSamsungBookmarkInfo(BaseItem item, User user, XmlWriter writer,
return;
}

MediaBrowser.Model.Dlna.XmlAttribute secAttribute = null;
XmlAttribute secAttribute = null;
foreach (var attribute in _profile.XmlRootAttributes)
{
if (string.Equals(attribute.Name, "xmlns:sec", StringComparison.OrdinalIgnoreCase))
Expand Down Expand Up @@ -706,7 +711,7 @@ private void AddCommonFields(BaseItem item, StubType? itemStubType, BaseItem con
{
// Don't filter on dc:title because not all devices will include it in the filter
// MediaMonkey for example won't display content without a title
//if (filter.Contains("dc:title"))
// if (filter.Contains("dc:title"))
{
AddValue(writer, "dc", "title", GetDisplayName(item, itemStubType, context), NS_DC);
}
Expand Down Expand Up @@ -745,7 +750,7 @@ private void AddCommonFields(BaseItem item, StubType? itemStubType, BaseItem con
AddValue(writer, "dc", "description", desc, NS_DC);
}
}
//if (filter.Contains("upnp:longDescription"))
// if (filter.Contains("upnp:longDescription"))
//{
// if (!string.IsNullOrWhiteSpace(item.Overview))
// {
Expand Down Expand Up @@ -995,7 +1000,6 @@ private void AddCover(BaseItem item, StubType? stubType, XmlWriter writer)
}

AddImageResElement(item, writer, 160, 160, "jpg", "JPEG_TN");

}

private void AddImageResElement(
Expand Down Expand Up @@ -1131,25 +1135,24 @@ private ImageDownloadInfo GetImageInfo(BaseItem item, ImageType type)

if (width == 0 || height == 0)
{
//_imageProcessor.GetImageSize(item, imageInfo);
// _imageProcessor.GetImageSize(item, imageInfo);
width = null;
height = null;
}

else if (width == -1 || height == -1)
{
width = null;
height = null;
}

//try
// try
//{
// var size = _imageProcessor.GetImageSize(imageInfo);

// width = size.Width;
// height = size.Height;
//}
//catch
// catch
//{

//}
Expand Down
3 changes: 1 addition & 2 deletions Emby.Dlna/Didl/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class Filter
public Filter()
: this("*")
{

}

public Filter(string filter)
Expand All @@ -26,7 +25,7 @@ public bool Contains(string field)
{
// Don't bother with this. Some clients (media monkey) use the filter and then don't display very well when very little data comes back.
return true;
//return _all || ListHelper.ContainsIgnoreCase(_fields, field);
// return _all || ListHelper.ContainsIgnoreCase(_fields, field);
}
}
}
9 changes: 4 additions & 5 deletions Emby.Dlna/DlnaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public IEnumerable<DeviceProfile> GetProfiles()
.Select(i => i.Item2)
.ToList();
}

}

public DeviceProfile GetDefaultProfile()
Expand Down Expand Up @@ -251,7 +250,7 @@ private bool IsMatch(IHeaderDictionary headers, HttpHeaderInfo header)
return string.Equals(value, header.Value, StringComparison.OrdinalIgnoreCase);
case HeaderMatchType.Substring:
var isMatch = value.ToString().IndexOf(header.Value, StringComparison.OrdinalIgnoreCase) != -1;
//_logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch);
// _logger.LogDebug("IsMatch-Substring value: {0} testValue: {1} isMatch: {2}", value, header.Value, isMatch);
return isMatch;
case HeaderMatchType.Regex:
return Regex.IsMatch(value, header.Value, RegexOptions.IgnoreCase);
Expand Down Expand Up @@ -566,9 +565,9 @@ private void DumpProfiles()
new Foobar2000Profile(),
new SharpSmartTvProfile(),
new MediaMonkeyProfile(),
//new Windows81Profile(),
//new WindowsMediaCenterProfile(),
//new WindowsPhoneProfile(),
// new Windows81Profile(),
// new WindowsMediaCenterProfile(),
// new WindowsPhoneProfile(),
new DirectTvProfile(),
new DishHopperJoeyProfile(),
new DefaultProfile(),
Expand Down
1 change: 0 additions & 1 deletion Emby.Dlna/Eventing/EventManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ private async Task TriggerEvent(EventSubscription subscription, IDictionary<stri
{
using (await _httpClient.SendAsync(options, new HttpMethod("NOTIFY")).ConfigureAwait(false))
{

}
}
catch (OperationCanceledException)
Expand Down
2 changes: 1 addition & 1 deletion Emby.Dlna/Main/DlnaEntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ private async Task RegisterServerEndpoints()

var device = new SsdpRootDevice
{
CacheLifetime = TimeSpan.FromSeconds(1800), //How long SSDP clients can cache this info.
CacheLifetime = TimeSpan.FromSeconds(1800), // How long SSDP clients can cache this info.
Location = uri, // Must point to the URL that serves your devices UPnP description document.
Address = address,
SubnetMask = _networkManager.GetLocalIpSubnetMask(address),
Expand Down
Loading

0 comments on commit 862bcdb

Please sign in to comment.