2025-04-02, 10:35 AM
All in Visual Basic, I'm afraid... I'm such an amateur.
First, a few constants:
Next, Analyse the media file with Comskip and generate EDL file:
And finally, mark the media segments:
I'm still running this manually because I can't find a way of getting the ID of an item from the recording post processing command, but actually that's OK for me because only a few programmes that I record are on commercial TV. I'm happy with it for my purposes, no need for any muxing, converting, creating chapters, or deleting - it doesn't even touch the source file. If anyone is interested in taking the idea and making it into a plugin, that would be wonderful (not me, I don't have the skills or the patience), and it would be really cool if the Jellyfin geniuses could expand the native Media Segments API to allow creation and deletion and avoid the need to use the third party Media Segments API plugin.
And my wife is happy because she now gets a "Skip Ads" button when she watches her favourite soaps :-)
Many thanks to TheDreadPirate and esvee for pointing me in the right direction!
Austin
First, a few constants:
Code:
Const MyServer = "http://localhost:8096"
Const PathToComSkip = "C:\ComSegments\comskip\comskip.exe"
Const PathToComSkipINI = "C:\ComSegments\comskip\comskip.ini"
Const AuthToken = "MediaBrowser Token=""MyAPIToken"""
Const ProviderID = "Chapter Segments Provider"
Const ComskipEDLFile = "C:\ComSegments\working\tmp.edl"
Next, Analyse the media file with Comskip and generate EDL file:
Code:
Dim psi As ProcessStartInfo
Dim p As Process
psi = New ProcessStartInfo(PathToComSkip)
psi.ArgumentList.Add(FileToAnalyse)
psi.ArgumentList.Add("--ini=" & PathToComSkipINI)
p = Process.Start(psi)
p.WaitForExit()
And finally, mark the media segments:
Code:
Dim lines = File.ReadAllLines(ComskipEDLFile)
Dim LineParts() As String
For Each line In lines
LineParts = line.Split(vbTab)
ms = New MediaSegment
ms.Id = Guid.NewGuid
ms.ItemId = Guid.Parse(ItemId)
ms.Type = MediaSegmentType.Commercial
ms.StartTicks = LineParts(0) * 10000000
ms.EndTicks = LineParts(1) * 10000000
h = New StringContent(JsonConvert.SerializeObject(ms), Encoding.UTF8, "application/json")
Await Client.PostAsync(MyServer & "/MediaSegmentsApi/" & Guid.Parse(ItemId).ToString & "?providerId=" & ProviderID, h)
Next
I'm still running this manually because I can't find a way of getting the ID of an item from the recording post processing command, but actually that's OK for me because only a few programmes that I record are on commercial TV. I'm happy with it for my purposes, no need for any muxing, converting, creating chapters, or deleting - it doesn't even touch the source file. If anyone is interested in taking the idea and making it into a plugin, that would be wonderful (not me, I don't have the skills or the patience), and it would be really cool if the Jellyfin geniuses could expand the native Media Segments API to allow creation and deletion and avoid the need to use the third party Media Segments API plugin.
And my wife is happy because she now gets a "Skip Ads" button when she watches her favourite soaps :-)
Many thanks to TheDreadPirate and esvee for pointing me in the right direction!
Austin