diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-06-03 23:34:36 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-06-03 23:34:36 -0400 |
| commit | 3640f620863e4947a07ad6ebbf54ab6427534b38 (patch) | |
| tree | 2b9c58f6e0ea069f282e46cbf081b38229bacb94 /MediaBrowser.Server.Implementations | |
| parent | 71351344d7f5a9057fe19b754f5d14d917e79d60 (diff) | |
create collections from movies page
Diffstat (limited to 'MediaBrowser.Server.Implementations')
4 files changed, 92 insertions, 10 deletions
diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 227e7bdfc..6ba2ac950 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -674,14 +674,19 @@ namespace MediaBrowser.Server.Implementations.Library { var folder = child.GetFolder(); - if (folder.Id == Guid.Empty) + if (folder != null) { - folder.Id = (folder.Path ?? folder.GetType().Name).GetMBId(folder.GetType()); - } + if (folder.Id == Guid.Empty) + { + folder.Id = (folder.Path ?? folder.GetType().Name).GetMBId(folder.GetType()); + } - rootFolder.AddVirtualChild(folder); + folder = GetItemById(folder.Id) as BasePluginFolder ?? folder; - RegisterItem(folder); + rootFolder.AddVirtualChild(folder); + + RegisterItem(folder); + } } return rootFolder; diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index cf827d26d..330fca082 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -115,7 +115,8 @@ "HeaderSplitMedia": "Split Media Apart", "MessageConfirmSplitMedia": "Are you sure you wish to split the media sources into separate items?", "HeaderError": "Error", - "MessagePleaseSelectItemsToGroup": "Please select two or more items to group together.", + "MessagePleaseSelectOneItem": "Please select at least one item.", + "MessagePleaseSelectTwoItems": "Please select at least two items.", "MessageTheFollowingItemsWillBeGrouped": "The following titles will be grouped into one item:", "MessageConfirmItemGrouping": "Media Browser clients will automatically choose the optimal version to play based on device and network performance. Are you sure you wish to continue?", "HeaderResume": "Resume", @@ -138,5 +139,6 @@ "HeaderSelectImagesByNamePathHelp": "Browse or enter the path to your items by name folder. The folder must be writeable.", "HeaderSelectMetadataPathHelp": "Browse or enter the path you'd like to store metadata within. The folder must be writeable.", "HeaderSelectChannelDownloadPath": "Select Channel Download Path", - "HeaderSelectChannelDownloadPathHelp": "Browse or enter the path to use for storing channel cache files. The folder must be writeable." + "HeaderSelectChannelDownloadPathHelp": "Browse or enter the path to use for storing channel cache files. The folder must be writeable.", + "OptionNewCollection": "New..." }
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index b2ebcdb9f..465896eb9 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -234,6 +234,7 @@ "ButtonSelect": "Select", "ButtonSearch": "Search", "ButtonGroupVersions": "Group Versions", + "ButtonAddToCollection": "Add to Collection", "PismoMessage": "Utilizing Pismo File Mount through a donated license.", "TangibleSoftwareMessage": "Utilizing Tangible Solutions Java/C# converters through a donated license.", "HeaderCredits": "Credits", @@ -452,6 +453,8 @@ "LabelPreferredDisplayLanguageHelp": "Translating Media Browser is an ongoing project and is not yet complete.", "LabelReadHowYouCanContribute": "Read about how you can contribute.", "HeaderNewCollection": "New Collection", + "HeaderAddToCollection": "Add to Collection", + "ButtonSubmit": "Submit", "NewCollectionNameExample": "Example: Star Wars Collection", "OptionSearchForInternetMetadata": "Search the internet for artwork and metadata", "ButtonCreate": "Create", @@ -807,5 +810,6 @@ "LabelChannelDownloadPathHelp": "Specify a custom download path if desired. Leave empty to download to an internal program data folder.", "LabelChannelDownloadAge": "Delete content after: (days)", "LabelChannelDownloadAgeHelp": "Downloaded content older than this will be deleted. It will remain playable via internet streaming.", - "ChannelSettingsFormHelp": "Install channels such as Trailers and Vimeo in the plugin catalog." + "ChannelSettingsFormHelp": "Install channels such as Trailers and Vimeo in the plugin catalog.", + "LabelSelectCollection": "Select collection:" }
\ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index ec3e636ae..cbf14076b 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.Events; +using System.IO; +using MediaBrowser.Common.Events; using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller; @@ -142,6 +143,16 @@ namespace MediaBrowser.Server.Implementations.Session SessionInfo = info }, _logger); + + if (!string.IsNullOrWhiteSpace(info.DeviceId)) + { + var capabilities = GetSavedCapabilities(info.DeviceId); + + if (capabilities != null) + { + ReportCapabilities(info, capabilities, false); + } + } } private async void OnSessionEnded(SessionInfo info) @@ -237,7 +248,7 @@ namespace MediaBrowser.Server.Implementations.Session { return session; } - + // Save this directly. No need to fire off all the events for this. await _userRepository.SaveUser(user, CancellationToken.None).ConfigureAwait(false); @@ -1148,6 +1159,13 @@ namespace MediaBrowser.Server.Implementations.Session { var session = GetSession(sessionId); + ReportCapabilities(session, capabilities, true); + } + + private async void ReportCapabilities(SessionInfo session, + SessionCapabilities capabilities, + bool saveCapabilities) + { session.PlayableMediaTypes = capabilities.PlayableMediaTypes; session.SupportedCommands = capabilities.SupportedCommands; @@ -1168,6 +1186,59 @@ namespace MediaBrowser.Server.Implementations.Session SessionInfo = session }, _logger); + + if (saveCapabilities) + { + await SaveCapabilities(session.DeviceId, capabilities).ConfigureAwait(false); + } + } + + private string GetCapabilitiesFilePath(string deviceId) + { + var filename = deviceId.GetMD5().ToString("N") + ".json"; + + return Path.Combine(_configurationManager.ApplicationPaths.CachePath, "devices", filename); + } + + private SessionCapabilities GetSavedCapabilities(string deviceId) + { + var path = GetCapabilitiesFilePath(deviceId); + + try + { + return _jsonSerializer.DeserializeFromFile<SessionCapabilities>(path); + } + catch (DirectoryNotFoundException) + { + return null; + } + catch (FileNotFoundException) + { + return null; + } + catch (Exception ex) + { + _logger.ErrorException("Error getting saved capabilities", ex); + return null; + } + } + + private readonly SemaphoreSlim _capabilitiesLock = new SemaphoreSlim(1, 1); + private async Task SaveCapabilities(string deviceId, SessionCapabilities capabilities) + { + var path = GetCapabilitiesFilePath(deviceId); + Directory.CreateDirectory(Path.GetDirectoryName(path)); + + await _capabilitiesLock.WaitAsync().ConfigureAwait(false); + + try + { + _jsonSerializer.SerializeToFile(capabilities, path); + } + finally + { + _capabilitiesLock.Release(); + } } public SessionInfoDto GetSessionInfoDto(SessionInfo session) |
