11using Jellyfin . Data . Entities ;
22using Jellyfin . Data . Enums ;
33using MediaBrowser . Common . Configuration ;
4+ using MediaBrowser . Common . Plugins ;
45using MediaBrowser . Controller . Entities ;
56using MediaBrowser . Controller . Library ;
67using MediaBrowser . Controller . MediaEncoding ;
@@ -14,7 +15,7 @@ namespace Jellyfin.Plugin.DoViRemux;
1415public class RemuxLibraryTask ( IItemRepository _itemRepo ,
1516 IMediaSourceManager _sourceManager ,
1617 ITranscodeManager _transcodeManager ,
17- PluginConfiguration _configuration ,
18+ IPluginManager _pluginManager ,
1819 ILogger < RemuxLibraryTask > _logger ,
1920 IApplicationPaths _paths ,
2021 ILibraryManager _libraryManager ,
@@ -35,15 +36,18 @@ public class RemuxLibraryTask(IItemRepository _itemRepo,
3536
3637 public async Task ExecuteAsync ( IProgress < double > progress , CancellationToken cancellationToken )
3738 {
38- var primaryUser = _configuration . PrimaryUser is not null
39- ? _userManager . GetUserByName ( _configuration . PrimaryUser )
40- ?? throw new Exception ( $ "Primary user '{ _configuration . PrimaryUser } ' does not exist")
39+ var configuration = ( _pluginManager . GetPlugin ( Plugin . OurGuid ) ? . Instance as Plugin ) ? . Configuration
40+ ?? throw new Exception ( "Can't get plugin configuration" ) ;
41+
42+ var primaryUser = configuration . PrimaryUser is not null
43+ ? _userManager . GetUserByName ( configuration . PrimaryUser )
44+ ?? throw new Exception ( $ "Primary user '{ configuration . PrimaryUser } ' does not exist")
4145 : null ;
4246
4347 var itemsToProcess = _itemRepo . GetItems ( new InternalItemsQuery
4448 {
4549 MediaTypes = [ MediaType . Video ] ,
46- AncestorIds = _configuration . IncludeAncestors
50+ AncestorIds = configuration . IncludeAncestors
4751 } )
4852 . Items
4953 . Cast < Video > ( ) // has some additional properties (that I don't remember if we use or not)
@@ -57,7 +61,7 @@ public async Task ExecuteAsync(IProgress<double> progress, CancellationToken can
5761
5862 try
5963 {
60- await ProcessOneItem ( item , cancellationToken ) ;
64+ await ProcessOneItem ( item , cancellationToken , configuration ) ;
6165 }
6266 catch ( Exception x )
6367 {
@@ -107,7 +111,7 @@ private bool ShouldProcessItem(Video item, User? primaryUser)
107111 return true ;
108112 }
109113
110- private async Task ProcessOneItem ( Video item , CancellationToken cancellationToken )
114+ private async Task ProcessOneItem ( Video item , CancellationToken cancellationToken , PluginConfiguration configuration )
111115 {
112116 var streams = _sourceManager . GetMediaStreams ( item . Id ) ;
113117 var otherSources = item . GetMediaSources ( true ) ;
@@ -138,7 +142,7 @@ private async Task ProcessOneItem(Video item, CancellationToken cancellationToke
138142 // This will be presented as a second input to FFmpeg, and it will copy that
139143 // converted video stream instead of our original MKV's.
140144 string ? downmuxedVideoPath = null ;
141- if ( streams . Any ( s => s . DvProfile == 7 && s . DvLevel == 6 ) && _configuration . DownmuxProfile7 )
145+ if ( streams . Any ( s => s . DvProfile == 7 && s . DvLevel == 6 ) && configuration . DownmuxProfile7 )
142146 {
143147 _logger . LogInformation ( "Downmuxing {Id} {Name} to Profile 8.1 first" , item . Id , item . Name ) ;
144148 downmuxedVideoPath = await _downmuxWorkflow . Downmux ( ourSource , cancellationToken ) ;
0 commit comments