better encoding

pull/702/head
Luke Pulverenti 12 years ago
parent e88eacab09
commit da5198298c

@ -277,11 +277,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
{
stream.Type = MediaStreamType.Subtitle;
}
else if (streamInfo.codec_type.Equals("data", StringComparison.OrdinalIgnoreCase))
{
stream.Type = MediaStreamType.Data;
}
else
else if (streamInfo.codec_type.Equals("video", StringComparison.OrdinalIgnoreCase))
{
stream.Type = MediaStreamType.Video;
@ -293,6 +289,10 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
stream.AverageFrameRate = GetFrameRate(streamInfo.avg_frame_rate);
stream.RealFrameRate = GetFrameRate(streamInfo.r_frame_rate);
}
else
{
return null;
}
// Get stream bitrate
if (stream.Type != MediaStreamType.Subtitle)

@ -51,7 +51,9 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
return;
}
audio.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList();
audio.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format))
.Where(i => i != null)
.ToList();
// Get the first audio stream
var stream = data.streams.First(s => s.codec_type.Equals("audio", StringComparison.OrdinalIgnoreCase));
@ -146,7 +148,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
/// </summary>
/// <param name="val">The val.</param>
/// <returns>System.String[][].</returns>
private string[] Split(string val)
private string[] Split(string val)
{
// Only use the comma as a delimeter if there are no slashes or pipes.
// We want to be careful not to split names that have commas in them
@ -168,7 +170,7 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
if (!string.IsNullOrEmpty(val))
{
var studios =
val.Split(new[] {'/', '|'}, StringSplitOptions.RemoveEmptyEntries)
val.Split(new[] { '/', '|' }, StringSplitOptions.RemoveEmptyEntries)
.Where(i => !string.Equals(i, audio.Artist, StringComparison.OrdinalIgnoreCase) && !string.Equals(i, audio.AlbumArtist, StringComparison.OrdinalIgnoreCase));
audio.Studios.Clear();

@ -213,7 +213,9 @@ namespace MediaBrowser.Controller.Providers.MediaInfo
if (data.streams != null)
{
video.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format)).ToList();
video.MediaStreams = data.streams.Select(s => GetMediaStream(s, data.format))
.Where(i => i != null)
.ToList();
}
if (data.Chapters != null)

@ -143,10 +143,6 @@ namespace MediaBrowser.Model.Entities
/// <summary>
/// The subtitle
/// </summary>
Subtitle,
/// <summary>
/// The data
/// </summary>
Data
Subtitle
}
}

