Merge pull request #2399 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2017-01-14 15:06:07 -05:00 committed by GitHub
commit cd469cf31c
13 changed files with 191 additions and 53 deletions

View File

@ -43,7 +43,7 @@ namespace Emby.Dlna.Profiles
AudioCodec = "ac3", AudioCodec = "ac3",
VideoCodec = "h264", VideoCodec = "h264",
Type = DlnaProfileType.Video, Type = DlnaProfileType.Video,
EstimateContentLength = true EstimateContentLength = false
}, },
new TranscodingProfile new TranscodingProfile
{ {

View File

@ -51,7 +51,7 @@
</DirectPlayProfiles> </DirectPlayProfiles>
<TranscodingProfiles> <TranscodingProfiles>
<TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" /> <TranscodingProfile container="mp3" type="Audio" audioCodec="mp3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="ac3" estimateContentLength="true" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" /> <TranscodingProfile container="ts" type="Video" videoCodec="h264" audioCodec="ac3" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
<TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" /> <TranscodingProfile container="jpeg" type="Photo" estimateContentLength="false" enableMpegtsM2TsMode="false" transcodeSeekInfo="Auto" copyTimestamps="false" context="Streaming" enableSubtitlesInManifest="false" />
</TranscodingProfiles> </TranscodingProfiles>
<ContainerProfiles> <ContainerProfiles>

View File

@ -49,6 +49,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
string device = null; string device = null;
string client = null; string client = null;
string version = null; string version = null;
string token = null;
if (auth != null) if (auth != null)
{ {
@ -56,9 +57,13 @@ namespace Emby.Server.Implementations.HttpServer.Security
auth.TryGetValue("Device", out device); auth.TryGetValue("Device", out device);
auth.TryGetValue("Client", out client); auth.TryGetValue("Client", out client);
auth.TryGetValue("Version", out version); auth.TryGetValue("Version", out version);
auth.TryGetValue("Token", out token);
} }
var token = httpReq.Headers["X-Emby-Token"]; if (string.IsNullOrWhiteSpace(token))
{
token = httpReq.Headers["X-Emby-Token"];
}
if (string.IsNullOrWhiteSpace(token)) if (string.IsNullOrWhiteSpace(token))
{ {
@ -156,8 +161,10 @@ namespace Emby.Server.Implementations.HttpServer.Security
// There should be at least to parts // There should be at least to parts
if (parts.Length != 2) return null; if (parts.Length != 2) return null;
var acceptedNames = new[] { "MediaBrowser", "Emby"};
// It has to be a digest request // It has to be a digest request
if (!string.Equals(parts[0], "MediaBrowser", StringComparison.OrdinalIgnoreCase)) if (!acceptedNames.Contains(parts[0] ?? string.Empty, StringComparer.OrdinalIgnoreCase))
{ {
return null; return null;
} }
@ -174,7 +181,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
if (param.Length == 2) if (param.Length == 2)
{ {
var value = NormalizeValue (param[1].Trim(new[] { '"' })); var value = NormalizeValue(param[1].Trim(new[] { '"' }));
result.Add(param[0], value); result.Add(param[0], value);
} }
} }
@ -182,14 +189,14 @@ namespace Emby.Server.Implementations.HttpServer.Security
return result; return result;
} }
private string NormalizeValue(string value) private string NormalizeValue(string value)
{ {
if (string.IsNullOrWhiteSpace (value)) if (string.IsNullOrWhiteSpace(value))
{ {
return value; return value;
} }
return System.Net.WebUtility.HtmlEncode(value); return System.Net.WebUtility.HtmlEncode(value);
} }
} }
} }

View File

