mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-24 19:16:32 +00:00
begin work on daily episodes
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
@@ -789,7 +790,7 @@ namespace MediaBrowser.Server.Implementations.Connect
|
||||
if (user == null)
|
||||
{
|
||||
// Add user
|
||||
user = await _userManager.CreateUser(connectEntry.UserName).ConfigureAwait(false);
|
||||
user = await _userManager.CreateUser(_userManager.MakeValidUsername(connectEntry.UserName)).ConfigureAwait(false);
|
||||
|
||||
user.ConnectUserName = connectEntry.UserName;
|
||||
user.ConnectUserId = connectEntry.UserId;
|
||||
|
||||
@@ -78,6 +78,11 @@ namespace MediaBrowser.Server.Implementations.Drawing
|
||||
// No biggie
|
||||
sizeDictionary = new Dictionary<Guid, ImageSize>();
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
// No biggie
|
||||
sizeDictionary = new Dictionary<Guid, ImageSize>();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.ErrorException("Error parsing image size cache file", ex);
|
||||
|
||||
@@ -459,11 +459,11 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
|
||||
private bool IsSameEpisode(string sourcePath, string newPath)
|
||||
{
|
||||
var sourceFileInfo = new FileInfo(sourcePath);
|
||||
var destinationFileInfo = new FileInfo(newPath);
|
||||
|
||||
try
|
||||
{
|
||||
var sourceFileInfo = new FileInfo(sourcePath);
|
||||
var destinationFileInfo = new FileInfo(newPath);
|
||||
|
||||
if (sourceFileInfo.Length == destinationFileInfo.Length)
|
||||
{
|
||||
return true;
|
||||
@@ -473,6 +473,10 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||
{
|
||||
return false;
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -419,7 +419,7 @@
|
||||
"HeaderMediaLocations": "Media Locations",
|
||||
"LabelFolderTypeValue": "Folder type: {0}",
|
||||
"LabelPathSubstitutionHelp": "Optional: Path substitution can map server paths to network shares that clients can access for direct playback.",
|
||||
"FolderTypeMixed": "Mixed videos",
|
||||
"FolderTypeMixed": "Mixed content",
|
||||
"FolderTypeMovies": "Movies",
|
||||
"FolderTypeMusic": "Music",
|
||||
"FolderTypeAdultVideos": "Adult videos",
|
||||
@@ -658,5 +658,5 @@
|
||||
"LabelItemLimitHelp": "Optional. Set a limit to the number of items that will be synced.",
|
||||
"MessageBookPluginRequired": "Requires installation of the Bookshelf plugin",
|
||||
"MessageGamePluginRequired": "Requires installation of the GameBrowser plugin",
|
||||
"MessageMixedContentHelp": "Content will be displayed with as a plain folder structure"
|
||||
"MessageMixedContentHelp": "Content will be displayed as a plain folder structure"
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"ButtonOk": "Ok",
|
||||
"ButtonCancel": "Cancel",
|
||||
"ButtonNew": "New",
|
||||
"FolderTypeMixed": "Mixed videos",
|
||||
"FolderTypeMixed": "Mixed content",
|
||||
"FolderTypeMovies": "Movies",
|
||||
"FolderTypeMusic": "Music",
|
||||
"FolderTypeAdultVideos": "Adult videos",
|
||||
@@ -48,7 +48,7 @@
|
||||
"FolderTypeBooks": "Books",
|
||||
"FolderTypeTvShows": "TV",
|
||||
"FolderTypeInherit": "Inherit",
|
||||
"LabelContentType": "Content type:",
|
||||
"LabelContentType": "Content type:",
|
||||
"HeaderSetupLibrary": "Setup your media library",
|
||||
"ButtonAddMediaFolder": "Add media folder",
|
||||
"LabelFolderType": "Folder type:",
|
||||
@@ -1307,5 +1307,8 @@
|
||||
"LabelEnableSingleImageInDidlLimitHelp": "Some devices will not render properly if multiple images are embedded within Didl.",
|
||||
"TabActivity": "Activity",
|
||||
"TitleSync": "Sync",
|
||||
"OptionAllowSyncContent": "Allow syncing media to devices"
|
||||
"OptionAllowSyncContent": "Allow syncing media to devices",
|
||||
"NameSeasonUnknown": "Season Unknown",
|
||||
"NameSeasonNumber": "Season {0}",
|
||||
"LabelNewUserNameHelp": "Usernames can contain letters (a-z), numbers (0-9), dashes (-), underscores (_), apostrophes ('), and periods (.)"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,14 @@ namespace MediaBrowser.Server.Implementations.News
|
||||
{
|
||||
return GetProductNewsInternal(query);
|
||||
}
|
||||
catch (DirectoryNotFoundException)
|
||||
{
|
||||
// No biggie
|
||||
return new QueryResult<NewsItem>
|
||||
{
|
||||
Items = new NewsItem[] { }
|
||||
};
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
// No biggie
|
||||
|
||||
Reference in New Issue
Block a user