Skip to content

Commit 7c54095

Browse files
authored
modify
add "softlink" keyword match && change logs ouput.
1 parent da1ce79 commit 7c54095

40 files changed

+1957
-946
lines changed

LICENSE

+674-674
Large diffs are not rendered by default.

StrmExtract.sln

+25-25
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
2-
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.8.34330.188
5-
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrmExtract", "StrmExtract\StrmExtract.csproj", "{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}"
7-
EndProject
8-
Global
9-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10-
Debug|Any CPU = Debug|Any CPU
11-
Release|Any CPU = Release|Any CPU
12-
EndGlobalSection
13-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17-
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Release|Any CPU.Build.0 = Release|Any CPU
18-
EndGlobalSection
19-
GlobalSection(SolutionProperties) = preSolution
20-
HideSolutionNode = FALSE
21-
EndGlobalSection
22-
GlobalSection(ExtensibilityGlobals) = postSolution
23-
SolutionGuid = {B21B91C2-6AA0-44B0-9DD0-700D48445883}
24-
EndGlobalSection
25-
EndGlobal
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34330.188
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StrmExtract", "StrmExtract\StrmExtract.csproj", "{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E0CEFE4D-2138-42CB-A03F-11E7991BF7A9}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {B21B91C2-6AA0-44B0-9DD0-700D48445883}
24+
EndGlobalSection
25+
EndGlobal

StrmExtract/ExtractTask.cs

