Merge pull request #1847 from MediaBrowser/dev

Dev
pull/702/head
Luke 9 years ago committed by GitHub
commit f18ea222f2

@ -1413,59 +1413,33 @@ namespace MediaBrowser.Controller.Entities
return; return;
} }
var recursiveItemCount = 0; var playedQueryResult = GetItems(new InternalItemsQuery(user)
var unplayed = 0;
double totalPercentPlayed = 0;
var itemsResult = GetItems(new InternalItemsQuery(user)
{ {
Recursive = true, Recursive = true,
IsFolder = false, IsFolder = false,
ExcludeLocationTypes = new[] { LocationType.Virtual }, IsVirtualItem = false,
EnableTotalRecordCount = false EnableTotalRecordCount = true,
Limit = 0,
IsPlayed = true
}).Result; }).Result;
var children = itemsResult.Items; var allItemsQueryResult = GetItems(new InternalItemsQuery(user)
// Loop through each recursive child
foreach (var child in children)
{
recursiveItemCount++;
var isUnplayed = true;
var itemUserData = UserDataManager.GetUserData(user, child);
// Incrememt totalPercentPlayed
if (itemUserData != null)
{
if (itemUserData.Played)
{ {
totalPercentPlayed += 100; Recursive = true,
IsFolder = false,
isUnplayed = false; IsVirtualItem = false,
} EnableTotalRecordCount = true,
else if (itemUserData.PlaybackPositionTicks > 0 && child.RunTimeTicks.HasValue && child.RunTimeTicks.Value > 0) Limit = 0
{
double itemPercent = itemUserData.PlaybackPositionTicks;
itemPercent /= child.RunTimeTicks.Value;
totalPercentPlayed += itemPercent;
}
}
if (isUnplayed) }).Result;
{
unplayed++;
}
}
dto.UnplayedItemCount = unplayed; double recursiveItemCount = allItemsQueryResult.TotalRecordCount;
double playedCount = playedQueryResult.TotalRecordCount;
if (recursiveItemCount > 0) if (recursiveItemCount > 0)
{ {
dto.PlayedPercentage = totalPercentPlayed / recursiveItemCount; dto.PlayedPercentage = (playedCount / recursiveItemCount) * 100;
dto.Played = dto.PlayedPercentage.Value >= 100; dto.Played = dto.PlayedPercentage.Value >= 100;
} }
} }

@ -208,7 +208,6 @@ namespace MediaBrowser.Server.Implementations.Library
var dto = GetUserItemDataDto(userData); var dto = GetUserItemDataDto(userData);
item.FillUserDataDtoValues(dto, userData, user); item.FillUserDataDtoValues(dto, userData, user);
return dto; return dto;
} }

@ -66,7 +66,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
{ {
CancellationToken = cancellationToken, CancellationToken = cancellationToken,
Url = path, Url = path,
Progress = new Progress<Double>() Progress = new Progress<Double>(),
EnableHttpCompression = false
}).ConfigureAwait(false); }).ConfigureAwait(false);
@ -96,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
ShortOverview = p.Description, ShortOverview = p.Description,
ProductionYear = !p.CopyrightDate.HasValue ? (int?)null : p.CopyrightDate.Value.Year, ProductionYear = !p.CopyrightDate.HasValue ? (int?)null : p.CopyrightDate.Value.Year,
SeasonNumber = p.Episode == null ? null : p.Episode.Series, SeasonNumber = p.Episode == null ? null : p.Episode.Series,
IsSeries = p.IsSeries, IsSeries = p.Episode != null,
IsRepeat = p.IsRepeat, IsRepeat = p.IsRepeat,
IsPremiere = p.Premiere != null, IsPremiere = p.Premiere != null,
IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)), IsKids = p.Categories.Any(c => info.KidsCategories.Contains(c, StringComparer.InvariantCultureIgnoreCase)),
@ -107,7 +108,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source), HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source),
OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null, OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null,
CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null, CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null,
SeriesId = p.IsSeries ? p.Title.GetMD5().ToString("N") : null SeriesId = p.Episode != null ? p.Title.GetMD5().ToString("N") : null
}); });
} }