@ -2106,13 +2106,13 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{ {
return true; return true;
} }
if (!seriesTimer.Days.Contains(timer.StartDate.ToLocalTime().DayOfWeek))
{
return true;
}
} }
//if (!seriesTimer.Days.Contains(timer.StartDate.ToLocalTime().DayOfWeek))
//{
// return true;
//}
if (seriesTimer.RecordNewOnly && timer.IsRepeat) if (seriesTimer.RecordNewOnly && timer.IsRepeat)
{ {
return true; return true;

View File

@ -14,6 +14,7 @@ using MediaBrowser.Controller;
using MediaBrowser.Controller.IO; using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Logging; using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Extensions;
namespace Emby.Server.Implementations.LiveTv.TunerHosts namespace Emby.Server.Implementations.LiveTv.TunerHosts
{ {
@ -43,6 +44,17 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
} }
} }
public List<M3UChannel> ParseString(string text, string channelIdPrefix, string tunerHostId)
{
var urlHash = "text".GetMD5().ToString("N");
// Read the file and display it line by line.
using (var reader = new StringReader(text))
{
return GetChannels(reader, urlHash, channelIdPrefix, tunerHostId);
}
}
public Task<Stream> GetListingsStream(string url, CancellationToken cancellationToken) public Task<Stream> GetListingsStream(string url, CancellationToken cancellationToken)
{ {
if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) if (url.StartsWith("http", StringComparison.OrdinalIgnoreCase))
@ -59,7 +71,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
} }
const string ExtInfPrefix = "#EXTINF:"; const string ExtInfPrefix = "#EXTINF:";
private List<M3UChannel> GetChannels(StreamReader reader, string urlHash, string channelIdPrefix, string tunerHostId) private List<M3UChannel> GetChannels(TextReader reader, string urlHash, string channelIdPrefix, string tunerHostId)
{ {
var channels = new List<M3UChannel>(); var channels = new List<M3UChannel>();
string line; string line;
@ -122,18 +134,22 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
var numberString = nameParts[0]; string numberString = null;
//Check for channel number with the format from SatIp // Check for channel number with the format from SatIp
int number; // #EXTINF:0,84. VOX Schweiz
// #EXTINF:0,84.0 - VOX Schweiz
if (!string.IsNullOrWhiteSpace(nameInExtInf)) if (!string.IsNullOrWhiteSpace(nameInExtInf))
{ {
var numberIndex = nameInExtInf.IndexOf('.'); var numberIndex = nameInExtInf.IndexOf(' ');
if (numberIndex > 0) if (numberIndex > 0)
{ {
if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
double number;
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
{ {
numberString = number.ToString(); numberString = numberPart;
} }
} }
} }
@ -150,7 +166,11 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
string value; string value;
if (attributes.TryGetValue("tvg-id", out value)) if (attributes.TryGetValue("tvg-id", out value))
{ {
numberString = value; double doubleValue;
if (double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out doubleValue))
{
numberString = value;
}
} }
} }
@ -208,17 +228,21 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var nameParts = extInf.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null; var nameInExtInf = nameParts.Length > 1 ? nameParts.Last().Trim() : null;
//Check for channel number with the format from SatIp // Check for channel number with the format from SatIp
int number; // #EXTINF:0,84. VOX Schweiz
// #EXTINF:0,84.0 - VOX Schweiz
if (!string.IsNullOrWhiteSpace(nameInExtInf)) if (!string.IsNullOrWhiteSpace(nameInExtInf))
{ {
var numberIndex = nameInExtInf.IndexOf('.'); var numberIndex = nameInExtInf.IndexOf(' ');
if (numberIndex > 0) if (numberIndex > 0)
{ {
if (int.TryParse(nameInExtInf.Substring(0, numberIndex), out number)) var numberPart = nameInExtInf.Substring(0, numberIndex).Trim(new[] { ' ', '.' });
double number;
if (double.TryParse(numberPart, NumberStyles.Any, CultureInfo.InvariantCulture, out number))
{ {
//channel.Number = number.ToString(); //channel.Number = number.ToString();
nameInExtInf = nameInExtInf.Substring(numberIndex + 1); nameInExtInf = nameInExtInf.Substring(numberIndex + 1).Trim(new[] { ' ', '-' });
} }
} }
} }
@ -250,20 +274,18 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts
var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase); var reg = new Regex(@"([a-z0-9\-_]+)=\""([^""]+)\""", RegexOptions.IgnoreCase);
var matches = reg.Matches(line); var matches = reg.Matches(line);
var minIndex = int.MaxValue;
foreach (Match match in matches)
{
dict[match.Groups[1].Value] = match.Groups[2].Value;
minIndex = Math.Min(minIndex, match.Index);
}
if (minIndex > 0 && minIndex < line.Length)
{
line = line.Substring(0, minIndex);
}
remaining = line; remaining = line;
foreach (Match match in matches)
{
var key = match.Groups[1].Value;
var value = match.Groups[2].Value;
dict[match.Groups[1].Value] = match.Groups[2].Value;
remaining = remaining.Replace(key + "=\"" + value + "\"", string.Empty, StringComparison.OrdinalIgnoreCase);
}
return dict; return dict;
} }
} }

View File

@ -100,7 +100,7 @@ namespace Emby.Server.Implementations.Playlists
if (string.IsNullOrWhiteSpace(options.MediaType)) if (string.IsNullOrWhiteSpace(options.MediaType))
{ {
throw new ArgumentException("A playlist media type is required."); options.MediaType = "Audio";
} }
var user = _userManager.GetUserById(options.UserId); var user = _userManager.GetUserById(options.UserId);

View File

@ -560,6 +560,12 @@ namespace Emby.Server.Implementations.Sync
{ {
var jobItem = _repo.GetJobItem(id); var jobItem = _repo.GetJobItem(id);
if (jobItem == null)
{
_logger.Debug("ReportSyncJobItemTransferred: SyncJobItem {0} doesn't exist anymore", id);
return;
}
jobItem.Status = SyncJobItemStatus.Synced; jobItem.Status = SyncJobItemStatus.Synced;
jobItem.Progress = 100; jobItem.Progress = 100;

View File

@ -66,29 +66,39 @@ namespace MediaBrowser.Providers.TV
.Distinct() .Distinct()
.ToList()) .ToList())
{ {
var hasSeason = series.Children.OfType<Season>() var existingSeason = series.Children.OfType<Season>()
.Any(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber); .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == seasonNumber);
if (!hasSeason) if (existingSeason == null)
{ {
await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false); await AddSeason(series, seasonNumber, false, cancellationToken).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }
else if (existingSeason.IsVirtualItem)
{
existingSeason.IsVirtualItem = false;
await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
} }
// Unknown season - create a dummy season to put these under // Unknown season - create a dummy season to put these under
if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue)) if (episodesInSeriesFolder.Any(i => !i.ParentIndexNumber.HasValue))
{ {
var hasSeason = series.Children.OfType<Season>() var existingSeason = series.Children.OfType<Season>()
.Any(i => !i.IndexNumber.HasValue); .FirstOrDefault(i => !i.IndexNumber.HasValue);
if (!hasSeason) if (existingSeason == null)
{ {
await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false); await AddSeason(series, null, false, cancellationToken).ConfigureAwait(false);
hasChanges = true; hasChanges = true;
} }
else if (existingSeason.IsVirtualItem)
{
existingSeason.IsVirtualItem = false;
await existingSeason.UpdateToRepository(ItemUpdateType.MetadataEdit, cancellationToken).ConfigureAwait(false);
}
} }
return hasChanges; return hasChanges;

View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Emby.Common.Implementations.Cryptography;
using Emby.Server.Implementations.LiveTv.TunerHosts;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Model.Logging;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MediaBrowser.Tests
{
[TestClass]
public class M3uParserTest
{
[TestMethod]
public void TestFormat1()
{
BaseExtensions.CryptographyProvider = new CryptographyProvider();
var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0,84. VOX Schweiz\nhttp://mystream", "-", "-");
Assert.AreEqual(1, result.Count);
Assert.AreEqual("VOX Schweiz", result[0].Name);
Assert.AreEqual("84", result[0].Number);
}
[TestMethod]
public void TestFormat2()
{
BaseExtensions.CryptographyProvider = new CryptographyProvider();
var input = "#EXTINF:-1 tvg-id=\"\" tvg-name=\"ABC News 04\" tvg-logo=\"\" group-title=\"ABC Group\",ABC News 04";
input += "\n";
input += "http://mystream";
var result = new M3uParser(new NullLogger(), null, null, null).ParseString(input, "-", "-");
Assert.AreEqual(1, result.Count);
Assert.AreEqual("ABC News 04", result[0].Name);
Assert.IsNull(result[0].Number);
}
[TestMethod]
public void TestFormat3()
{
BaseExtensions.CryptographyProvider = new CryptographyProvider();
var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0, 3.2 - Movies!\nhttp://mystream", "-", "-");
Assert.AreEqual(1, result.Count);
Assert.AreEqual("Movies!", result[0].Name);
Assert.AreEqual("3.2", result[0].Number);
}
[TestMethod]
public void TestFormat4()
{
BaseExtensions.CryptographyProvider = new CryptographyProvider();
var result = new M3uParser(new NullLogger(), null, null, null).ParseString("#EXTINF:0 tvg-id=\"abckabclosangeles.path.to\" tvg-logo=\"path.to / channel_logos / abckabclosangeles.png\", ABC KABC Los Angeles\nhttp://mystream", "-", "-");
Assert.AreEqual(1, result.Count);
Assert.IsNull(result[0].Number);
Assert.AreEqual("ABC KABC Los Angeles", result[0].Name);
}
}
}

View File

@ -37,6 +37,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Emby.Common.Implementations">
<HintPath>..\ThirdParty\emby\Emby.Common.Implementations.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.XML" /> <Reference Include="System.XML" />
</ItemGroup> </ItemGroup>
@ -58,12 +61,21 @@
<Compile Include="ConsistencyTests\TextIndexing\WordIndex.cs" /> <Compile Include="ConsistencyTests\TextIndexing\WordIndex.cs" />
<Compile Include="ConsistencyTests\TextIndexing\WordOccurrence.cs" /> <Compile Include="ConsistencyTests\TextIndexing\WordOccurrence.cs" />
<Compile Include="ConsistencyTests\TextIndexing\WordOccurrences.cs" /> <Compile Include="ConsistencyTests\TextIndexing\WordOccurrences.cs" />
<Compile Include="M3uParserTest.cs" />
<Compile Include="MediaEncoding\Subtitles\AssParserTests.cs" /> <Compile Include="MediaEncoding\Subtitles\AssParserTests.cs" />
<Compile Include="MediaEncoding\Subtitles\SrtParserTests.cs" /> <Compile Include="MediaEncoding\Subtitles\SrtParserTests.cs" />
<Compile Include="MediaEncoding\Subtitles\VttWriterTest.cs" /> <Compile Include="MediaEncoding\Subtitles\VttWriterTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Emby.Server.Implementations\Emby.Server.Implementations.csproj">
<Project>{e383961b-9356-4d5d-8233-9a1079d03055}</Project>
<Name>Emby.Server.Implementations</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Common\MediaBrowser.Common.csproj">
<Project>{9142eefa-7570-41e1-bfcc-468bb571af2f}</Project>
<Name>MediaBrowser.Common</Name>
</ProjectReference>
<ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj"> <ProjectReference Include="..\MediaBrowser.Controller\MediaBrowser.Controller.csproj">
<Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project> <Project>{17e1f4e6-8abd-4fe5-9ecf-43d4b6087ba2}</Project>
<Name>MediaBrowser.Controller</Name> <Name>MediaBrowser.Controller</Name>

View File

@ -964,7 +964,20 @@ namespace MediaBrowser.XbmcMetadata.Parsers
} }
default: default:
reader.Skip(); string readerName = reader.Name;
string providerIdValue;
if (_validProviderIds.TryGetValue(readerName, out providerIdValue))
{
var id = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(id))
{
item.SetProviderId(providerIdValue, id);
}
}
else
{
reader.Skip();
}
break; break;
} }
} }

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Common</id> <id>MediaBrowser.Common</id>
<version>3.0.693</version> <version>3.0.694</version>
<title>Emby.Common</title> <title>Emby.Common</title>
<authors>Emby Team</authors> <authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>MediaBrowser.Server.Core</id> <id>MediaBrowser.Server.Core</id>
<version>3.0.693</version> <version>3.0.694</version>
<title>Emby.Server.Core</title> <title>Emby.Server.Core</title>
<authors>Emby Team</authors> <authors>Emby Team</authors>
<owners>ebr,Luke,scottisafool</owners> <owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Emby Server.</description> <description>Contains core components required to build plugins for Emby Server.</description>
<copyright>Copyright © Emby 2013</copyright> <copyright>Copyright © Emby 2013</copyright>
<dependencies> <dependencies>
<dependency id="MediaBrowser.Common" version="3.0.693" /> <dependency id="MediaBrowser.Common" version="3.0.694" />
</dependencies> </dependencies>
</metadata> </metadata>
<files> <files>