Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 MediaBrowser.Providers.Chapters ChapterManager.SaveChapters(string itemId, List<ChapterInfo> chapters)
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 1 minute ago, chef said: I can't find IChapterManager ChapterManager you will need to initiate it in your constructor and set the field
chef 3810 Posted September 8, 2021 Posted September 8, 2021 53 minutes ago, Cheesegeezer said: ChapterManager you will need to initiate it in your constructor and set the field I updated the Git. Oh boy... what is the namespace for that again {facepalm}
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 Just now, chef said: I updated the Git. Oh boy... what is the namespace for that again {facepalm} cheers let me have a look
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 11 minutes ago, Cheesegeezer said: cheers let me have a look It would appear that ChapterManager is no longer availabe from Mediabrowser.Model.Providers
chef 3810 Posted September 8, 2021 Posted September 8, 2021 1 hour ago, Cheesegeezer said: It would appear that ChapterManager is no longer availabe from Mediabrowser.Model.Providers Ah, that sucks. Life would have been much easier with that implemented. Maybe it changed names. It must be somewhere, because there is a scheduled task which handles chapters. Unless, it is possible that by changing the BaseItemDto object, it somehow magically updates and saves itself behind the scenes. Which would be a crazy thing, and probably no the case. I'm scared to run the chapter code on my test sample set because it is part of my production server. I think I had better create an actual separate sample set of episodes to test this. LOL! I'm not sure what will happen. LOL.
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 @chef I'm thinking we need to specify the chapterInfo and then "insert" the Index into the chapters ChapterInfo cInfo = null; if(titleSequence.TitleSequenceStart == TimeSpan.FromSeconds(0)) { cInfo.StartPositionTicks = 0; cInfo.Name = "Intro"; cInfo.StartPositionTicks = titleSequence.TitleSequenceEnd.Ticks; 1
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 1 minute ago, chef said: Ah, that sucks. Life would have been much easier with that implemented. Maybe it changed names. It must be somewhere, because there is a scheduled task which handles chapters. Unless, it is possible that by changing the BaseItemDto object, it somehow magically updates and saves itself behind the scenes. Which would be a crazy thing, and probably no the case. I'm scared to run the chapter code on my test sample set because it is part of my production server. I think I had better create an actual separate sample set of episodes to test this. LOL! I'm not sure what will happen. LOL. I can run it on my laptop lol
rbjtech 5284 Posted September 8, 2021 Posted September 8, 2021 1 minute ago, chef said: Ah, that sucks. Life would have been much easier with that implemented. Maybe it changed names. It must be somewhere, because there is a scheduled task which handles chapters. Unless, it is possible that by changing the BaseItemDto object, it somehow magically updates and saves itself behind the scenes. Which would be a crazy thing, and probably no the case. I'm scared to run the chapter code on my test sample set because it is part of my production server. I think I had better create an actual separate sample set of episodes to test this. LOL! I'm not sure what will happen. LOL. It's only changing the chapterdB though right ? If it screws it up, then just refresh the metadata and it will re-read the chapters from the original file no ?
chef 3810 Posted September 8, 2021 Posted September 8, 2021 Just now, rbjtech said: It's only changing the chapterdB though right ? If it screws it up, then just refresh the metadata and it will re-read the chapters from the original file no ? I think so. I think the API is doing that... But, I'm unsure. So I will test it out and see what it does. It's probably best to know for certain what the Api is doing anyway, for future projects. 1
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 10 minutes ago, chef said: I think so. I think the API is doing that... But, I'm unsure. So I will test it out and see what it does. It's probably best to know for certain what the Api is doing anyway, for future projects. I've altered the ChapterManager Code to just use the Mediabrowser.Model.Entities.ChapterInfo set the start time ticks and name and also insert at chapter 1 position. Question Chef, Did you add the code to run ChapterManager and on what task is it run. At the end of Sequence detection. I'm just trying it now, but didn't check that bit lol 1
chef 3810 Posted September 8, 2021 Posted September 8, 2021 Ha! I'm back. Okay, No, saving the BaseItem which was used to edit the BaseItemDto does not save the Dto information. This is what I thought, but now we are sure that it doesn't. Currently I'm not sure how to update the Dto item.
chef 3810 Posted September 8, 2021 Posted September 8, 2021 (edited) 1 hour ago, Cheesegeezer said: I've altered the ChapterManager Code to just use the Mediabrowser.Model.Entities.ChapterInfo set the start time ticks and name and also insert at chapter 1 position. Question Chef, Did you add the code to run ChapterManager and on what task is it run. At the end of Sequence detection. I'm just trying it now, but didn't check that bit lol No, I'll update the Github with a test Scheduled task. You'd have to change the InternalId to something that is in your test library set. You'll see it in the test Chapter schedule task. If I made no sense there, let me know. It's been committed. Edited September 8, 2021 by chef
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 Sorry i'm just on a call with a guy at work gimme some time
chef 3810 Posted September 8, 2021 Posted September 8, 2021 (edited) I suppose if the ItemUpdateService can be accessed from the frontend, then perhaps we try doing this another way. Instead of the backend handling it, could we send the sequence data to the ItemUpdateService from the UI? Edited September 8, 2021 by chef
chef 3810 Posted September 8, 2021 Posted September 8, 2021 I've done it Now we save it back using the ItemUpdateService. 2
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 This is some code from a MBChapter plugin i wrote a few years ago, but the chapterdb.org was never updated and went stale. But this is how I would have saved it in the old Mediabrowser code days. It may help us public async Task GetChapterInfo(Video video, CancellationToken cancellationToken) { if (!CheckPreviouslyDownloaded(video)) { var defaultVideoStream = video.GetDefaultVideoStream(); var results = await new ChapterDBSearcher(_logger).Search(video, defaultVideoStream, cancellationToken).ConfigureAwait(false); //Check the number of items in the list. Lets make sure we have a decent list so lets make it need to have more than 5 chapters if (results.Count > 5) { var chapters = new List<MediaBrowser.Model.Entities.ChapterInfo>(); foreach (var chapterEntry in results) { chapters.Add(new MediaBrowser.Model.Entities.ChapterInfo { Name = chapterEntry.Name, StartPositionTicks = chapterEntry.Time.Ticks, }); await _itemrepositry.SaveChapters(video.Id, chapters, cancellationToken).ConfigureAwait(false); } _logger.Info("MBCHAPTERS SAVED info for {0}", video.Name.ToUpper()); AddToDownloaded(video); Plugin.Instance.SaveConfiguration(); } if (results.Count == 0) { _logger.Info("MB CHAPTERS - NO Chapter Info found for {0}", video.Name.ToUpper()); } } else { _logger.Info(Plugin.Instance.Name + " - {0} in filter list so will not be downloaded", video.Name); } }
crusher11 1101 Posted September 8, 2021 Posted September 8, 2021 (edited) Most apps don't have a 'skip chapter' button, do they? So you'd have to bring up the chapters, navigate to the next one, and play it. I'm not sure that's an upgrade in convenience. Especially when you consider a number of shows will already have an end-of-intro chapter point, assuming they're sourced from DVD or Blu-ray rather than being recordings or pirated. If there's a way of having it flag when there's a chapter point within a certain tolerance of the detected end-of-intro, I could run it on my library (assuming it'll run on a Synology NAS?) and see how common that is, seeing as I do have a large number of chaptered TV shows. Edited September 8, 2021 by crusher11
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 2 minutes ago, crusher11 said: Most apps don't have a 'skip chapter' button, do they? So you'd have to bring up the chapters, navigate to the next one, and play it. I'm not sure that's an upgrade in convenience. Especially when you consider a number of shows will already have an end-of-intro chapter point, assuming they're sourced from DVD or Blu-ray rather than being recordings or pirated. If there's a way of having it flag when there's a chapter point within a certain tolerance of the detected end-of-intro, I could run it on my library (assuming it'll run on a Synology NAS?) and see how common that is, seeing as I do have a large number of chaptered TV shows. It's something that could be added 1
rbjtech 5284 Posted September 8, 2021 Posted September 8, 2021 (edited) 15 minutes ago, crusher11 said: Most apps don't have a 'skip chapter' button, do they? So you'd have to bring up the chapters, navigate to the next one, and play it. I'm not sure that's an upgrade in convenience. Especially when you consider a number of shows will already have an end-of-intro chapter point, assuming they're sourced from DVD or Blu-ray rather than being recordings or pirated. If there's a way of having it flag when there's a chapter point within a certain tolerance of the detected end-of-intro, I could run it on my library (assuming it'll run on a Synology NAS?) and see how common that is, seeing as I do have a large number of chaptered TV shows. The release version of emby doesn't even support chapters - yet alone Intro ! Small steps - we can assist the Core Dev team and try and influence what they deliver - but at the end of the day, it's taken a number of years to get 'chapter' support in the UI - something which is in most media players from the outset as a basic function. Will they add 'Skip Intro' any time soon ? Your guess is as good as mine. Edited September 8, 2021 by rbjtech
chef 3810 Posted September 8, 2021 Posted September 8, 2021 (edited) 1 hour ago, crusher11 said: Most apps don't have a 'skip chapter' button, do they? So you'd have to bring up the chapters, navigate to the next one, and play it. I'm not sure that's an upgrade in convenience. Especially when you consider a number of shows will already have an end-of-intro chapter point, assuming they're sourced from DVD or Blu-ray rather than being recordings or pirated. If there's a way of having it flag when there's a chapter point within a certain tolerance of the detected end-of-intro, I could run it on my library (assuming it'll run on a Synology NAS?) and see how common that is, seeing as I do have a large number of chaptered TV shows. Perhaps. What we'd like to see is the clients implement the button. I'm not as keen on the chapter idea, as I am about having the client skip to the timestamp provided by the plugin. There are the following endpoints currently available in the API: TitleSequenceStart, TitleSequenceEnd, HasSequence This is so the client can request that data with the BaseItem while setting up the stream. The client can look for HasSequence, if its true, show the button at the TitleSequenceStart timestamp using the PlaybackProgressEventArgs, Then skip the stream to TitleSequenceEnd, if the button is pressed. But, for now, we can allow the user to edit their chapters if they want, even though overall a button would be preferred. Yes, it will run on Synology. That device was one of the first test machine. It just takes a while to get all the info. Edited September 8, 2021 by chef 1
crusher11 1101 Posted September 8, 2021 Posted September 8, 2021 1 minute ago, chef said: Yes, it will run on Synology. That device was one of the first test machine. It just takes a while to get all the info. So a) how do I get it? and b) is there anything in there to check for an already-existing end-of-intro chapter? I'm curious to see what percentage of shows already have that in place.
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 46 minutes ago, chef said: I've done it Now we save it back using the ItemUpdateService. It's all in the ItemRepo. Create a field, Initialise it and then use the GetChapters() to get the list, insert the intro and then SaveChapters() with the new intro added private ILibraryManager LibraryManager {get; set;} private IDtoService DtoService { get; set; } public static ChapterManager Instance {get; set; } private IItemRepository _ItemRepository; private ILogger _logger; public ChapterManager(ILibraryManager libraryManager, IDtoService dtoService, ILogger logger, IItemRepository ItemRepo) { LibraryManager = libraryManager; DtoService = dtoService; _logger = logger; _ItemRepository = ItemRepo; Instance = this; } public void EditChapters(long id) { var item = LibraryManager.GetItemById(id); var itemDto = DtoService.GetBaseItemDto(item, new DtoOptions() { Fields = new ItemFields[] { ItemFields.Chapters } }); List<ChapterInfo> getChapters = _ItemRepository.GetChapters(item); List<ChapterInfo> chapters = new List<ChapterInfo>(); //Lets get the existing chapters and put them in a new list so we can insert the new Intro Chapter foreach(var chap in getChapters) { chapters.Add(new ChapterInfo { Name = chap.Name, StartPositionTicks = chap.StartPositionTicks, }); } if (titleSequence.TitleSequenceStart == TimeSpan.FromSeconds(0)) { //do all the required logic to create a new point and insert to index point 1 in the chapters list, then save the new list _ItemRepository.SaveChapters(id, chapters) } 1
Cheesegeezer 3104 Posted September 8, 2021 Posted September 8, 2021 2 minutes ago, crusher11 said: So a) how do I get it? and b) is there anything in there to check for an already-existing end-of-intro chapter? I'm curious to see what percentage of shows already have that in place. crusher just wait, we are still testing and playing at the minute. All you would get currently is a list of intro points that can only be viewed in the config page. You can't do anything with them right now. go back and read thru the thread to get an understanding, you would also have load the beta version so that the chromaprint can be executed....
chef 3810 Posted September 8, 2021 Posted September 8, 2021 (edited) 7 minutes ago, crusher11 said: So a) how do I get it? and b) is there anything in there to check for an already-existing end-of-intro chapter? I'm curious to see what percentage of shows already have that in place. I'll put up a dll here.. in a moment. Don't worry about chapters, this has nothing to do with chapters . What we do is encode the first fifteen minutes of audio from two different episodes from the same season. Once the encoding is done, we use chromaprints (byte arrays of the audio), then we slide the encodings over each other, and where they line up (where they are the same) this is the intro for each episode. We then grab the time stamps of where they lined up both at the beginning and the end. This tells us where it starts in the stream and where it ends. Cool eh? Edited September 8, 2021 by chef
Recommended Posts