@ -95,9 +95,11 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
return name;
}());
function encodeName(name) {
return encodeURIComponent(name).replace("'", '%27');
}
self.encodeName = function (name) {
var val = $.param({ name: name });
return val.substring(val.indexOf('=') + 1).replace("'", '%27');
};
/**
* Wraps around jQuery ajax methods to add additional info to the request.
@ -874,7 +876,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
options.userId = userId;
}
var url = self.getUrl("Studios/" + encodeName(name), options);
var url = self.getUrl("Studios/" + self.encodeName(name), options);
return self.ajax({
type: "GET",
@ -898,7 +900,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
options.userId = userId;
}
var url = self.getUrl("Genres/" + encodeName(name), options);
var url = self.getUrl("Genres/" + self.encodeName(name), options);
return self.ajax({
type: "GET",
@ -922,7 +924,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
options.userId = userId;
}
var url = self.getUrl("Artists/" + encodeName(name), options);
var url = self.getUrl("Artists/" + self.encodeName(name), options);
return self.ajax({
type: "GET",
@ -946,7 +948,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
options.userId = userId;
}
var url = self.getUrl("Years/" + encodeName(name), options);
var url = self.getUrl("Years/" + self.encodeName(name), options);
return self.ajax({
type: "GET",
@ -970,7 +972,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
options.userId = userId;
}
var url = self.getUrl("Persons/" + encodeName(name), options);
var url = self.getUrl("Persons/" + self.encodeName(name), options);
return self.ajax({
type: "GET",
@ -1096,7 +1098,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
var url = "Persons/" + encodeName(name) + "/Images/" + options.type;
var url = "Persons/" + self.encodeName(name) + "/Images/" + options.type;
if (options.index != null) {
url += "/" + options.index;
@ -1166,7 +1168,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
var url = "Genres/" + encodeName(name) + "/Images/" + options.type;
var url = "Genres/" + self.encodeName(name) + "/Images/" + options.type;
if (options.index != null) {
url += "/" + options.index;
@ -1201,7 +1203,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
var url = "Artists/" + encodeName(name) + "/Images/" + options.type;
var url = "Artists/" + self.encodeName(name) + "/Images/" + options.type;
if (options.index != null) {
url += "/" + options.index;
@ -1236,7 +1238,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
};
var url = "Studios/" + encodeName(name) + "/Images/" + options.type;
var url = "Studios/" + self.encodeName(name) + "/Images/" + options.type;
if (options.index != null) {
url += "/" + options.index;
@ -1880,7 +1882,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Favorites/Artists/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Favorites/Artists/" + self.encodeName(name));
var method = isFavorite ? "POST" : "DELETE";
@ -1900,7 +1902,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Favorites/Persons/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Favorites/Persons/" + self.encodeName(name));
var method = isFavorite ? "POST" : "DELETE";
@ -1920,7 +1922,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Favorites/Studios/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Favorites/Studios/" + self.encodeName(name));
var method = isFavorite ? "POST" : "DELETE";
@ -1940,7 +1942,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Favorites/Genres/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Favorites/Genres/" + self.encodeName(name));
var method = isFavorite ? "POST" : "DELETE";
@ -1966,7 +1968,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Artists/" + encodeName(name), {
var url = self.getUrl("Users/" + userId + "/Ratings/Artists/" + self.encodeName(name), {
likes: likes
});
@ -1986,7 +1988,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Persons/" + encodeName(name), {
var url = self.getUrl("Users/" + userId + "/Ratings/Persons/" + self.encodeName(name), {
likes: likes
});
@ -2006,7 +2008,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Studios/" + encodeName(name), {
var url = self.getUrl("Users/" + userId + "/Ratings/Studios/" + self.encodeName(name), {
likes: likes
});
@ -2026,7 +2028,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Genres/" + encodeName(name), {
var url = self.getUrl("Users/" + userId + "/Ratings/Genres/" + self.encodeName(name), {
likes: likes
});
@ -2051,7 +2053,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Artists/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Ratings/Artists/" + self.encodeName(name));
return self.ajax({
type: "DELETE",
@ -2069,7 +2071,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Persons/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Ratings/Persons/" + self.encodeName(name));
return self.ajax({
type: "DELETE",
@ -2087,7 +2089,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Studios/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Ratings/Studios/" + self.encodeName(name));
return self.ajax({
type: "DELETE",
@ -2105,7 +2107,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Users/" + userId + "/Ratings/Genres/" + encodeName(name));
var url = self.getUrl("Users/" + userId + "/Ratings/Genres/" + self.encodeName(name));
return self.ajax({
type: "DELETE",
@ -2126,7 +2128,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Persons/" + encodeName(name) + "/Counts", {
var url = self.getUrl("Persons/" + self.encodeName(name) + "/Counts", {
userId: userId
});
@ -2150,7 +2152,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Genres/" + encodeName(name) + "/Counts", {
var url = self.getUrl("Genres/" + self.encodeName(name) + "/Counts", {
userId: userId
});
@ -2174,7 +2176,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Artists/" + encodeName(name) + "/Counts", {
var url = self.getUrl("Artists/" + self.encodeName(name) + "/Counts", {
userId: userId
});
@ -2198,7 +2200,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
throw new Error("null name");
}
var url = self.getUrl("Studios/" + encodeName(name) + "/Counts", {
var url = self.getUrl("Studios/" + self.encodeName(name) + "/Counts", {
userId: userId
});

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.88" targetFramework="net45" />
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.91" targetFramework="net45" />
<package id="ServiceStack.Common" version="3.9.43" targetFramework="net45" />
<package id="ServiceStack.Text" version="3.9.43" targetFramework="net45" />
</packages>
Loading…
Cancel
Save