+138-156
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,138 @@
1-
using MediaBrowser.Common.Configuration;
2-
using MediaBrowser.Controller.Library;
3-
using MediaBrowser.Controller.MediaEncoding;
4-
using MediaBrowser.Model.IO;
5-
using MediaBrowser.Model.Logging;
6-
using MediaBrowser.Model.Tasks;
7-
using System;
8-
using System.Collections.Generic;
9-
using System.Text;
10-
using System.Threading.Tasks;
11-
using System.Threading;
12-
using MediaBrowser.Model.MediaInfo;
13-
using MediaBrowser.Model.Dto;
14-
using MediaBrowser.Controller.Entities;
15-
using MediaBrowser.Model.Configuration;
16-
using MediaBrowser.Controller.Providers;
17-
using System.Collections;
18-
19-
namespace StrmExtract
20-
{
21-
public class ExtractTask : IScheduledTask
22-
{
23-
private readonly ILogger _logger;
24-
private readonly ILibraryManager _libraryManager;
25-
private readonly IFileSystem _fileSystem;
26-
private readonly ILibraryMonitor _libraryMonitor;
27-
private readonly IMediaProbeManager _mediaProbeManager;
28-
29-
public ExtractTask(ILibraryManager libraryManager,
30-
ILogger logger,
31-
IFileSystem fileSystem,
32-
ILibraryMonitor libraryMonitor,
33-
IMediaProbeManager prob)
34-
{
35-
_libraryManager = libraryManager;
36-
_logger = logger;
37-
_fileSystem = fileSystem;
38-
_libraryMonitor = libraryMonitor;
39-
_mediaProbeManager = prob;
40-
}
41-
42-
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
43-
{
44-
_logger.Info("StrmExtract - Task Execute");
45-
46-
InternalItemsQuery query = new InternalItemsQuery();
47-
48-
query.HasPath = true;
49-
query.HasContainer = false;
50-
query.ExcludeItemTypes = new string[] { "Folder", "CollectionFolder", "UserView", "Series", "Season", "Trailer", "Playlist" };
51-
52-
BaseItem[] results = _libraryManager.GetItemList(query);
53-
_logger.Info("StrmExtract - Number of items before : " + results.Length);
54-
List<BaseItem> items = new List<BaseItem>();
55-
foreach(BaseItem item in results)
56-
{
57-
if(!string.IsNullOrEmpty(item.Path) &&
58-
item.Path.EndsWith(".strm", StringComparison.InvariantCultureIgnoreCase) &&
59-
item.GetMediaStreams().Count == 0)
60-
{
61-
items.Add(item);
62-
}
63-
else
64-
{
65-
_logger.Info("StrmExtract - Item dropped : " + item.Name + " - " + item.Path + " - " + item.GetType() + " - " + item.GetMediaStreams().Count);
66-
}
67-
}
68-
69-
_logger.Info("StrmExtract - Number of items after : " + items.Count);
70-
71-
double total = items.Count;
72-
int current = 0;
73-
foreach(BaseItem item in items)
74-
{
75-
if (cancellationToken.IsCancellationRequested)
76-
{
77-
_logger.Info("StrmExtract - Task Cancelled");
78-
break;
79-
}
80-
double percent_done = (current / total) * 100;
81-
progress.Report(percent_done);
82-
83-
MetadataRefreshOptions options = new MetadataRefreshOptions(_fileSystem);
84-
options.EnableRemoteContentProbe = true;
85-
options.ReplaceAllMetadata = true;
86-
options.EnableThumbnailImageExtraction = false;
87-
options.ImageRefreshMode = MetadataRefreshMode.ValidationOnly;
88-
options.MetadataRefreshMode = MetadataRefreshMode.ValidationOnly;
89-
options.ReplaceAllImages = false;
90-
91-
ItemUpdateType resp = await item.RefreshMetadata(options, cancellationToken);
92-
93-
_logger.Info("StrmExtract - " + current + "/" + total + " - " + item.Path);
94-
95-
//Thread.Sleep(5000);
96-
current++;
97-
}
98-
99-
progress.Report(100.0);
100-
_logger.Info("StrmExtract - Task Complete");
101-
102-
/*
103-
LibraryOptions lib_options = new LibraryOptions();
104-
List<MediaSourceInfo> sources = item.GetMediaSources(true, true, lib_options);
105-
106-
_logger.Info("StrmExtract - GetMediaSources : " + sources.Count);
107-
108-
MediaInfoRequest request = new MediaInfoRequest();
109-
110-
MediaSourceInfo mediaSource = sources[0];
111-
request.MediaSource = mediaSource;
112-
113-
_logger.Info("StrmExtract - GetMediaInfo");
114-
MediaInfo info = await _mediaProbeManager.GetMediaInfo(request, cancellationToken);
115-
116-
_logger.Info("StrmExtract - Extracting Strm info " + info);
117-
118-
_logger.Info("StrmExtract - Extracting Strm info : url - " + info.DirectStreamUrl);
119-
_logger.Info("StrmExtract - Extracting Strm info : runtime - " + info.RunTimeTicks);
120-
*/
121-
}
122-
123-
public string Category
124-
{
125-
get { return "Strm Extract"; }
126-
}
127-
128-
public string Key
129-
{
130-
get { return "StrmExtractTask"; }
131-
}
132-
133-
public string Description
134-
{
135-
get { return "Run Strm Media Info Extraction"; }
136-
}
137-
138-
public string Name
139-
{
140-
get { return "Process Strm targets"; }
141-
}
142-
143-
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
144-
{
145-
return new[]
146-
{
147-
new TaskTriggerInfo
148-
{
149-
Type = TaskTriggerInfo.TriggerDaily,
150-
TimeOfDayTicks = TimeSpan.FromHours(3).Ticks,
151-
MaxRuntimeTicks = TimeSpan.FromHours(24).Ticks
152-
}
153-
};
154-
}
155-
}
156-
}
1+
using MediaBrowser.Common.Configuration;
2+
using MediaBrowser.Controller.Library;
3+
using MediaBrowser.Controller.MediaEncoding;
4+
using MediaBrowser.Model.IO;
5+
using MediaBrowser.Model.Logging;
6+
using MediaBrowser.Model.Tasks;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Text;
10+
using System.Threading.Tasks;
11+
using System.Threading;
12+
using MediaBrowser.Model.MediaInfo;
13+
using MediaBrowser.Model.Dto;
14+
using MediaBrowser.Controller.Entities;
15+
using MediaBrowser.Model.Configuration;
16+
using MediaBrowser.Controller.Providers;
17+
using System.Collections;
18+
using System.Linq;
19+
20+
namespace StrmExtract
21+
{
22+
public class ExtractTask : IScheduledTask
23+
{
24+
private readonly ILogger _logger;
25+
private readonly ILibraryManager _libraryManager;
26+
private readonly IFileSystem _fileSystem;
27+
private readonly ILibraryMonitor _libraryMonitor;
28+
private readonly IMediaProbeManager _mediaProbeManager;
29+
30+
public ExtractTask(ILibraryManager libraryManager,
31+
ILogger logger,
32+
IFileSystem fileSystem,
33+
ILibraryMonitor libraryMonitor,
34+
IMediaProbeManager prob)
35+
{
36+
_libraryManager = libraryManager;
37+
_logger = logger;
38+
_fileSystem = fileSystem;
39+
_libraryMonitor = libraryMonitor;
40+
_mediaProbeManager = prob;
41+
}
42+
43+
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
44+
{
45+
_logger.Info("MediaExtract - Task Execute");
46+
47+
InternalItemsQuery query = new InternalItemsQuery();
48+
49+
query.HasPath = true;
50+
query.HasContainer = false;
51+
query.ExcludeItemTypes = new string[] { "Folder", "CollectionFolder", "UserView", "Series", "Season", "Trailer", "Playlist" };
52+
53+
BaseItem[] results = _libraryManager.GetItemList(query);
54+
_logger.Info("MediaExtract - Scan items : " + results.Length);
55+
List<BaseItem> items = new List<BaseItem>();
56+
foreach(BaseItem item in results)
57+
{
58+
if(!string.IsNullOrEmpty(item.Path) &&
59+
(item.Path.Contains("softlink") || item.Path.Contains("strm")) &&
60+
item.GetMediaStreams().Count == 0)
61+
{
62+
items.Add(item);
63+
_logger.Info("MediaExtract - Item added : " + " - " + item.Path);
64+
}
65+
else
66+
{
67+
_logger.Info("MediaExtract - Item dropped : " + " - " + item.Path + " - MediaStreams: " + item.GetMediaStreams().Count);
68+
}
69+
}
70+
71+
_logger.Info("MediaExtract - Nums of targets : " + items.Count);
72+
73+
double total = items.Count;
74+
int current = 0;
75+
foreach(BaseItem item in items)
76+
{
77+
if (cancellationToken.IsCancellationRequested)
78+
{
79+
_logger.Info("MediaExtract - Task Cancelled");
80+
break;
81+
}
82+
double percent_done = (current / total) * 100;
83+
progress.Report(percent_done);
84+
85+
MetadataRefreshOptions options = new MetadataRefreshOptions(_fileSystem);
86+
options.EnableRemoteContentProbe = true;
87+
options.ReplaceAllMetadata = true;
88+
options.EnableThumbnailImageExtraction = false;
89+
options.ImageRefreshMode = MetadataRefreshMode.ValidationOnly;
90+
options.MetadataRefreshMode = MetadataRefreshMode.ValidationOnly;
91+
options.ReplaceAllImages = false;
92+
93+
ItemUpdateType resp = await item.RefreshMetadata(options, cancellationToken);
94+
95+
_logger.Info("MediaExtract - " + current + "/" + total + " - " + item.Path);
96+
97+
//Thread.Sleep(5000);
98+
current++;
99+
}
100+
101+
progress.Report(100.0);
102+
_logger.Info("MediaExtract - Task Complete");
103+
}
104+
105+
public string Category
106+
{
107+
get { return "Media Extract"; }
108+
}
109+
110+
public string Key
111+
{
112+
get { return "MediaExtract Task"; }
113+
}
114+
115+
public string Description
116+
{
117+
get { return "Run Media Info Extraction"; }
118+
}
119+
120+
public string Name
121+
{
122+
get { return "Process Media targets"; }
123+
}
124+
125+
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
126+
{
127+
return new[]
128+
{
129+
new TaskTriggerInfo
130+
{
131+
Type = TaskTriggerInfo.TriggerDaily,
132+
TimeOfDayTicks = TimeSpan.FromHours(3).Ticks,
133+
MaxRuntimeTicks = TimeSpan.FromHours(24).Ticks
134+
}
135+
};
136+
}
137+
}
138+
}

0 commit comments

Comments
 (0)