mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-02 05:48:47 +01:00
begin work on daily episodes
This commit is contained in:
@@ -1755,9 +1755,12 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
var resolver = new EpisodeResolver(new ExtendedNamingOptions(),
|
||||
new Naming.Logging.NullLogger());
|
||||
|
||||
var fileType = episode.VideoType == VideoType.BluRay || episode.VideoType == VideoType.Dvd || episode.VideoType == VideoType.HdDvd ?
|
||||
FileInfoType.Directory :
|
||||
FileInfoType.File;
|
||||
|
||||
var locationType = episode.LocationType;
|
||||
|
||||
var fileType = /*args.IsDirectory ? FileInfoType.Directory :*/ FileInfoType.File;
|
||||
var episodeInfo = locationType == LocationType.FileSystem || locationType == LocationType.Offline ?
|
||||
resolver.Resolve(episode.Path, fileType) :
|
||||
new Naming.TV.EpisodeInfo();
|
||||
@@ -1769,29 +1772,42 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
var changed = false;
|
||||
|
||||
if (!episode.IndexNumber.HasValue)
|
||||
if (episodeInfo.IsByDate)
|
||||
{
|
||||
episode.IndexNumber = episodeInfo.EpisodeNumber;
|
||||
|
||||
if (episode.IndexNumber.HasValue)
|
||||
{
|
||||
episode.IndexNumber = null;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!episode.IndexNumberEnd.HasValue)
|
||||
{
|
||||
episode.IndexNumberEnd = episodeInfo.EndingEpsiodeNumber;
|
||||
|
||||
if (episode.IndexNumberEnd.HasValue)
|
||||
{
|
||||
episode.IndexNumberEnd = null;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
episode.ParentIndexNumber = episodeInfo.SeasonNumber;
|
||||
if (!episode.PremiereDate.HasValue)
|
||||
{
|
||||
if (episodeInfo.Year.HasValue && episodeInfo.Month.HasValue && episodeInfo.Day.HasValue)
|
||||
{
|
||||
episode.PremiereDate = new DateTime(episodeInfo.Year.Value, episodeInfo.Month.Value, episodeInfo.Day.Value).ToUniversalTime();
|
||||
}
|
||||
|
||||
if (episode.PremiereDate.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!episode.ProductionYear.HasValue)
|
||||
{
|
||||
episode.ProductionYear = episodeInfo.Year;
|
||||
|
||||
if (episode.ProductionYear.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
@@ -1801,11 +1817,53 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
{
|
||||
episode.ParentIndexNumber = season.IndexNumber;
|
||||
}
|
||||
|
||||
if (episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!episode.IndexNumber.HasValue)
|
||||
{
|
||||
episode.IndexNumber = episodeInfo.EpisodeNumber;
|
||||
|
||||
if (episode.IndexNumber.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (episode.ParentIndexNumber.HasValue)
|
||||
if (!episode.IndexNumberEnd.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
episode.IndexNumberEnd = episodeInfo.EndingEpsiodeNumber;
|
||||
|
||||
if (episode.IndexNumberEnd.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
episode.ParentIndexNumber = episodeInfo.SeasonNumber;
|
||||
|
||||
if (!episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
var season = episode.Season;
|
||||
|
||||
if (season != null)
|
||||
{
|
||||
episode.ParentIndexNumber = season.IndexNumber;
|
||||
}
|
||||
}
|
||||
|
||||
if (episode.ParentIndexNumber.HasValue)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Naming.Common;
|
||||
using MediaBrowser.Naming.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV
|
||||
|
||||
@@ -171,6 +171,38 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return AuthenticateUser(username, passwordSha1, null, remoteEndPoint);
|
||||
}
|
||||
|
||||
public bool IsValidUsername(string username)
|
||||
{
|
||||
// Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
|
||||
return username.All(IsValidCharacter);
|
||||
}
|
||||
|
||||
private bool IsValidCharacter(char i)
|
||||
{
|
||||
return char.IsLetterOrDigit(i) || char.Equals(i, '-') || char.Equals(i, '_') || char.Equals(i, '\'') ||
|
||||
char.Equals(i, '.');
|
||||
}
|
||||
|
||||
public string MakeValidUsername(string username)
|
||||
{
|
||||
if (IsValidUsername(username))
|
||||
{
|
||||
return username;
|
||||
}
|
||||
|
||||
// Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)
|
||||
var builder = new StringBuilder();
|
||||
|
||||
foreach (var c in username)
|
||||
{
|
||||
if (IsValidCharacter(c))
|
||||
{
|
||||
builder.Append(c);
|
||||
}
|
||||
}
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
public async Task<bool> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(username))
|
||||
@@ -178,7 +210,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
throw new ArgumentNullException("username");
|
||||
}
|
||||
|
||||
var user = Users.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||
var user = Users
|
||||
.FirstOrDefault(i => string.Equals(username, i.Name, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (user == null)
|
||||
{
|
||||
@@ -203,20 +236,6 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
}
|
||||
}
|
||||
|
||||
// Maybe user accidently entered connect credentials. let's be flexible
|
||||
if (!success && user.ConnectLinkType.HasValue && !string.IsNullOrWhiteSpace(passwordMd5))
|
||||
{
|
||||
try
|
||||
{
|
||||
await _connectFactory().Authenticate(user.ConnectUserName, passwordMd5).ConfigureAwait(false);
|
||||
success = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update LastActivityDate and LastLoginDate, then save
|
||||
if (success)
|
||||
{
|
||||
@@ -273,7 +292,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
// There always has to be at least one user.
|
||||
if (users.Count == 0)
|
||||
{
|
||||
var name = Environment.UserName;
|
||||
var name = MakeValidUsername(Environment.UserName);
|
||||
|
||||
var user = InstantiateNewUser(name, false);
|
||||
|
||||
@@ -477,6 +496,11 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
|
||||
if (!IsValidUsername(name))
|
||||
{
|
||||
throw new ArgumentException("Only alphanumeric characters are allowed.");
|
||||
}
|
||||
|
||||
if (Users.Any(u => u.Name.Equals(name, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
throw new ArgumentException(string.Format("A user with the name '{0}' already exists.", name));
|
||||
@@ -803,6 +827,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return (UserPolicy)_xmlSerializer.DeserializeFromFile(typeof(UserPolicy), path);
|
||||
}
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return GetDefaultPolicy(user);
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return GetDefaultPolicy(user);
|
||||
@@ -840,6 +868,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
var path = GetPolifyFilePath(user);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
lock (_policySyncLock)
|
||||
{
|
||||
_xmlSerializer.SerializeToFile(userPolicy, path);
|
||||
@@ -900,6 +930,10 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
return (UserConfiguration)_xmlSerializer.DeserializeFromFile(typeof(UserConfiguration), path);
|
||||
}
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return new UserConfiguration();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
return new UserConfiguration();
|
||||
@@ -930,6 +964,8 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
config = _jsonSerializer.DeserializeFromString<UserConfiguration>(json);
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
|
||||
lock (_configSyncLock)
|
||||
{
|
||||
_xmlSerializer.SerializeToFile(config, path);
|
||||
|
||||
Reference in New Issue
Block a user