Skip to content

Commit da1ce79

Browse files
committed
first release
1 parent 370c58f commit da1ce79

7 files changed

+283
-0
lines changed

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
.vs
2+
*.suo
3+
*.user
4+
*.sln.docstates
5+
6+
[Dd]ebug/
7+
[Rr]elease/
8+
x64/
9+
build/
10+
[Bb]in/
11+
[Oo]bj/

StrmExtract.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +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

StrmExtract/ExtractTask.cs

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,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+
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+
}

StrmExtract/Images/thumb.png

83.1 KB
Loading

StrmExtract/Plugin.cs

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using MediaBrowser.Common.Configuration;
2+
using MediaBrowser.Common.Plugins;
3+
using MediaBrowser.Model.Drawing;
4+
using MediaBrowser.Model.Serialization;
5+
using System;
6+
using System.IO;
7+
8+
namespace StrmExtract
9+
{
10+
public class Plugin : BasePlugin<PluginConfiguration>, IHasThumbImage
11+
{
12+
13+
public static Plugin Instance { get; private set; }
14+
public static string PluginName = "Strm Extract";
15+
private Guid _id = new Guid("6107fc8c-443a-4171-b70e-7590658706d8");
16+
17+
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer)
18+
{
19+
Instance = this;
20+
}
21+
22+
public Stream GetThumbImage()
23+
{
24+
var type = GetType();
25+
return type.Assembly.GetManifestResourceStream(type.Namespace + ".Images.thumb.png");
26+
}
27+
28+
public ImageFormat ThumbImageFormat
29+
{
30+
get
31+
{
32+
return ImageFormat.Png;
33+
}
34+
}
35+
36+
public override string Description
37+
{
38+
get
39+
{
40+
return "Extracts info from Strm targets";
41+
}
42+
}
43+
44+
public override string Name
45+
{
46+
get { return PluginName; }
47+
}
48+
49+
public override Guid Id
50+
{
51+
get { return _id; }
52+
}
53+
}
54+
}
55+
56+

StrmExtract/PluginConfiguration.cs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using MediaBrowser.Model.Plugins;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace StrmExtract
7+
{
8+
public class PluginConfiguration : BasePluginConfiguration
9+
{
10+
11+
}
12+
}

StrmExtract/StrmExtract.csproj

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
4+
<AssemblyVersion>1.0.0.0</AssemblyVersion>
5+
<FileVersion>1.0.0.0</FileVersion>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<None Remove="Images\thumb.png" />
9+
</ItemGroup>
10+
<ItemGroup>
11+
<EmbeddedResource Include="Images\thumb.png" />
12+
</ItemGroup>
13+
<ItemGroup>
14+
<PackageReference Include="mediabrowser.server.core" Version="4.7.9" />
15+
<PackageReference Include="System.Memory" Version="4.5.5" />
16+
</ItemGroup>
17+
<ItemGroup>
18+
<Folder Include="Properties\" />
19+
</ItemGroup>
20+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
21+
<Exec Command="xcopy &quot;$(TargetPath)&quot; &quot;%25AppData%25\Emby-Server\programdata\plugins\&quot; /y" />
22+
</Target>
23+
</Project>

0 commit comments

Comments
 (0)