Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug where virtual folders containing 2 folders with the same na…

…me would fail to load

Added name and description to IPlugin

git-svn-id: https://videobrowser.googlecode.com/svn/trunk@1093 096cc86f-8a4c-0410-9b85-8b5e0eee1c45
  • Loading branch information...
commit 44a0eed565c7cac997110a2800fe21dc9c6d84cd 1 parent c90a962
sam.saffron authored
View
7 DvrmsMetadataProvider/Plugin.cs
@@ -12,5 +12,12 @@ public class Plugin : IPlugin {
config.Providers.Add(new MetadataProviderFactory(typeof(DvrmsMetadataProvider)));
}
+ public string Name {
+ get { return "DVR-MS metadata."; }
+ }
+
+ public string Description {
+ get { return "This plugin provides metadata for DVR-MS files. (all your recorded tv shows start off as dvr-ms files)"; }
+ }
}
}
View
10 FilmTrailerPlugin/Plugin.cs
@@ -10,8 +10,6 @@ namespace FilmTrailerPlugin {
class Plugin : IPlugin {
public static ILogger Logger;
-
-
static readonly Guid TrailersGuid = new Guid("{B70517FE-9B66-44a7-838B-CC2A2B6FEC0C}");
public void Init(LibraryConfig config) {
@@ -23,5 +21,13 @@ class Plugin : IPlugin {
config.RootFolder.AddVirtualChild(trailers);
}
+ public string Name {
+ get { return "Film Trailers"; }
+ }
+
+ public string Description {
+ get { return "Film Trailers powered by filmtrailer.com"; }
+ }
+
}
}
View
8 FrameGrabProvider/Plugin.cs
@@ -25,5 +25,13 @@ public class Plugin : IPlugin {
}
+ public string Name {
+ get { return "Frame Grab provider"; }
+ }
+
+ public string Description {
+ get { return "This plugin provides frame grabs for videos which contain no cover art."; }
+ }
+
}
}
View
8 ITunesTrailers/Plugin.cs
@@ -20,5 +20,13 @@ public class Plugin : IPlugin {
config.RootFolder.AddVirtualChild(trailers);
}
+ public string Name {
+ get { return "ITunes Trailers"; }
+ }
+
+ public string Description {
+ get { return "HD Trailers powered by Apple."; }
+ }
+
}
}
View
36 LogViewer/LogMessages.cs
@@ -17,6 +17,7 @@ class LogMessages : ObservableCollection<LogRow> {
string path;
+ Dictionary<string, DateTime> logfileChangeDate = new Dictionary<string,DateTime>();
HashSet<Guid> rowHashs = new HashSet<Guid>();
System.Threading.Timer timer;
Dispatcher dispatcher;
@@ -75,8 +76,24 @@ class LogMessages : ObservableCollection<LogRow> {
private void LoadMessages() {
var newRows = new List<LogRow>();
+ var filesToLoad = new List<string>();
- foreach (var file in Directory.GetFiles(path)) {
+ var logFiles = new DirectoryInfo(path).GetFiles();
+
+ foreach (var file in logFiles) {
+ DateTime lastChanged;
+ if (!logfileChangeDate.TryGetValue(file.FullName, out lastChanged)) {
+ lastChanged = DateTime.MinValue;
+ }
+
+ if (lastChanged < file.LastWriteTime) {
+ filesToLoad.Add(file.FullName);
+ logfileChangeDate[file.FullName] = file.LastWriteTime;
+ }
+
+ }
+
+ foreach (var file in filesToLoad) {
foreach (var line in GetLines(file)) {
LogRow row = LogRow.FromString(line);
var hash = row.ToString().GetMD5();
@@ -87,14 +104,15 @@ class LogMessages : ObservableCollection<LogRow> {
}
}
- dispatcher.Invoke((Action)(() =>
- {
- foreach (var item in newRows.OrderBy(row => row.Time))
- {
- this.Items.Add(item);
- }
- OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
- }));
+ if (newRows.Count > 0) {
+ dispatcher.Invoke((Action)(() =>
+ {
+ foreach (var item in newRows.OrderBy(row => row.Time)) {
+ this.Items.Add(item);
+ }
+ OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
+ }));
+ }
}
View
11 MediaBrowser/Library/Extensions/DistinctExtensions.cs
@@ -5,11 +5,11 @@
namespace MediaBrowser.Library.Extensions {
public static class DistinctExtensions {
- class StructEqualityComparer<T, TKey> : IEqualityComparer<T> where TKey : struct {
+ class EqualityComparer<T, TKey> : IEqualityComparer<T> {
Func<T, TKey> lookup;
- public StructEqualityComparer(Func<T, TKey> lookup) {
+ public EqualityComparer(Func<T, TKey> lookup) {
this.lookup = lookup;
}
@@ -22,10 +22,11 @@ class StructEqualityComparer<T, TKey> : IEqualityComparer<T> where TKey : struct
}
}
-
- public static IEnumerable<T> Distinct<T, TKey>(this IEnumerable<T> list, Func<T, TKey> lookup) where TKey : struct {
- return list.Distinct(new StructEqualityComparer<T, TKey>(lookup));
+ public static IEnumerable<T> Distinct<T, TKey>(this IEnumerable<T> list, Func<T, TKey> lookup) {
+ // null handling perhaps ?
+ return list.Distinct(new EqualityComparer<T, TKey>(lookup));
}
+
}
}
View
1  MediaBrowser/Library/Factories/SharedKernel.cs
@@ -11,5 +11,6 @@ namespace MediaBrowser.Library.Factories {
/// </summary>
public class SharedKernel {
+
}
}
View
12 MediaBrowser/Library/Filesystem/FolderMediaLocation.cs
@@ -38,9 +38,19 @@ internal FolderMediaLocation(FileInfo info, IFolderMediaLocation parent, IFolder
}
Dictionary<string, IMediaLocation> CreateIndex() {
- return children.Value.ToDictionary(item => System.IO.Path.GetFileName(item.Path).ToLower());
+ // the juggling here is to workaround a situation where we have 2 children with the same name
+ return children
+ .Value
+ .Select(item => new {Name = System.IO.Path.GetFileName(item.Path).ToLower(), Value = item})
+ .Distinct(item => item.Name)
+ .ToDictionary(item => item.Name, item => item.Value);
}
+ /// <summary>
+ /// Will return the first child with the specific name
+ /// </summary>
+ /// <param name="name"></param>
+ /// <returns></returns>
public IMediaLocation GetChild(string name) {
return index.Value[name.ToLower()];
}
View
2  MediaBrowser/Library/Plugins/IPlugin.cs
@@ -11,5 +11,7 @@ namespace MediaBrowser.Library.Plugins {
/// </summary>
public interface IPlugin {
void Init(LibraryConfig config);
+ string Name { get; }
+ string Description { get; }
}
}
View
4 MediaBrowser/Library/Providers/ImageByNameProvider.cs
@@ -17,10 +17,14 @@ class ImageByNameProvider : ImageFromMediaLocationProvider
protected override string Location
{
get {
+
+ if (string.IsNullOrEmpty(Item.Name)) return "";
+
string location = Config.Instance.ImageByNameLocation;
if ((location == null) || (location.Length == 0))
location = Path.Combine(ApplicationPaths.AppConfigPath, "ImagesByName");
char[] invalid = Path.GetInvalidFileNameChars();
+
string name = Item.Name;
foreach (char c in invalid)
name = name.Replace(c.ToString(), "");
View
7 MediaInfoProvider/Plugin.cs
@@ -17,5 +17,12 @@ public class Plugin : IPlugin {
config.Providers.Add(MetadataProviderFactory.Get<MediaInfoProvider>());
}
+ public string Name {
+ get { return "MediaInfo Provider"; }
+ }
+
+ public string Description {
+ get { return "This plugin provides rich information about your media using the MediaInfo project."; }
+ }
}
}
View
8 MtnFrameGrabProvider/Plugin.cs
@@ -37,6 +37,14 @@ public class Plugin : IPlugin {
});
}
+ public string Name {
+ get { return "High Quality Thumbnails"; }
+ }
+
+ public string Description {
+ get { return "High quality automatic thumbnails powered by the mtn project. http://moviethumbnail.sourceforge.net"; }
+ }
+
public static void EnsureMtnIsExtracted() {
if (!Directory.Exists(MtnPath)) {
View
7 NndbMetadataProvider/Plugin.cs
@@ -17,5 +17,12 @@ class Plugin : IPlugin {
config.Providers.Add(MetadataProviderFactory.Get<NndbPeopleProvider>());
}
+ public string Name {
+ get { return "Nndb image provider"; }
+ }
+
+ public string Description {
+ get { return "Downloads actor and director images from nndb.com"; }
+ }
}
}
View
2  TestMediaBrowser/TestLibrary.cs
@@ -70,8 +70,6 @@ public class TestLibrary {
}
Assert.AreEqual("movie3", rootFolder.Children.ElementAt(1).Name);
-
-
}
[Ignore("Only used for performance testing!")]
View
48 TestMediaBrowser/TestMediaLocation.cs
@@ -19,6 +19,54 @@ public class TestMediaLocation {
}
}
+
+ // note this test can take a while..
+ [Test]
+ public void DodgyVfsShouldPartiallyLoad() {
+
+ var vf = Path.Combine(testDir, "test.vf");
+
+ Directory.CreateDirectory(testDir);
+ var dir1 = Path.Combine(testDir, "test");
+ Directory.CreateDirectory(dir1 + "\\path");
+
+ VirtualFolderContents generator = new VirtualFolderContents("");
+ generator.AddFolder(dir1);
+ generator.AddFolder(@"\\10.0.0.4\mydir");
+
+ File.WriteAllText(vf, generator.Contents);
+
+ var root = MediaLocationFactory.Instance.Create(vf) as VirtualFolderMediaLocation;
+
+ Assert.AreEqual(1, root.Children.Count);
+
+ }
+
+ [Test]
+ public void VirtualFoldersCanContainDuplicateFiles() {
+ Directory.CreateDirectory(testDir);
+
+ var dir1 = Path.Combine(testDir, "test");
+ var dir2 = Path.Combine(testDir, "test2");
+
+ var vf = Path.Combine(testDir, "test.vf");
+
+ Directory.CreateDirectory(dir1 + "\\path");
+ Directory.CreateDirectory(dir2 + "\\path");
+
+
+ VirtualFolderContents generator = new VirtualFolderContents("");
+ generator.AddFolder(dir1);
+ generator.AddFolder(dir2);
+
+ File.WriteAllText(vf, generator.Contents);
+
+ var root = MediaLocationFactory.Instance.Create(vf) as VirtualFolderMediaLocation;
+
+ Assert.AreEqual(2, root.Children.Count);
+ Assert.AreEqual(true, root.ContainsChild("path"));
+ }
+
[Test]
public void TestStandardScanning() {
CreateTree(3, 10, "hello world");
Please sign in to comment.
Something went wrong with that request. Please try again.