@ -46,7 +46,7 @@
<HintPath>..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll</HintPath> <HintPath>..\packages\CommonIO.1.0.0.9\lib\net45\CommonIO.dll</HintPath>
</Reference> </Reference>
<Reference Include="Emby.XmlTv, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Emby.XmlTv, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Emby.XmlTv.1.0.0.51\lib\net45\Emby.XmlTv.dll</HintPath> <HintPath>..\packages\Emby.XmlTv.1.0.0.53\lib\net45\Emby.XmlTv.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL"> <Reference Include="INIFileParser, Version=2.3.0.0, Culture=neutral, PublicKeyToken=79af7b307b65cf3c, processorArchitecture=MSIL">

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonIO" version="1.0.0.9" targetFramework="net45" /> <package id="CommonIO" version="1.0.0.9" targetFramework="net45" />
<package id="Emby.XmlTv" version="1.0.0.51" targetFramework="net45" /> <package id="Emby.XmlTv" version="1.0.0.53" targetFramework="net45" />
<package id="ini-parser" version="2.3.0" targetFramework="net45" /> <package id="ini-parser" version="2.3.0" targetFramework="net45" />
<package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" /> <package id="Interfaces.IO" version="1.0.0.5" targetFramework="net45" />
<package id="MediaBrowser.Naming" version="1.0.0.51" targetFramework="net45" /> <package id="MediaBrowser.Naming" version="1.0.0.51" targetFramework="net45" />

@ -89,19 +89,21 @@ namespace MediaBrowser.ServerApplication.Networking
/// </summary> /// </summary>
/// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER /// <returns>Arraylist that represents all the SV_TYPE_WORKSTATION and SV_TYPE_SERVER
/// PC's in the Domain</returns> /// PC's in the Domain</returns>
private IEnumerable<string> GetNetworkDevicesInternal() private List<string> GetNetworkDevicesInternal()
{ {
//local fields //local fields
const int MAX_PREFERRED_LENGTH = -1; const int MAX_PREFERRED_LENGTH = -1;
var SV_TYPE_WORKSTATION = 1; var SV_TYPE_WORKSTATION = 1;
var SV_TYPE_SERVER = 2; var SV_TYPE_SERVER = 2;
var buffer = IntPtr.Zero; IntPtr buffer = IntPtr.Zero;
var tmpBuffer = IntPtr.Zero; IntPtr tmpBuffer = IntPtr.Zero;
var entriesRead = 0; var entriesRead = 0;
var totalEntries = 0; var totalEntries = 0;
var resHandle = 0; var resHandle = 0;
var sizeofINFO = Marshal.SizeOf(typeof(_SERVER_INFO_100)); var sizeofINFO = Marshal.SizeOf(typeof(_SERVER_INFO_100));
var returnList = new List<string>();
try try
{ {
//call the DllImport : NetServerEnum with all its required parameters //call the DllImport : NetServerEnum with all its required parameters
@ -118,7 +120,7 @@ namespace MediaBrowser.ServerApplication.Networking
//get pointer to, Pointer to the buffer that received the data from //get pointer to, Pointer to the buffer that received the data from
//the call to NetServerEnum. Must ensure to use correct size of //the call to NetServerEnum. Must ensure to use correct size of
//STRUCTURE to ensure correct location in memory is pointed to //STRUCTURE to ensure correct location in memory is pointed to
tmpBuffer = new IntPtr((int)buffer + (i * sizeofINFO)); tmpBuffer = new IntPtr((Int64)buffer + (i * sizeofINFO));
//Have now got a pointer to the list of SV_TYPE_WORKSTATION and //Have now got a pointer to the list of SV_TYPE_WORKSTATION and
//SV_TYPE_SERVER PC's, which is unmanaged memory //SV_TYPE_SERVER PC's, which is unmanaged memory
//Needs to Marshal data from an unmanaged block of memory to a //Needs to Marshal data from an unmanaged block of memory to a
@ -129,7 +131,7 @@ namespace MediaBrowser.ServerApplication.Networking
//add the PC names to the ArrayList //add the PC names to the ArrayList
if (!string.IsNullOrEmpty(svrInfo.sv100_name)) if (!string.IsNullOrEmpty(svrInfo.sv100_name))
{ {
yield return svrInfo.sv100_name; returnList.Add(svrInfo.sv100_name);
} }
} }
} }
@ -140,6 +142,8 @@ namespace MediaBrowser.ServerApplication.Networking
//the memory that the NetApiBufferAllocate function allocates //the memory that the NetApiBufferAllocate function allocates
NativeMethods.NetApiBufferFree(buffer); NativeMethods.NetApiBufferFree(buffer);
} }
return returnList;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save