Merge pull request #1533 from MediaBrowser/dev

Dev
pull/702/head
Luke 9 years ago
commit c87e42b970

@ -73,9 +73,13 @@ namespace MediaBrowser.Api.Playback.Progressive
audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture)); audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
} }
if (state.OutputAudioSampleRate.HasValue) // opus will fail on 44100
if (!string.Equals(state.OutputAudioCodec, "opus", global::System.StringComparison.OrdinalIgnoreCase))
{ {
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture)); if (state.OutputAudioSampleRate.HasValue)
{
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
}
} }
const string vn = " -vn"; const string vn = " -vn";

@ -35,9 +35,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture)); audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(UsCulture));
} }
if (state.OutputAudioSampleRate.HasValue) // opus will fail on 44100
if (!string.Equals(state.OutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase))
{ {
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture)); if (state.OutputAudioSampleRate.HasValue)
{
audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(UsCulture));
}
} }
const string vn = " -vn"; const string vn = " -vn";

@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.BoxSets
{ {
var language = item.GetPreferredMetadataLanguage(); var language = item.GetPreferredMetadataLanguage();
var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, language, cancellationToken).ConfigureAwait(false); var mainResult = await MovieDbBoxSetProvider.Current.GetMovieDbResult(tmdbId, null, cancellationToken).ConfigureAwait(false);
if (mainResult != null) if (mainResult != null)
{ {

@ -169,11 +169,10 @@ namespace MediaBrowser.Providers.BoxSets
if (!string.IsNullOrEmpty(language)) if (!string.IsNullOrEmpty(language))
{ {
url += string.Format("&language={0}", language); url += string.Format("&language={0}", language);
}
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language); // Get images in english and with no language
// Get images in english and with no language url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
url += "&include_image_language=" + includeImageLanguageParam; }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -196,7 +195,13 @@ namespace MediaBrowser.Providers.BoxSets
{ {
if (!string.IsNullOrEmpty(language) && !string.Equals(language, "en", StringComparison.OrdinalIgnoreCase)) if (!string.IsNullOrEmpty(language) && !string.Equals(language, "en", StringComparison.OrdinalIgnoreCase))
{ {
url = string.Format(GetCollectionInfo3, id, MovieDbSearch.ApiKey) + "&include_image_language=en,null&language=en"; url = string.Format(GetCollectionInfo3, id, MovieDbSearch.ApiKey) + "&language=en";
if (!string.IsNullOrEmpty(language))
{
// Get images in english and with no language
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
}
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{ {
@ -239,15 +244,9 @@ namespace MediaBrowser.Providers.BoxSets
private static string GetDataFilePath(IApplicationPaths appPaths, string tmdbId, string preferredLanguage) private static string GetDataFilePath(IApplicationPaths appPaths, string tmdbId, string preferredLanguage)
{ {
if (string.IsNullOrWhiteSpace(preferredLanguage))
{
throw new ArgumentNullException("preferredLanguage");
}
var path = GetDataPath(appPaths, tmdbId); var path = GetDataPath(appPaths, tmdbId);
var filename = string.Format("all-{0}.json", var filename = string.Format("all-{0}.json", preferredLanguage ?? string.Empty);
preferredLanguage);
return Path.Combine(path, filename); return Path.Combine(path, filename);
} }

@ -97,7 +97,7 @@ namespace MediaBrowser.Providers.Manager
var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem); var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem);
var localImagesFailed = false; var localImagesFailed = false;
var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList(); var allImageProviders = ((ProviderManager)ProviderManager).GetImageProviders(item, refreshOptions).ToList();
// Start by validating images // Start by validating images
try try
@ -301,17 +301,23 @@ namespace MediaBrowser.Providers.Manager
{ {
if (ServerConfigurationManager.Configuration.DownloadImagesInAdvance) if (ServerConfigurationManager.Configuration.DownloadImagesInAdvance)
{ {
await ProviderManager.SaveImage(personEntity, imageUrl, null, ImageType.Primary, null, cancellationToken).ConfigureAwait(false); try
}
else
{
personEntity.SetImage(new ItemImageInfo
{ {
Path = imageUrl, await ProviderManager.SaveImage(personEntity, imageUrl, null, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
Type = ImageType.Primary, return;
IsPlaceholder = true }
}, 0); catch (Exception ex)
{
Logger.ErrorException("Error in AddPersonImage", ex);
}
} }
personEntity.SetImage(new ItemImageInfo
{
Path = imageUrl,
Type = ImageType.Primary,
IsPlaceholder = true
}, 0);
} }
private readonly Task _cachedTask = Task.FromResult(true); private readonly Task _cachedTask = Task.FromResult(true);

@ -82,7 +82,7 @@ namespace MediaBrowser.Providers.Movies
{ {
var list = new List<RemoteImageInfo>(); var list = new List<RemoteImageInfo>();
var results = await FetchImages((BaseItem)item, _jsonSerializer, cancellationToken).ConfigureAwait(false); var results = await FetchImages((BaseItem)item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false);
if (results == null) if (results == null)
{ {
@ -183,14 +183,13 @@ namespace MediaBrowser.Providers.Movies
/// Fetches the images. /// Fetches the images.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="language">The language.</param>
/// <param name="jsonSerializer">The json serializer.</param> /// <param name="jsonSerializer">The json serializer.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MovieImages}.</returns> /// <returns>Task{MovieImages}.</returns>
private async Task<MovieDbProvider.Images> FetchImages(BaseItem item, IJsonSerializer jsonSerializer, private async Task<MovieDbProvider.Images> FetchImages(BaseItem item, string language, IJsonSerializer jsonSerializer, CancellationToken cancellationToken)
CancellationToken cancellationToken)
{ {
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb); var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
var language = item.GetPreferredMetadataLanguage();
if (string.IsNullOrWhiteSpace(tmdbId)) if (string.IsNullOrWhiteSpace(tmdbId))
{ {

@ -226,10 +226,6 @@ namespace MediaBrowser.Providers.Movies
{ {
throw new ArgumentNullException("tmdbId"); throw new ArgumentNullException("tmdbId");
} }
if (string.IsNullOrEmpty(language))
{
throw new ArgumentNullException("language");
}
var path = GetDataFilePath(tmdbId, language); var path = GetDataFilePath(tmdbId, language);
@ -253,15 +249,15 @@ namespace MediaBrowser.Providers.Movies
{ {
throw new ArgumentNullException("tmdbId"); throw new ArgumentNullException("tmdbId");
} }
if (string.IsNullOrEmpty(preferredLanguage))
{
throw new ArgumentNullException("preferredLanguage");
}
var path = GetMovieDataPath(_configurationManager.ApplicationPaths, tmdbId); var path = GetMovieDataPath(_configurationManager.ApplicationPaths, tmdbId);
var filename = string.Format("all-{0}.json", if (string.IsNullOrWhiteSpace(preferredLanguage))
preferredLanguage); {
preferredLanguage = "alllang";
}
var filename = string.Format("all-{0}.json", preferredLanguage);
return Path.Combine(path, filename); return Path.Combine(path, filename);
} }
@ -298,11 +294,10 @@ namespace MediaBrowser.Providers.Movies
if (!string.IsNullOrEmpty(language)) if (!string.IsNullOrEmpty(language))
{ {
url += string.Format("&language={0}", language); url += string.Format("&language={0}", language);
}
var includeImageLanguageParam = GetImageLanguagesParam(language); // Get images in english and with no language
// Get images in english and with no language url += "&include_image_language=" + GetImageLanguagesParam(language);
url += "&include_image_language=" + includeImageLanguageParam; }
CompleteMovieData mainResult; CompleteMovieData mainResult;
@ -348,7 +343,13 @@ namespace MediaBrowser.Providers.Movies
{ {
_logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English..."); _logger.Info("MovieDbProvider couldn't find meta for language " + language + ". Trying English...");
url = string.Format(GetMovieInfo3, id, ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en"; url = string.Format(GetMovieInfo3, id, ApiKey) + "&language=en";
if (!string.IsNullOrEmpty(language))
{
// Get images in english and with no language
url += "&include_image_language=" + GetImageLanguagesParam(language);
}
using (var json = await GetMovieDbResponse(new HttpRequestOptions using (var json = await GetMovieDbResponse(new HttpRequestOptions
{ {

@ -55,7 +55,7 @@ namespace MediaBrowser.Providers.TV
{ {
var list = new List<RemoteImageInfo>(); var list = new List<RemoteImageInfo>();
var results = await FetchImages((BaseItem)item, _jsonSerializer, cancellationToken).ConfigureAwait(false); var results = await FetchImages((BaseItem)item, null, _jsonSerializer, cancellationToken).ConfigureAwait(false);
if (results == null) if (results == null)
{ {
@ -146,14 +146,14 @@ namespace MediaBrowser.Providers.TV
/// Fetches the images. /// Fetches the images.
/// </summary> /// </summary>
/// <param name="item">The item.</param> /// <param name="item">The item.</param>
/// <param name="language">The language.</param>
/// <param name="jsonSerializer">The json serializer.</param> /// <param name="jsonSerializer">The json serializer.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task{MovieImages}.</returns> /// <returns>Task{MovieImages}.</returns>
private async Task<MovieDbSeriesProvider.Images> FetchImages(BaseItem item, IJsonSerializer jsonSerializer, private async Task<MovieDbSeriesProvider.Images> FetchImages(BaseItem item, string language, IJsonSerializer jsonSerializer,
CancellationToken cancellationToken) CancellationToken cancellationToken)
{ {
var tmdbId = item.GetProviderId(MetadataProviders.Tmdb); var tmdbId = item.GetProviderId(MetadataProviders.Tmdb);
var language = item.GetPreferredMetadataLanguage();
if (string.IsNullOrEmpty(tmdbId)) if (string.IsNullOrEmpty(tmdbId))
{ {

@ -302,11 +302,10 @@ namespace MediaBrowser.Providers.TV
if (!string.IsNullOrEmpty(language)) if (!string.IsNullOrEmpty(language))
{ {
url += string.Format("&language={0}", language); url += string.Format("&language={0}", language);
}
var includeImageLanguageParam = MovieDbProvider.GetImageLanguagesParam(language); // Get images in english and with no language
// Get images in english and with no language url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
url += "&include_image_language=" + includeImageLanguageParam; }
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
@ -333,7 +332,13 @@ namespace MediaBrowser.Providers.TV
{ {
_logger.Info("MovieDbSeriesProvider couldn't find meta for language " + language + ". Trying English..."); _logger.Info("MovieDbSeriesProvider couldn't find meta for language " + language + ". Trying English...");
url = string.Format(GetTvInfo3, id, MovieDbProvider.ApiKey) + "&include_image_language=" + includeImageLanguageParam + "&language=en"; url = string.Format(GetTvInfo3, id, MovieDbProvider.ApiKey) + "&language=en";
if (!string.IsNullOrEmpty(language))
{
// Get images in english and with no language
url += "&include_image_language=" + MovieDbProvider.GetImageLanguagesParam(language);
}
using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions using (var json = await MovieDbProvider.Current.GetMovieDbResponse(new HttpRequestOptions
{ {
@ -359,10 +364,6 @@ namespace MediaBrowser.Providers.TV
{ {
throw new ArgumentNullException("tmdbId"); throw new ArgumentNullException("tmdbId");
} }
if (string.IsNullOrEmpty(language))
{
throw new ArgumentNullException("language");
}
var path = GetDataFilePath(tmdbId, language); var path = GetDataFilePath(tmdbId, language);
@ -386,15 +387,10 @@ namespace MediaBrowser.Providers.TV
{ {
throw new ArgumentNullException("tmdbId"); throw new ArgumentNullException("tmdbId");
} }
if (string.IsNullOrEmpty(preferredLanguage))
{
throw new ArgumentNullException("preferredLanguage");
}
var path = GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId); var path = GetSeriesDataPath(_configurationManager.ApplicationPaths, tmdbId);
var filename = string.Format("series-{0}.json", var filename = string.Format("series-{0}.json", preferredLanguage ?? string.Empty);
preferredLanguage ?? string.Empty);
return Path.Combine(path, filename); return Path.Combine(path, filename);
} }

@ -27,6 +27,11 @@ namespace MediaBrowser.Providers.TV
public static TvdbSeasonIdentity? ParseIdentity(string id) public static TvdbSeasonIdentity? ParseIdentity(string id)
{ {
if (id == null)
{
return null;
}
try try
{ {
var parts = id.Split(':'); var parts = id.Split(':');

@ -160,19 +160,19 @@ namespace MediaBrowser.Providers.TV
var series = result.Item; var series = result.Item;
string id; string id;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id))
{ {
series.SetProviderId(MetadataProviders.Tvdb, id); series.SetProviderId(MetadataProviders.Tvdb, id);
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id))
{ {
series.SetProviderId(MetadataProviders.Imdb, id); series.SetProviderId(MetadataProviders.Imdb, id);
} }
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
var seriesXmlPath = GetSeriesXmlPath (seriesProviderIds, metadataLanguage); var seriesXmlPath = GetSeriesXmlPath(seriesProviderIds, metadataLanguage);
var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml"); var actorsXmlPath = Path.Combine(seriesDataPath, "actors.xml");
FetchSeriesInfo(series, seriesXmlPath, cancellationToken); FetchSeriesInfo(series, seriesXmlPath, cancellationToken);
@ -320,7 +320,7 @@ namespace MediaBrowser.Providers.TV
internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds) internal static bool IsValidSeries(Dictionary<string, string> seriesProviderIds)
{ {
string id; string id;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out id) && !string.IsNullOrEmpty(id))
{ {
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))
@ -329,7 +329,7 @@ namespace MediaBrowser.Providers.TV
} }
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out id) && !string.IsNullOrEmpty(id))
{ {
// This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet. // This check should ideally never be necessary but we're seeing some cases of this and haven't tracked them down yet.
if (!string.IsNullOrWhiteSpace(id)) if (!string.IsNullOrWhiteSpace(id))
@ -340,7 +340,7 @@ namespace MediaBrowser.Providers.TV
return false; return false;
} }
private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1,1); private SemaphoreSlim _ensureSemaphore = new SemaphoreSlim(1, 1);
internal async Task<string> EnsureSeriesInfo(Dictionary<string, string> seriesProviderIds, string preferredMetadataLanguage, CancellationToken cancellationToken) internal async Task<string> EnsureSeriesInfo(Dictionary<string, string> seriesProviderIds, string preferredMetadataLanguage, CancellationToken cancellationToken)
{ {
await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false); await _ensureSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
@ -348,7 +348,7 @@ namespace MediaBrowser.Providers.TV
try try
{ {
string seriesId; string seriesId;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId))
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
@ -362,7 +362,7 @@ namespace MediaBrowser.Providers.TV
return seriesDataPath; return seriesDataPath;
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId))
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
@ -1300,14 +1300,14 @@ namespace MediaBrowser.Providers.TV
internal static string GetSeriesDataPath(IApplicationPaths appPaths, Dictionary<string, string> seriesProviderIds) internal static string GetSeriesDataPath(IApplicationPaths appPaths, Dictionary<string, string> seriesProviderIds)
{ {
string seriesId; string seriesId;
if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId))
{ {
var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId);
return seriesDataPath; return seriesDataPath;
} }
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId)) if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out seriesId) && !string.IsNullOrEmpty(seriesId))
{ {
var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId); var seriesDataPath = Path.Combine(GetSeriesDataPath(appPaths), seriesId);
@ -1317,14 +1317,14 @@ namespace MediaBrowser.Providers.TV
return null; return null;
} }
public string GetSeriesXmlPath(Dictionary<string, string> seriesProviderIds, string language) public string GetSeriesXmlPath(Dictionary<string, string> seriesProviderIds, string language)
{ {
var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds); var seriesDataPath = GetSeriesDataPath(_config.ApplicationPaths, seriesProviderIds);
var seriesXmlFilename = language.ToLower() + ".xml"; var seriesXmlFilename = language.ToLower() + ".xml";
return Path.Combine (seriesDataPath, seriesXmlFilename); return Path.Combine(seriesDataPath, seriesXmlFilename);
} }
/// <summary> /// <summary>
/// Gets the series data path. /// Gets the series data path.
@ -1466,4 +1466,4 @@ namespace MediaBrowser.Providers.TV
}; };
} }
} }
} }

@ -84,7 +84,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.ErrorException("Error organizing episode {0}", ex, file); _logger.ErrorException("Error organizing episode {0}", ex, file.FullName);
} }
numComplete++; numComplete++;
@ -132,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
{ {
try try
{ {
return _fileSystem.GetFiles(path, true) return _fileSystem.GetFiles(path, true)
.ToList(); .ToList();
} }
catch (IOException ex) catch (IOException ex)
@ -150,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
/// <param name="extensions">The extensions.</param> /// <param name="extensions">The extensions.</param>
private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions) private void DeleteLeftOverFiles(string path, IEnumerable<string> extensions)
{ {
var eligibleFiles = _fileSystem.GetFiles(path, true) var eligibleFiles = _fileSystem.GetFiles(path, true)
.Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase)) .Where(i => extensions.Contains(i.Extension, StringComparer.OrdinalIgnoreCase))
.ToList(); .ToList();
@ -206,4 +206,4 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
return watchLocations.Contains(path, StringComparer.OrdinalIgnoreCase); return watchLocations.Contains(path, StringComparer.OrdinalIgnoreCase);
} }
} }
} }

@ -17,6 +17,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Common.IO; using MediaBrowser.Common.IO;
using MediaBrowser.Model.Configuration;
namespace MediaBrowser.Server.Implementations.Library namespace MediaBrowser.Server.Implementations.Library
{ {
@ -276,7 +277,7 @@ namespace MediaBrowser.Server.Implementations.Library
private void SetDefaultSubtitleStreamIndex(MediaSourceInfo source, UserItemData userData, User user) private void SetDefaultSubtitleStreamIndex(MediaSourceInfo source, UserItemData userData, User user)
{ {
if (userData.SubtitleStreamIndex.HasValue && user.Configuration.RememberSubtitleSelections) if (userData.SubtitleStreamIndex.HasValue && user.Configuration.RememberSubtitleSelections && user.Configuration.SubtitleMode != SubtitlePlaybackMode.None)
{ {
var index = userData.SubtitleStreamIndex.Value; var index = userData.SubtitleStreamIndex.Value;
// Make sure the saved index is still valid // Make sure the saved index is still valid

@ -21,225 +21,225 @@ using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
{ {
//public class SatIpDiscovery : IServerEntryPoint public class SatIpDiscovery : IServerEntryPoint
//{ {
// private readonly IDeviceDiscovery _deviceDiscovery; private readonly IDeviceDiscovery _deviceDiscovery;
// private readonly IServerConfigurationManager _config; private readonly IServerConfigurationManager _config;
// private readonly ILogger _logger; private readonly ILogger _logger;
// private readonly ILiveTvManager _liveTvManager; private readonly ILiveTvManager _liveTvManager;
// private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
// private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
// private readonly IJsonSerializer _json; private readonly IJsonSerializer _json;
// public static SatIpDiscovery Current; public static SatIpDiscovery Current;
// private readonly List<TunerHostInfo> _discoveredHosts = new List<TunerHostInfo>(); private readonly List<TunerHostInfo> _discoveredHosts = new List<TunerHostInfo>();
// public List<TunerHostInfo> DiscoveredHosts public List<TunerHostInfo> DiscoveredHosts
// { {
// get { return _discoveredHosts.ToList(); } get { return _discoveredHosts.ToList(); }
// } }
// public SatIpDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json) public SatIpDiscovery(IDeviceDiscovery deviceDiscovery, IServerConfigurationManager config, ILogger logger, ILiveTvManager liveTvManager, IHttpClient httpClient, IJsonSerializer json)
// { {
// _deviceDiscovery = deviceDiscovery; _deviceDiscovery = deviceDiscovery;
// _config = config; _config = config;
// _logger = logger; _logger = logger;
// _liveTvManager = liveTvManager; _liveTvManager = liveTvManager;
// _httpClient = httpClient; _httpClient = httpClient;
// _json = json; _json = json;
// Current = this; Current = this;
// } }
// public void Run() public void Run()
// { {
// _deviceDiscovery.DeviceDiscovered += _deviceDiscovery_DeviceDiscovered; _deviceDiscovery.DeviceDiscovered += _deviceDiscovery_DeviceDiscovered;
// } }
// void _deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e) void _deviceDiscovery_DeviceDiscovered(object sender, SsdpMessageEventArgs e)
// { {
// string st = null; string st = null;
// string nt = null; string nt = null;
// e.Headers.TryGetValue("ST", out st); e.Headers.TryGetValue("ST", out st);
// e.Headers.TryGetValue("NT", out nt); e.Headers.TryGetValue("NT", out nt);
// if (string.Equals(st, "urn:ses-com:device:SatIPServer:1", StringComparison.OrdinalIgnoreCase) || if (string.Equals(st, "urn:ses-com:device:SatIPServer:1", StringComparison.OrdinalIgnoreCase) ||
// string.Equals(nt, "urn:ses-com:device:SatIPServer:1", StringComparison.OrdinalIgnoreCase)) string.Equals(nt, "urn:ses-com:device:SatIPServer:1", StringComparison.OrdinalIgnoreCase))
// { {
// string location; string location;
// if (e.Headers.TryGetValue("Location", out location) && !string.IsNullOrWhiteSpace(location)) if (e.Headers.TryGetValue("Location", out location) && !string.IsNullOrWhiteSpace(location))
// { {
// _logger.Debug("SAT IP found at {0}", location); _logger.Debug("SAT IP found at {0}", location);
// // Just get the beginning of the url // Just get the beginning of the url
// AddDevice(location); AddDevice(location);
// } }
// } }
// } }
// private async void AddDevice(string location) private async void AddDevice(string location)
// { {
// await _semaphore.WaitAsync().ConfigureAwait(false); await _semaphore.WaitAsync().ConfigureAwait(false);
// try try
// { {
// if (_discoveredHosts.Any(i => string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) && string.Equals(location, i.Url, StringComparison.OrdinalIgnoreCase))) if (_discoveredHosts.Any(i => string.Equals(i.Type, SatIpHost.DeviceType, StringComparison.OrdinalIgnoreCase) && string.Equals(location, i.Url, StringComparison.OrdinalIgnoreCase)))
// { {
// return; return;
// } }
// _logger.Debug("Will attempt to add SAT device {0}", location); _logger.Debug("Will attempt to add SAT device {0}", location);
// var info = await GetInfo(location, CancellationToken.None).ConfigureAwait(false); var info = await GetInfo(location, CancellationToken.None).ConfigureAwait(false);
// _discoveredHosts.Add(info); _discoveredHosts.Add(info);
// } }
// catch (OperationCanceledException) catch (OperationCanceledException)
// { {
// } }
// catch (NotImplementedException) catch (NotImplementedException)
// { {
// } }
// catch (Exception ex) catch (Exception ex)
// { {
// _logger.ErrorException("Error saving device", ex); _logger.ErrorException("Error saving device", ex);
// } }
// finally finally
// { {
// _semaphore.Release(); _semaphore.Release();
// } }
// } }
// public void Dispose() public void Dispose()
// { {
// } }
// public async Task<SatIpTunerHostInfo> GetInfo(string url, CancellationToken cancellationToken) public async Task<SatIpTunerHostInfo> GetInfo(string url, CancellationToken cancellationToken)
// { {
// var result = new SatIpTunerHostInfo var result = new SatIpTunerHostInfo
// { {
// Url = url, Url = url,
// IsEnabled = true, IsEnabled = true,
// Type = SatIpHost.DeviceType, Type = SatIpHost.DeviceType,
// Tuners = 1, Tuners = 1,
// TunersAvailable = 1 TunersAvailable = 1
// }; };
// using (var stream = await _httpClient.Get(url, cancellationToken).ConfigureAwait(false)) using (var stream = await _httpClient.Get(url, cancellationToken).ConfigureAwait(false))
// { {
// using (var streamReader = new StreamReader(stream)) using (var streamReader = new StreamReader(stream))
// { {
// // Use XmlReader for best performance // Use XmlReader for best performance
// using (var reader = XmlReader.Create(streamReader)) using (var reader = XmlReader.Create(streamReader))
// { {
// reader.MoveToContent(); reader.MoveToContent();
// // Loop through each element // Loop through each element
// while (reader.Read()) while (reader.Read())
// { {
// if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
// { {
// switch (reader.Name) switch (reader.Name)
// { {
// case "device": case "device":
// using (var subtree = reader.ReadSubtree()) using (var subtree = reader.ReadSubtree())
// { {
// FillFromDeviceNode(result, subtree); FillFromDeviceNode(result, subtree);
// } }
// break; break;
// default: default:
// reader.Skip(); reader.Skip();
// break; break;
// } }
// } }
// } }
// } }
// } }
// } }
// if (string.IsNullOrWhiteSpace(result.Id)) if (string.IsNullOrWhiteSpace(result.Id))
// { {
// throw new NotImplementedException(); throw new NotImplementedException();
// } }
// // Device hasn't implemented an m3u list // Device hasn't implemented an m3u list
// if (string.IsNullOrWhiteSpace(result.M3UUrl)) if (string.IsNullOrWhiteSpace(result.M3UUrl))
// { {
// result.IsEnabled = false; result.IsEnabled = false;
// } }
// else if (!result.M3UUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) else if (!result.M3UUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase))
// { {
// var fullM3uUrl = url.Substring(0, url.LastIndexOf('/')); var fullM3uUrl = url.Substring(0, url.LastIndexOf('/'));
// result.M3UUrl = fullM3uUrl + "/" + result.M3UUrl.TrimStart('/'); result.M3UUrl = fullM3uUrl + "/" + result.M3UUrl.TrimStart('/');
// } }
// _logger.Debug("SAT device result: {0}", _json.SerializeToString(result)); _logger.Debug("SAT device result: {0}", _json.SerializeToString(result));
// return result; return result;
// } }
// private void FillFromDeviceNode(SatIpTunerHostInfo info, XmlReader reader) private void FillFromDeviceNode(SatIpTunerHostInfo info, XmlReader reader)
// { {
// reader.MoveToContent(); reader.MoveToContent();
// while (reader.Read()) while (reader.Read())
// { {
// if (reader.NodeType == XmlNodeType.Element) if (reader.NodeType == XmlNodeType.Element)
// { {
// switch (reader.LocalName) switch (reader.LocalName)
// { {
// case "UDN": case "UDN":
// { {
// info.Id = reader.ReadElementContentAsString(); info.Id = reader.ReadElementContentAsString();
// break; break;
// } }
// case "friendlyName": case "friendlyName":
// { {
// info.FriendlyName = reader.ReadElementContentAsString(); info.FriendlyName = reader.ReadElementContentAsString();
// break; break;
// } }
// case "satip:X_SATIPCAP": case "satip:X_SATIPCAP":
// case "X_SATIPCAP": case "X_SATIPCAP":
// { {
// // <satip:X_SATIPCAP xmlns:satip="urn:ses-com:satip">DVBS2-2</satip:X_SATIPCAP> // <satip:X_SATIPCAP xmlns:satip="urn:ses-com:satip">DVBS2-2</satip:X_SATIPCAP>
// var value = reader.ReadElementContentAsString() ?? string.Empty; var value = reader.ReadElementContentAsString() ?? string.Empty;
// var parts = value.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries); var parts = value.Split(new[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
// if (parts.Length == 2) if (parts.Length == 2)
// { {
// int intValue; int intValue;
// if (int.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out intValue)) if (int.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out intValue))
// { {
// info.TunersAvailable = intValue; info.TunersAvailable = intValue;
// } }
// if (int.TryParse(parts[0].Substring(parts[0].Length - 1), NumberStyles.Any, CultureInfo.InvariantCulture, out intValue)) if (int.TryParse(parts[0].Substring(parts[0].Length - 1), NumberStyles.Any, CultureInfo.InvariantCulture, out intValue))
// { {
// info.Tuners = intValue; info.Tuners = intValue;
// } }
// } }
// break; break;
// } }
// case "satip:X_SATIPM3U": case "satip:X_SATIPM3U":
// case "X_SATIPM3U": case "X_SATIPM3U":
// { {
// // <satip:X_SATIPM3U xmlns:satip="urn:ses-com:satip">/channellist.lua?select=m3u</satip:X_SATIPM3U> // <satip:X_SATIPM3U xmlns:satip="urn:ses-com:satip">/channellist.lua?select=m3u</satip:X_SATIPM3U>
// info.M3UUrl = reader.ReadElementContentAsString(); info.M3UUrl = reader.ReadElementContentAsString();
// break; break;
// } }
// default: default:
// reader.Skip(); reader.Skip();
// break; break;
// } }
// } }
// } }
// } }
//} }
public class SatIpTunerHostInfo : TunerHostInfo public class SatIpTunerHostInfo : TunerHostInfo
{ {

@ -19,153 +19,153 @@ using MediaBrowser.Model.Serialization;
namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp
{ {
//public class SatIpHost : BaseTunerHost, ITunerHost public class SatIpHost : BaseTunerHost, ITunerHost
//{ {
// private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
// private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
// public SatIpHost(IConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient) public SatIpHost(IConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder, IFileSystem fileSystem, IHttpClient httpClient)
// : base(config, logger, jsonSerializer, mediaEncoder) : base(config, logger, jsonSerializer, mediaEncoder)
// { {
// _fileSystem = fileSystem; _fileSystem = fileSystem;
// _httpClient = httpClient; _httpClient = httpClient;
// } }
// private const string ChannelIdPrefix = "sat_"; private const string ChannelIdPrefix = "sat_";
// protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken) protected override async Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken)
// { {
// var satInfo = (SatIpTunerHostInfo) tuner; var satInfo = (SatIpTunerHostInfo)tuner;
// return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false); return await new M3uParser(Logger, _fileSystem, _httpClient).Parse(satInfo.M3UUrl, ChannelIdPrefix, tuner.Id, cancellationToken).ConfigureAwait(false);
// } }
// public static string DeviceType public static string DeviceType
// { {
// get { return "satip"; } get { return "satip"; }
// } }
// public override string Type public override string Type
// { {
// get { return DeviceType; } get { return DeviceType; }
// } }
// protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) protected override async Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
// { {
// var urlHash = tuner.Url.GetMD5().ToString("N"); var urlHash = tuner.Url.GetMD5().ToString("N");
// var prefix = ChannelIdPrefix + urlHash; var prefix = ChannelIdPrefix + urlHash;
// if (!channelId.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) if (!channelId.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
// { {
// return null; return null;
// } }
// var channels = await GetChannels(tuner, true, cancellationToken).ConfigureAwait(false); var channels = await GetChannels(tuner, true, cancellationToken).ConfigureAwait(false);
// var m3uchannels = channels.Cast<M3UChannel>(); var m3uchannels = channels.Cast<M3UChannel>();
// var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); var channel = m3uchannels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase));
// if (channel != null) if (channel != null)
// { {
// var path = channel.Path; var path = channel.Path;
// MediaProtocol protocol = MediaProtocol.File; MediaProtocol protocol = MediaProtocol.File;
// if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase)) if (path.StartsWith("http", StringComparison.OrdinalIgnoreCase))
// { {
// protocol = MediaProtocol.Http; protocol = MediaProtocol.Http;
// } }
// else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase)) else if (path.StartsWith("rtmp", StringComparison.OrdinalIgnoreCase))
// { {
// protocol = MediaProtocol.Rtmp; protocol = MediaProtocol.Rtmp;
// } }
// else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase)) else if (path.StartsWith("rtsp", StringComparison.OrdinalIgnoreCase))
// { {
// protocol = MediaProtocol.Rtsp; protocol = MediaProtocol.Rtsp;
// } }
// var mediaSource = new MediaSourceInfo var mediaSource = new MediaSourceInfo
// { {
// Path = channel.Path, Path = channel.Path,
// Protocol = protocol, Protocol = protocol,
// MediaStreams = new List<MediaStream> MediaStreams = new List<MediaStream>
// { {
// new MediaStream new MediaStream
// { {
// Type = MediaStreamType.Video, Type = MediaStreamType.Video,
// // Set the index to -1 because we don't know the exact index of the video stream within the container // Set the index to -1 because we don't know the exact index of the video stream within the container
// Index = -1, Index = -1,
// IsInterlaced = true IsInterlaced = true
// }, },
// new MediaStream new MediaStream
// { {
// Type = MediaStreamType.Audio, Type = MediaStreamType.Audio,
// // Set the index to -1 because we don't know the exact index of the audio stream within the container // Set the index to -1 because we don't know the exact index of the audio stream within the container
// Index = -1 Index = -1
// } }
// }, },
// RequiresOpening = false, RequiresOpening = false,
// RequiresClosing = false RequiresClosing = false
// }; };
// return new List<MediaSourceInfo> { mediaSource }; return new List<MediaSourceInfo> { mediaSource };
// } }
// return new List<MediaSourceInfo> { }; return new List<MediaSourceInfo> { };
// } }
// protected override async Task<MediaSourceInfo> GetChannelStream(TunerHostInfo tuner, string channelId, string streamId, CancellationToken cancellationToken) protected override async Task<MediaSourceInfo> GetChannelStream(TunerHostInfo tuner, string channelId, string streamId, CancellationToken cancellationToken)
// { {
// var sources = await GetChannelStreamMediaSources(tuner, channelId, cancellationToken).ConfigureAwait(false); var sources = await GetChannelStreamMediaSources(tuner, channelId, cancellationToken).ConfigureAwait(false);
// return sources.First(); return sources.First();
// } }
// protected override async Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) protected override async Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
// { {
// var updatedInfo = await SatIpDiscovery.Current.GetInfo(tuner.Url, cancellationToken).ConfigureAwait(false); var updatedInfo = await SatIpDiscovery.Current.GetInfo(tuner.Url, cancellationToken).ConfigureAwait(false);
// return updatedInfo.TunersAvailable > 0; return updatedInfo.TunersAvailable > 0;
// } }
// protected override bool IsValidChannelId(string channelId) protected override bool IsValidChannelId(string channelId)
// { {
// return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase); return channelId.StartsWith(ChannelIdPrefix, StringComparison.OrdinalIgnoreCase);
// } }
// protected override List<TunerHostInfo> GetTunerHosts() protected override List<TunerHostInfo> GetTunerHosts()
// { {
// return SatIpDiscovery.Current.DiscoveredHosts; return SatIpDiscovery.Current.DiscoveredHosts;
// } }
// public string Name public string Name
// { {
// get { return "Sat IP"; } get { return "Sat IP"; }
// } }
// public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken) public Task<List<LiveTvTunerInfo>> GetTunerInfos(CancellationToken cancellationToken)
// { {
// var list = GetTunerHosts() var list = GetTunerHosts()
// .SelectMany(i => GetTunerInfos(i, cancellationToken)) .SelectMany(i => GetTunerInfos(i, cancellationToken))
// .ToList(); .ToList();
// return Task.FromResult(list); return Task.FromResult(list);
// } }
// public List<LiveTvTunerInfo> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken) public List<LiveTvTunerInfo> GetTunerInfos(TunerHostInfo info, CancellationToken cancellationToken)
// { {
// var satInfo = (SatIpTunerHostInfo) info; var satInfo = (SatIpTunerHostInfo)info;
// var list = new List<LiveTvTunerInfo>(); var list = new List<LiveTvTunerInfo>();
// for (var i = 0; i < satInfo.Tuners; i++) for (var i = 0; i < satInfo.Tuners; i++)
// { {
// list.Add(new LiveTvTunerInfo list.Add(new LiveTvTunerInfo
// { {
// Name = satInfo.FriendlyName ?? Name, Name = satInfo.FriendlyName ?? Name,
// SourceType = Type, SourceType = Type,
// Status = LiveTvTunerStatus.Available, Status = LiveTvTunerStatus.Available,
// Id = info.Url.GetMD5().ToString("N") + i.ToString(CultureInfo.InvariantCulture), Id = info.Url.GetMD5().ToString("N") + i.ToString(CultureInfo.InvariantCulture),
// Url = info.Url Url = info.Url
// }); });
// } }
// return list; return list;
// } }
//} }
} }

@ -143,6 +143,9 @@
<Content Include="dashboard-ui\devices\windowsphone\wp.css"> <Content Include="dashboard-ui\devices\windowsphone\wp.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\legacy\fnchecked.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\legacy\buttonenabled.js"> <Content Include="dashboard-ui\legacy\buttonenabled.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@ -281,9 +284,6 @@
<Content Include="dashboard-ui\robots.txt"> <Content Include="dashboard-ui\robots.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="dashboard-ui\scripts\globalize.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="dashboard-ui\scripts\homenextup.js"> <Content Include="dashboard-ui\scripts\homenextup.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

Loading…
Cancel
Save